schon/storefront/app/composables/user/useUserBaseData.ts
Alexandr SaVBaD Waltz 8d7685ef67 feat(notification): integrate global notification plugin using ElNotification
Added a global `notify` method via Nuxt plugin to replace `useNotification`. Improved messaging structure by embedding progress bars and handled dynamic durations. Updated usage across composables and components for consistency.

- Replaced `useNotification` with `$notify` in all applicable files.
- Updated `app.config.ts` to support customizable notification positions.
- Refactored affected composables for simplified notification calls.
- Enhanced progress indicator display within notifications.

Breaking Changes:
`useNotification` is removed, requiring migration to the new `$notify` API.
2026-03-01 15:30:47 +03:00

48 lines
1.3 KiB
TypeScript

import { orderStatuses } from '@appConstants';
import { useOrderSync } from '@composables/orders';
import { useWishlistSync } from '@composables/wishlist';
import { getUserBaseData } from '@graphql/queries/combined/userBaseData';
import type { IUserBaseDataResponse } from '@types';
export function useUserBaseData() {
const wishlistStore = useWishlistStore();
const cartStore = useCartStore();
const promocodeStore = usePromocodeStore();
const { syncWishlist } = useWishlistSync();
const { syncOrder } = useOrderSync();
async function loadUserBaseData(userEmail: string) {
const { document, variables } = getUserBaseData({
userEmail,
status: orderStatuses.PENDING,
});
const { mutate, error } = useMutation<IUserBaseDataResponse>(document);
const result = await mutate(variables);
if (error.value) {
console.error('useUserBaseData error:', error.value);
}
const data = result?.data;
if (data?.wishlists.edges) {
wishlistStore.setWishlist(data.wishlists.edges[0].node);
await syncWishlist();
}
if (data?.orders.edges) {
cartStore.setCurrentOrders(data.orders.edges[0].node);
await syncOrder();
}
if (data?.promocodes.edges) {
promocodeStore.setPromocodes(data.promocodes.edges);
}
}
return {
loadUserBaseData
};
}