Praise to Allah.
For someone who hates life and wishes for death, Islam has rulings to stop the victim and make them stop asking Allah to cause them to die, which teaches them how to stop thinking of suicide.
While it does not allow for a Muslim to hate life, it is permissible for the victim to beg Allah to grand him relief, good health, ability to be patient.
Allah, (may He be glorified) says:
“For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease” [Ash-Sharh 94:5-6]. , says (interpretation of the meaning): “For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease” [Ash-Sharh 94:5-6].
This is t clarify that the hardship that you are facing is temporal and after hardship relief will surely follow.
Another thing to consider is the saying of the prophet (PBUH).
In as-Saheehayn it is narrated that Anas (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “No one of you should wish for death because of some harm that befalls him. But if he must do that, then let him say: ‘O Allah, cause me to live so long as life is good for me, and cause me to die so long as that is good for me.’”
From the wording of the hadith, we understand that whatever befalls a Muslim of calamities in this world is an expiation for him, if he seeks reward for that with Allah, may He be exalted, and does not become discontent. This is a wake-up call to turn away from heedlessness, and a lesson for the future.
From Fataawa al-Lajnah ad-Daa’imah li’l-Buhooth al-‘Ilmiyyah wa’l-Ifta’ (25/398).
In short, if you (or someone you know) hate life and wish for death, which will cause them to feel nothing works. Recite the verses above and know for sure that every calamity that happens to you are not meant for someone else. And the best solution is to supplicate to Allah and beg him for a patient and good life.
And Allah knows best.