Offering condolences means advising the person to bear their loss with patience, with the promise of reward, warning against sin, and praying for forgiveness for the deceased and for the afflicted one to be compensated for his loss.
End quote from al-Mawsoo‘ah al-Fiqhiyyah, 12/287
From the scholarly definition of condolences, it is clear that it is prescribed to offer condolences to anyone who is stricken by calamity, whether that is the loss of a relative, wealth or a job, or any other calamity that may befall a Muslim. Offering condolences, as prescribed in Islam, is not limited to cases of death.
It says in al-Bayjurami’s commentary on Minhaaj at-Tullaab (1/500): It is also Sunnah to offer condolences on the loss of wealth… And to offer supplication for him as appropriate. End quote.
In Haashiyat al-Jamal (2/214) it says: It may be said to one who has lost wealth or anything else that may be replaced: May Allah compensate you and grant you something similar to that which you have lost. If his child, father, mother or the like, who cannot be replaced, has died, then one may say: May Allah comfort you. End quote.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: You said concerning condolences that condolences may be offered in cases other than death. Is it Sunnah to offer condolences in cases other than death? How would you describe condolences?
Offering condolences means encouraging the one who has suffered a calamity to bear it with patience and to hope for reward, whether it is the death of a loved one or anything else, such as one who has lost a great deal of his wealth and the like. So you should go to him, console him and encourage him to be patient so that he will not flounder in his grief. End quote from Majmoo‘ al-Fataawa, 17/384
And Allah knows best.