After constant hounding and harassment I decided to step down, only to have my job handed to a colleague the very next day

I had been a teacher for ten years when I took a new role in a good school albeit a struggling department. My partner and I had been told there was no chance of us having a baby so to my surprise i found out I was pregnant in the October. My work place was really supportive to begin with. It was only when I started maternity leave that they decided as an academy I was not entitled to the maternity pay, only maternity allowance from the government. This was barely enough to cover my contribution to the house. I tried to argue that I had been teaching 10 years but they denied me continuation of service. When I was on maternity I got paid for one kit day despite being constantly asked/ hounded for schemes of work and lessons that I then found were not even used. I returned to work and on meeting my line manager, a woman, I was told that I needed to settle in for the first few weeks then knuckle down because I’d had an unplanned pregnancy and needed to get back to work. I was told that I should be super organised and that I should feel privileged to have such supportive management! I was then informed that to ease me back into work, I would need to produce a 4 year plan of how to improve and have weekly meetings.
After being back two weeks I was constantly asked how I was coping, was I thinking of leaving and when a colleague applied for a job similar to my role at another school, I was called to a meeting to discuss what we could do to keep him- I.e what role could we give him.
After this went on constantly for a week- including surprise meetings and checks I decided to step down from my role only to have it handed to this colleague without interview the very next day.
I’m glad I stepped down but feel like I’ve worked so hard for this position and I have been penalised for having a baby