Hi Gobi,
The good news is, yes you can switch it out, and as it turns out, it's actually fairly easy to do on your phone!
There's a small circuit board that holds the headphone jack and charging port that's cheap and easy to replace. Here's the part you need; this one is on AliExpress, but you can find it on eBay, Amazon and several other parts suppliers.
[link|https://www.aliexpress.com/i/2255801011561447.html|Repair Parts Charging Port Board For Galaxy M30s SM-M307F Mobile Phone Flex Cables Replace parts USB Charger Board - AliExpress Cellphones & Telecommunications|new_window=true]
Of course, you'll need instructions on how to swap out that part, and YouTube has you covered.
[link|https://www.youtube.com/watch?v=hIt7mmJK_qo|Samsung M30 charging problem|new_window=true]
Good luck with your repair; let us know how it goes!