I am blocked with unchecking the checkbox. there are two check fields sms and email i am able to check and uncheck checkbox for sms but for email field uncheck is not working Here is my code,
const Notifications = ({
editAlertState,
setEditAlertState,
handleNotifyByEmailSMS,
handleNotifyByChange,
name,
userEmail,
handleToggle,
phoneNumber,
placeId,
errors,
register,
}) => {
const places = useSelector((state) => state.entities.places.data);
const generateNotificationList = (editAlertState, name, places, placeId) => {
let place = null;
if (placeId) {
place = places.filter((place) => place.id === placeId)[0];
} else {
place = places[0];
}
let options = editAlertState.editPlace
? [
`When ${name} is located near ${place.name}`,
`When ${name} is not located near ${place.name}`,
"Always",
]
: ["Always"];
return options.map((e) => {
return {
key: e,
value: e,
};
});
};
<div className={style.notify_wrapper}>
<TmoH4 className={style.subheading}>How to notify me</TmoH4>
<div className={style.checkbox}>
<input
type="checkbox"
checked={editAlertState.SMS}
id="text"
value="SMS"
name="notifyBy"
onChange={(e) =>
handleNotifyByEmailSMS(e, editAlertState, setEditAlertState)
}
/>
<label htmlFor="text">
Text message {StringUtilities.formatPhoneNumber(phoneNumber)}
</label>
</div>
<div className={style.checkbox}>
<input
type="checkbox"
checked={editAlertState.email}
id="email"
value="EMAIL"
name="notifyBy"
onChange={(e) =>
handleNotifyByEmailSMS(e, editAlertState, setEditAlertState)
}
/>
<label htmlFor="email">Email {userEmail}</label>
</div>
i am not able to uncheck email checkbox. Can anyone please tell what exactly i am missing in this