Refactored multiple files for code styling consistency, using proper indentation and spacing to align with team standards. Improved readability and maintainability across composables, Apollo plugin, and localization files. Enhancements: - Standardized import and function indentation across all composables. - Updated `biome.json` schema to the latest version (v2.4.4) for tool compatibility. - Organized code blocks in Apollo plugin for better understandability. No functional changes introduced—this is a non-breaking, code refinement commit.
46 lines
1.2 KiB
TypeScript
46 lines
1.2 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 async function useUserBaseData(userEmail: string) {
|
|
const wishlistStore = useWishlistStore();
|
|
const cartStore = useCartStore();
|
|
const promocodeStore = usePromocodeStore();
|
|
|
|
const { syncWishlist } = useWishlistSync();
|
|
const { syncOrder } = useOrderSync();
|
|
|
|
const { document, variables } = getUserBaseData({
|
|
userEmail,
|
|
status: orderStatuses.PENDING,
|
|
});
|
|
|
|
const { mutate, error } = useMutation<IUserBaseDataResponse>(document);
|
|
|
|
const result = await mutate(variables);
|
|
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);
|
|
}
|
|
|
|
watch(error, (err) => {
|
|
if (err) {
|
|
console.error('useUserBaseData error:', err);
|
|
}
|
|
});
|
|
|
|
return {};
|
|
}
|