From c977740a5d4163c701730bdf95e8710c1f910bd7 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Fri, 18 Apr 2025 19:49:01 +0330 Subject: [PATCH 01/17] updated tpast porsition --- frontend/app.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/app.vue b/frontend/app.vue index b55ac18..da627ed 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -5,8 +5,7 @@ import { VueQueryDevtools } from "@tanstack/vue-query-devtools"; // state -const { $updateAvailable: updateAvailable, $handleUpdate: handleUpdate } = - useNuxtApp(); +const { $updateAvailable: updateAvailable, $handleUpdate: handleUpdate } = useNuxtApp(); const closeModal = () => { updateAvailable.value = false; @@ -16,7 +15,7 @@ const closeModal = () => { From f851df69c6256b7cea78b39476ec5bdf4da6258d Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Fri, 18 Apr 2025 19:49:13 +0330 Subject: [PATCH 02/17] updated toast animation --- frontend/assets/css/tailwind.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/assets/css/tailwind.css b/frontend/assets/css/tailwind.css index c647adb..f071dc5 100644 --- a/frontend/assets/css/tailwind.css +++ b/frontend/assets/css/tailwind.css @@ -215,22 +215,22 @@ @keyframes toastSlideIn { from { opacity: 0; - transform: translateX(calc(100% + var(--viewport-padding))); + transform: translateY(calc(100% + var(--viewport-padding))); } to { opacity: 1; - transform: translateX(0); + transform: translateY(0); } } @keyframes toastSlideOut { from { opacity: 1; - transform: translateX(var(--reka-toast-swipe-end-x)); + transform: translateY(var(--reka-toast-swipe-end-x)); } to { opacity: 0; - transform: translateX(calc(100% + var(--viewport-padding))); + transform: translateY(calc(100% + var(--viewport-padding))); } } @@ -281,6 +281,10 @@ /* CONTAINER */ +* { + scroll-behavior: smooth !important; +} + @utility container { @apply mx-auto px-[var(--app-container-padding)] w-full max-sm:max-w-[var(--breakpoint-xs)] max-md:max-w-[var(--breakpoint-sm)] max-lg:max-w-[var(--breakpoint-md)] max-xl:max-w-[var(--breakpoint-lg)] max-w-[var(--breakpoint-2xl)]; } From 90c3f6dbec45eba623b44acf32693b94166d98f8 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Fri, 18 Apr 2025 19:49:27 +0330 Subject: [PATCH 03/17] updated selecting address logic --- .../components/cart/delivery/AddressItem.vue | 78 +++++++++++++------ 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/frontend/components/cart/delivery/AddressItem.vue b/frontend/components/cart/delivery/AddressItem.vue index 7151960..8f28869 100644 --- a/frontend/components/cart/delivery/AddressItem.vue +++ b/frontend/components/cart/delivery/AddressItem.vue @@ -2,6 +2,7 @@ // imports import useDeleteAddress from "~/composables/api/account/useDeleteAddress"; +import useSetOrderAddress from "~/composables/api/orders/useSetOrderAddress"; import { useToast } from "~/composables/global/useToast"; import { QUERY_KEYS } from "~/constants"; @@ -15,13 +16,11 @@ type Props = { // props -withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { selectable: true, }); -// emit - -const emit = defineEmits(["select"]); +const { address } = toRefs(props); // state @@ -31,19 +30,48 @@ const { addToast } = useToast(); // queries -const { mutateAsync: deleteAddress, isPending: deleteAddressIsPending } = - useDeleteAddress(); +const { mutateAsync: deleteAddress, isPending: deleteAddressIsPending } = useDeleteAddress(); + +const { mutateAsync: setOrderAddress, isPending: setOrderAddressIsPending } = useSetOrderAddress(); // methods +const handleSelectAddress = () => { + setOrderAddress( + { address_id: address.value?.id! }, + { + onSettled: () => { + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.cart], + }); + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.addresses], + }); + }, + onError: () => { + addToast({ + message: "در انتخاب آدرس خطایی رخ داد", + options: { + description: "لطفا مجدد تلاش کنید", + }, + }); + }, + } + ); +}; + const handleDeleteAddress = (id: number) => { deleteAddress( { id }, { onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.cart], + }); queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.addresses], }); + addToast({ message: "آدرس با موفقیت حذف شد", options: { @@ -66,29 +94,30 @@ const handleDeleteAddress = (id: number) => {