From 68fda9902f50804beaa5de99193aea04e3e12149 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Fri, 18 Apr 2025 19:51:39 +0330 Subject: [PATCH] updated selecting address logic loading --- frontend/pages/cart/delivery.vue | 103 ++++++++----------------------- 1 file changed, 27 insertions(+), 76 deletions(-) diff --git a/frontend/pages/cart/delivery.vue b/frontend/pages/cart/delivery.vue index f3cafd0..7174721 100644 --- a/frontend/pages/cart/delivery.vue +++ b/frontend/pages/cart/delivery.vue @@ -2,9 +2,8 @@ // imports import useGetAllAddress from "~/composables/api/account/useGetAllAddress"; -import useSetOrderAddress from "~/composables/api/orders/useSetOrderAddress"; import { useToast } from "~/composables/global/useToast"; -import { QUERY_KEYS } from "~/constants"; +import useGetCartOrders from "~/composables/api/orders/useGetCartOrders"; // meta @@ -29,10 +28,9 @@ type DeliveryData = { // queries -const { data: addresses, isLoading: addressesIsLoading } = useGetAllAddress(); +const { data: cart, isLoading: cartIsLoading } = useGetCartOrders(); -const { mutateAsync: setOrderAddress, isPending: setOrderAddressIsPending } = - useSetOrderAddress(); +const { data: addresses, isLoading: addressesIsLoading } = useGetAllAddress(); // computed @@ -53,41 +51,6 @@ const deliveryData = ref({ tipax: false, }, }); - -// methods - -const handleSelectAddress = (address: Address) => { - deliveryData.value.address = { ...address }; -}; - -// watch - -whenever( - () => deliveryData.value.address, - (nv) => { - setOrderAddress( - { address_id: nv.id! }, - { - onSettled: () => { - queryClient.invalidateQueries({ - queryKey: [QUERY_KEYS.addresses], - }); - }, - onError: () => { - addToast({ - message: "در انتخاب آدرس خطایی رخ داد", - options: { - description: "لطفا مجدد تلاش کنید", - }, - }); - }, - } - ); - }, - { - deep: true, - } -);