The other day my iphone would randomly just shut off and when turning it back on it says my battery was dead and gave me the connect to power icons. When I did and tried to reset it, it would just shut down again. This happened a few times. The phone said that it had like 30% battery left
A number of threads on the topic exist with some more information about it all that might be of some help (although it doesn't seem there are any specific solutions that really work for everyone), one of the more recent ones is at https://forums.macrumors.com/threads/1659435/