diff --git a/src/boot/app.js b/src/boot/app.js index 824a26a1..51734ba5 100644 --- a/src/boot/app.js +++ b/src/boot/app.js @@ -1,10 +1,10 @@ -import { boot } from 'quasar/wrappers' -import { appStore } from 'stores/app' -import { userStore } from 'stores/user' +import { boot } from 'quasar/wrappers'; +import { useAppStore } from 'stores/app'; +import { useUserStore } from 'stores/user'; export default boot(({ app }) => { - const props = app.config.globalProperties - props.$app = appStore() - props.$user = userStore() - props.$actions = document.createElement('div') -}) + const props = app.config.globalProperties; + const userStore = useUserStore(); + props.$app = useAppStore(); + props.$user = userStore.user; +}); diff --git a/src/boot/axios.js b/src/boot/axios.js index 66b2ffe9..0e0549f0 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -1,6 +1,6 @@ import { boot } from 'quasar/wrappers'; import { Connection } from '../js/db/connection'; -import { userStore } from 'stores/user'; +import { useUserStore } from 'stores/user'; import axios from 'axios'; import useNotify from 'src/composables/useNotify.js'; @@ -36,10 +36,10 @@ const onResponseError = error => { }; export default boot(({ app }) => { - const user = userStore(); + const userStore = useUserStore(); function addToken(config) { - if (user.token) { - config.headers.Authorization = user.token; + if (userStore.token) { + config.headers.Authorization = userStore.token; } return config; } diff --git a/src/components/common/VnForm.vue b/src/components/common/VnForm.vue index 450f7000..0f7724d1 100644 --- a/src/components/common/VnForm.vue +++ b/src/components/common/VnForm.vue @@ -2,6 +2,8 @@ import { ref, inject, onMounted, computed, Teleport } from 'vue'; import { useI18n } from 'vue-i18n'; +import { useAppStore } from 'stores/app'; +import { storeToRefs } from 'pinia'; import useNotify from 'src/composables/useNotify.js'; import { generateUpdateSqlQuery, @@ -81,6 +83,8 @@ const emit = defineEmits(['onDataSaved']); const { t } = useI18n(); const jApi = inject('jApi'); const { notify } = useNotify(); +const appStore = useAppStore(); +const { isHeaderMounted } = storeToRefs(appStore); const loading = ref(false); const formData = ref({}); @@ -191,13 +195,14 @@ defineExpose({ !!val || t('globals.fieldRequired'); const vnInputRef = ref(null); const value = computed({ get() { - return $props.modelValue; + return props.modelValue; }, set(value) { emit('update:modelValue', value); @@ -41,7 +41,7 @@ const value = computed({ }); const hover = ref(false); const styleAttrs = computed(() => { - return $props.isOutlined + return props.isOutlined ? { dense: true, outlined: true, rounded: true } : {}; }); @@ -88,9 +88,7 @@ const inputRules = [ + + diff --git a/src/components/ui/ChangePasswordForm.vue b/src/components/ui/ChangePasswordForm.vue index 9f546ded..e2af6236 100644 --- a/src/components/ui/ChangePasswordForm.vue +++ b/src/components/ui/ChangePasswordForm.vue @@ -5,8 +5,10 @@ import { useI18n } from 'vue-i18n'; import VnInput from 'src/components/common/VnInput.vue'; import VnForm from 'src/components/common/VnForm.vue'; -import { userStore as useUserStore } from 'stores/user'; +import { useUserStore } from 'stores/user'; import useNotify from 'src/composables/useNotify.js'; +import { useAppStore } from 'stores/app'; +import { storeToRefs } from 'pinia'; const props = defineProps({ verificationToken: { @@ -24,6 +26,8 @@ const { t } = useI18n(); const api = inject('api'); const userStore = useUserStore(); const { notify } = useNotify(); +const appStore = useAppStore(); +const { isHeaderMounted } = storeToRefs(appStore); const oldPasswordRef = ref(null); const newPasswordRef = ref(null); @@ -33,7 +37,7 @@ const repeatPassword = ref(''); const passwordRequirements = ref(null); const formData = ref({ - userId: userStore.id, + userId: userStore.user.id, oldPassword: '', newPassword: '' }); @@ -75,7 +79,7 @@ const getPasswordRequirements = async () => { }; const login = async () => { - await userStore.login(userStore.name, formData.value.newPassword); + await userStore.login(userStore.user.name, formData.value.newPassword); }; const onPasswordChanged = async () => { @@ -112,40 +116,40 @@ onMounted(async () => { v-model="formData.oldPassword" :type="!showOldPwd ? 'password' : 'text'" :label="t('oldPassword')" - > + > - + + + + > + > -