35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
// The Lucia project.
|
|
// Copyright 2023-2026 DSP, inc. All rights reserved.
|
|
// Authors:
|
|
// chiayin.kuo@dsp.im (chiayin), 2023/1/31
|
|
// imacat.yang@dsp.im (imacat), 2023/9/23
|
|
// cindy.chang@dsp.im (Cindy Chang), 2024/5/30
|
|
/** @module stores/modal Account management modal state. */
|
|
|
|
import { defineStore } from "pinia";
|
|
import { MODAL_ACCT_INFO } from "@/constants/constants.js";
|
|
|
|
/** Pinia store for controlling account management modal visibility. */
|
|
export const useModalStore = defineStore("modalStore", {
|
|
state: () => ({
|
|
/** Whether a modal is currently open. */
|
|
isModalOpen: false,
|
|
/** The current modal type constant (e.g. MODAL_ACCT_INFO). */
|
|
whichModal: MODAL_ACCT_INFO,
|
|
}),
|
|
actions: {
|
|
/**
|
|
* Opens a modal of the specified type.
|
|
* @param {string} whichModal - The modal type constant.
|
|
*/
|
|
openModal(whichModal) {
|
|
this.isModalOpen = true;
|
|
this.whichModal = whichModal;
|
|
},
|
|
/** Closes the currently open modal. */
|
|
async closeModal() {
|
|
this.isModalOpen = false;
|
|
},
|
|
},
|
|
});
|