I no longer have a job as I would like flexible working

I am 8 months into my 9 month maternity leave and I was told a month ago that because I wanted to return 3 days per week and I am a manager I no longer have a job. There is a job coming up within the company but if I want it, I have to wait and apply for it when the job comes up and go for an interview. This is the only company I have worked for as I have been there 15 years!