I can’t quite see from the pics but there should be a metal collar between the two legs, is it missing? You should be able to buy just the clasp half rather than the full item, I’ve seen them on eBay. Alternatively on my clasp that same pin that goes all the way through the legs, collar and side clasps has screws both sides so likely you can replace just that.
EDIT: Sorry just took a closer look at my clasp. The screws in the side don’t line up with that pin, so I think the clasp top replacement would be the better route,