This could be three things: a bad battery a bad charging port logicboard issue Try Replacing the battery first. Then the port. If neither of those work it’s a board level problem.
Rewa has just recently made a video on this. It cannot be fixed by a 3rd repair. You have to go to Apple but even then they won’t work on the phone because you swapped the battery.