Svartpilen401 Gear Shaft came lose and hung off til I pulled over, was about to so.e

Bought bike yesterday. 2018 401 with 1500miles. All services was done, I checked paperwork before I bought it amongst everything else I saw bike looked and rode great. Till this happened.

Left for a 30miles ride back home and this happened about 3 blocks away from home.

Please let me know your thoughts and feedback, thanks. I'm worried it may have done serious damage

New to the sub