Cypress method for choosing an if section depending on a string

How can I write this method correctly in cypress so that when I call for example setToOffService('Online booking') it knows how to go to the correct if and call the appropriate id for that string.

I hope I have provided all the important details

 setToOffService(name: string) : void {
    
        cy.get('#Service_IsActive').then(($name) => {
    
            if ($name.text().includes('Service is available')) {
                cy.get('#Service_IsActive').click({force:true});
            }
            else if ($name.text().includes('Online booking')) {
                cy.get('#Service_AllowOnlineScheduling').click({force:true});
            }
        })
    }