diff --git a/src/api/card.ts b/src/api/card.ts index b5490d8..eba20a2 100644 --- a/src/api/card.ts +++ b/src/api/card.ts @@ -1,11 +1,6 @@ import useAxios from "@/utils/useAxios"; -import type {PInventory, Product} from "@/models/products"; -import type {PWallet, Wallet} from '@/models/wallet' import type {Order} from "@/models/order"; -import {useUserStore} from "@/store/userStore"; - -const userStore = useUserStore() export const checkoutCart = async (orders: Order[]): Promise => { return await useAxios.post(`/customer/cart/checkout`, orders) -} \ No newline at end of file +} diff --git a/src/api/order.ts b/src/api/order.ts index 3c3913e..8575fbf 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -5,10 +5,9 @@ import type {Ref, UnwrapRef} from "vue"; import type {Transaction} from "@/models/transaction"; import {useUserStore} from "@/store/userStore"; -const userStore = useUserStore() - function customerOrderPrefix() { - return `/customer${!userStore.isSingle ? '' : '/single'}` + // lazy: این ماژول ممکن است قبل از app.use(pinia) لود شود + return `/customer${!useUserStore().isSingle ? '' : '/single'}` } export const createOrder = async (obj: Order): Promise => { diff --git a/src/app/createApp.ts b/src/app/createApp.ts index 90d7ada..819738d 100644 --- a/src/app/createApp.ts +++ b/src/app/createApp.ts @@ -1,14 +1,15 @@ import { createApp } from 'vue' -import { createPinia } from 'pinia' +import { createPinia, setActivePinia } from 'pinia' import VueLazyLoad from 'vue3-lazyload' import VueApexCharts from 'vue3-apexcharts' import App from '@/App.vue' import router from '@/router' export function createVueApp() { - const app = createApp(App) const pinia = createPinia() + setActivePinia(pinia) + const app = createApp(App) app.use(pinia) app.use(VueLazyLoad, {}) app.use(router) diff --git a/src/utils/inputRules.ts b/src/utils/inputRules.ts index ee32f33..2ef5808 100644 --- a/src/utils/inputRules.ts +++ b/src/utils/inputRules.ts @@ -144,7 +144,6 @@ export const justNumber = () => { message: 'لطفا اطلاعات را به صورت عدد و نقطه وارد کنید' } } -const walletCash = useWalletStore() let priceP = 0 let methodP = 'cash' let amountP = 0 @@ -152,6 +151,7 @@ let isBuyP = true let NumP = 0 let gatewayP = false const checkNumber = async (_rule: Rule, value: number) => { + const walletCash = useWalletStore() if (!value) { return Promise.reject('تعداد محصول را مشخص کنید') }