Had this very same problem with an iPhone X immediately following a housing swap. I contacted STS Telecom (Which I totally recommend for data recovery) and the technician informed me that the iPhone X will restart by itself every 3 minutes if the charging port is not connected or it is broken. I went on eBay and ordered a high-quality replacement cable ($10-$15) and viola it was working good as new! I know this may not be the exact problem, but I hope this helps! P.S From what I have heard, there is a temperature sensor on the cable and if the cable does not have that or it is damaged it will cause the phone to have a kernel panic and thus shutting the phone down. so make sure you have a good quality cable!
Sorry to say this but if the camera module is actually damaged you are not able to replace it yourself. Apple has paired the camera to each motherboard so if the camera is replaced you will not get all the functionality back on your device. Sadly the only way to get the rear camera replaced as of now is to go through apple themselves.
You should be able to use this link to get ahold of their customer support, hope this helps! Link: https://help.ifixit.com/category/133-contact-ifixit-customer-support