export default () => {
const modals = useState(
"modals",
(): { [k: string]: ReturnType<typeof useModal> } => {
return {};
},
);
const closeModals = () => {
let modal: keyof typeof modals.value;
for (modal in modals.value) {
if (modals.value[modal].isOpen.value) {
modals.value[modal].close();
}
}
};
modals.value = {
login: useModal(closeModals),
signup: useModal(closeModals),
forgotPassword: useModal(closeModals),
resetPassword: useModal(closeModals),
emailConfirmationSuccess: useModal(closeModals),
emailConfirmationFailed: useModal(closeModals),
bookingDetailsModal: useModal(closeModals),
profileCompletionModal: useModal(closeModals),
};
return {
loginModal: modals.value.login,
signupModal: modals.value.signup,
forgotPasswordModal: modals.value.forgotPassword,
resetPasswordModal: modals.value.resetPassword,
emailConfirmSuccessModal: modals.value.emailConfirmationSuccess,
emailConfirmFailedModal: modals.value.emailConfirmationFailed,
bookingDetailsModal: modals.value.bookingDetailsModal,
profileCompletionModal: modals.value.profileCompletionModal,
};
};
export default () => {
const modals = useState(
"modals",
(): { [k: string]: ReturnType<typeof useModal> } => {
return {};
},
);
const closeModals = () => {
let modal: keyof typeof modals.value;
for (modal in modals.value) {
if (modals.value[modal].isOpen.value) {
modals.value[modal].close();
}
}
};
modals.value = {
login: useModal(closeModals),
signup: useModal(closeModals),
forgotPassword: useModal(closeModals),
resetPassword: useModal(closeModals),
emailConfirmationSuccess: useModal(closeModals),
emailConfirmationFailed: useModal(closeModals),
bookingDetailsModal: useModal(closeModals),
profileCompletionModal: useModal(closeModals),
};
return {
loginModal: modals.value.login,
signupModal: modals.value.signup,
forgotPasswordModal: modals.value.forgotPassword,
resetPasswordModal: modals.value.resetPassword,
emailConfirmSuccessModal: modals.value.emailConfirmationSuccess,
emailConfirmFailedModal: modals.value.emailConfirmationFailed,
bookingDetailsModal: modals.value.bookingDetailsModal,
profileCompletionModal: modals.value.profileCompletionModal,
};
};