diff --git a/api/endpoints/orders/index.ts b/api/endpoints/orders/index.ts new file mode 100644 index 0000000..fd95e74 --- /dev/null +++ b/api/endpoints/orders/index.ts @@ -0,0 +1 @@ +export * from './postOrdersCreate' diff --git a/api/endpoints/orders/postOrdersCreate.ts b/api/endpoints/orders/postOrdersCreate.ts new file mode 100644 index 0000000..d39eef0 --- /dev/null +++ b/api/endpoints/orders/postOrdersCreate.ts @@ -0,0 +1,4 @@ +import api from '~/api/instance' + +export const postOrdersCreate = async (parent_id: number | undefined) => + await api.wc.v3OrdersCreate({ parent_id }) diff --git a/api/mutations/index.ts b/api/mutations/index.ts new file mode 100644 index 0000000..2801c31 --- /dev/null +++ b/api/mutations/index.ts @@ -0,0 +1 @@ +export * from './usePostOrdersCreate' diff --git a/api/mutations/usePostOrdersCreate.ts b/api/mutations/usePostOrdersCreate.ts new file mode 100644 index 0000000..a928b24 --- /dev/null +++ b/api/mutations/usePostOrdersCreate.ts @@ -0,0 +1,19 @@ +import type { MaybeRef } from 'vue' +import { useMutation, useQueryClient } from '@tanstack/vue-query' +import { unref } from 'vue' +import { postOrdersCreate } from '~/api/endpoints/orders' + +export const usePostOrdersCreate = () => { + const queryClient = useQueryClient() + + return useMutation({ + mutationFn: (params: { parent_id: MaybeRef }) => + postOrdersCreate(unref(params.parent_id)), + + onSuccess: (data, variables) => { + queryClient.invalidateQueries({ + queryKey: ['post-orders-create', unref(variables.parent_id)], + }) + }, + }) +} diff --git a/assets/scss/utils.scss b/assets/scss/utils.scss index 3485f21..aec3f45 100644 --- a/assets/scss/utils.scss +++ b/assets/scss/utils.scss @@ -141,4 +141,8 @@ $indents: 0 2 4 5 6 8 10 12 15 16 18 20 24 25 28 30 32 36 40 48 50 52 60 64; .text-align-center { text-align: center !important; } .text-align-left { text-align: left !important; } -.text-align-right { text-align: right !important; } \ No newline at end of file +.text-align-right { text-align: right !important; } + +.cursor-pointer { cursor: pointer !important; } +.cursor-not-allowed { cursor: not-allowed !important; } +.cursor-progress { cursor: progress !important; } \ No newline at end of file diff --git a/components/ProductDescription.vue b/components/ProductDescription.vue index 07aabd0..d72e94b 100644 --- a/components/ProductDescription.vue +++ b/components/ProductDescription.vue @@ -34,7 +34,13 @@ - + @@ -45,11 +51,12 @@ import ProductVariations from '~/components/ProductVariations.vue' import { useCurrentProduct, useProduct } from '~/composables' const { t } = useI18n() +const { addToCart } = useCart() const { productsData, colors, getAttribute } = useProduct() const { currentVariant, currentColor, currentMaterial } = useCurrentProduct() -const currentSize = ref(0) +const currentSize = ref(undefined) const items = computed(() => [ { @@ -78,6 +85,10 @@ const items = computed(() => [ content: 'Возврат в течение 14 дней\nОбмен размера в течение 7 дней', }, ]) + +function addToCartBtn() { + addToCart(currentSize?.value?.id) +}