diff --git a/src/constants/constants.js b/src/constants/constants.js index fefeb4a..5acd258 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -1,12 +1,41 @@ export const PRIME_VUE_TICKS_LIMIT = 6; export const GRID_COLOR = '#64748b'; +export const MODAL_CREATE_NEW = 'MODAL_CREATE_NEW'; +export const MODAL_ACCT_EDIT = 'MODAL_ACCT_EDIT'; +export const MODAL_ACCT_INFO = 'MODAL_ACCT_INFO'; export const knownLayoutChartOption = { padding: { top: 16, left: 8, right: 8, } - }; +}; +export const accountList = [ + { + id: 12345, + account: "REDACTED-USER1", + fullName: "Alice Zheng", + adminRights: true, + accountActivation: true, + detail: "abcde", + }, + { + id: 345, + account: "REDACTED-USER2", + fullName: "Mike Chen", + adminRights: true, + accountActivation: true, + detail: "abcde", + }, + { + id: 88, + account: "REDACTED-USER3", + fullName: "Tory Cheng", + adminRights: true, + accountActivation: true, + detail: "abcde", + }, +]; export const knownScaleLineChartOptions = { x: { type: 'time', diff --git a/src/i18n/en.json b/src/i18n/en.json index 23a0bd1..8147e1c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -20,7 +20,8 @@ "AccountActivation": "Account Activation", "Detail": "Detail", "Edit": "Edit", - "AccountEdit": "Account Edit" + "AccountEdit": "Account Edit", + "AccountInformation": "Account Information" }, "Compare": { "timeUsage": "Time Usage", diff --git a/src/stores/acctMgmt.js b/src/stores/acctMgmt.js index 721a859..2f3a31a 100644 --- a/src/stores/acctMgmt.js +++ b/src/stores/acctMgmt.js @@ -1,8 +1,17 @@ import { defineStore } from "pinia"; +import { accountList, } from "@/constants/constants.js"; export default defineStore('acctMgmtStore', { state: () => ({ isAcctMenuOpen: false, + currentViewingUser: { + id: 12345, + account: "REDACTED-USER1", + fullName: "Alice Zheng", + adminRights: true, + accountActivation: true, + detail: "abcde", + } }), getters: { }, @@ -22,5 +31,13 @@ export default defineStore('acctMgmtStore', { toggleIsAcctMenuOpen() { this.isAcctMenuOpen = !this.isAcctMenuOpen; }, + /** + * For convenience, set current viewing data according to unique user ID. + * @param {number} userId + */ + setCurrentViewingUser(userId) { + const userFind = accountList.find(user => user.id === userId); + this.currentViewingUser = userFind ? userFind : {}; + }, }, }) \ No newline at end of file diff --git a/src/stores/modal.js b/src/stores/modal.js index 147a387..491f88e 100644 --- a/src/stores/modal.js +++ b/src/stores/modal.js @@ -1,12 +1,14 @@ import { defineStore } from 'pinia'; - +import { MODAL_ACCT_INFO, } from '@/constants/constants.js'; export const useModalStore = defineStore('modalStore', { state: () => ({ isModalOpen: false, + whichModal: MODAL_ACCT_INFO, }), actions: { - openModal() { + openModal(whichModal) { this.isModalOpen = true; + this.whichModal = whichModal; }, closeModal() { this.isModalOpen = false; diff --git a/src/views/AccountManagement/AccountAdmin/index.vue b/src/views/AccountManagement/AccountAdmin/index.vue index 4009a75..3a5cc8d 100644 --- a/src/views/AccountManagement/AccountAdmin/index.vue +++ b/src/views/AccountManagement/AccountAdmin/index.vue @@ -54,8 +54,15 @@ import { storeToRefs, mapState, mapActions, } from 'pinia'; import LoadingStore from '@/stores/loading.js'; import { useModalStore } from '@/stores/modal.js'; +import useAcctMgmtStore from '@/stores/acctMgmt.js'; import SearchBar from '../../../components/AccountMenu/SearchBar.vue'; import i18next from '@/i18n/i18n.js'; +import { + MODAL_CREATE_NEW, + MODAL_ACCT_EDIT, + MODAL_ACCT_INFO, + accountList, + } from "@/constants/constants.js"; const ONCE_RENDER_NUM_OF_DATA = 9; @@ -74,33 +81,6 @@ function repeatAccountList(accountList, N) { return repeatedList; } -const accountList = [ - { - id: 12345, - account: "REDACTED-USER1", - fullName: "Alice Zheng", - adminRights: true, - accountActivation: true, - detail: "abcde", - }, - { - id: 345, - account: "REDACTED-USER2", - fullName: "Mike Chen", - adminRights: true, - accountActivation: true, - detail: "abcde", - }, - { - id: 88, - account: "REDACTED-USER3", - fullName: "Tory Cheng", - adminRights: true, - accountActivation: true, - detail: "abcde", - }, -]; - const repeatedAccountList = repeatAccountList(accountList, 20); export default { setup() { @@ -166,12 +146,14 @@ export default { }, onDetailBtnClick(dataId){ - this.openModal(); + this.openModal(MODAL_ACCT_INFO); + this.setCurrentViewingUser(dataId); }, onEditBtnClick(dataId){ - this.openModal(); + this.openModal(MODAL_ACCT_EDIT); }, ...mapActions(useModalStore, ['openModal']), + ...mapActions(useAcctMgmtStore, ['setCurrentViewingUser']), }, created() { diff --git a/src/views/AccountManagement/ModalAccountEdit.vue b/src/views/AccountManagement/ModalAccountEdit.vue index f5293d5..3c377c2 100644 --- a/src/views/AccountManagement/ModalAccountEdit.vue +++ b/src/views/AccountManagement/ModalAccountEdit.vue @@ -1,14 +1,7 @@