It’s water resistant not water proof. Also, that is not a permanent state. Time, conditions, etc can deteriorate that ability. At this point you will need to purchase a new phone unless you have a protection plan that covers water damage. You may be able to get one for the out of warranty price but that price might be more than you would like to pay for that model.
“Splash, water, and dust resistance are not permanent conditions and resistance might decrease as a result of normal wear. Liquid damage is not covered under warranty, but you might have rights under consumer law.”
About splash, water, and dust resistance of iPhone 7 and later - Apple Support