Internal battery not detected, can only power on with charger
About a month ago, my Macbook Pro started to face issues where it would be unable to power on without a charger attached to it. When the Macbook Pro was powered on, an x mark would appear over the battery icon and an app I had installed would indicate that there was no internal battery. The entire device would also start moving at a snail's pace making it extremely difficult to use.
I was going to replace the Macbook Pro a week ago, but it suddenly started working again without the need for a charger for no explainable reason. However, just a few days ago, the same issues mentioned earlier started to appear again. Is there any way to resolve this issue permanently?
MacBook Pro 13″, macOS 12.1