feat: show order

This commit is contained in:
Sergey Krylov 2025-01-28 06:58:50 +03:00
parent dd0bf57f6b
commit d8492ae873
2 changed files with 15 additions and 7 deletions

View File

@ -120,7 +120,6 @@
}) })
} finally { } finally {
isCreatingOrder.value = false; isCreatingOrder.value = false;
showDrawer.value = false;
} }
} }

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import DrawerHead from './DrawerHead.vue' import DrawerHead from './DrawerHead.vue'
import CartItemList from '@/components/CartItemList.vue' import CartItemList from '@/components/CartItemList.vue'
import { inject, onMounted, onUnmounted } from 'vue' import { inject, onMounted, onUnmounted, ref } from 'vue'
import { decimalFormatter } from '@/utils/helpers.js' import { decimalFormatter } from '@/utils/helpers.js'
import InfoBlock from '@/components/InfoBlock.vue' import InfoBlock from '@/components/InfoBlock.vue'
@ -12,6 +12,8 @@
isCreatingOrder, isCreatingOrder,
} = inject('cart') } = inject('cart')
const orderDetails = ref({});
defineProps({ defineProps({
cart: { cart: {
type: Array, type: Array,
@ -26,6 +28,10 @@
onUnmounted(() => { onUnmounted(() => {
document.body.style.overflow = 'unset' document.body.style.overflow = 'unset'
}) })
const onClickHandler = async () => {
orderDetails.value = await createOrder();
}
</script> </script>
<template> <template>
@ -58,7 +64,7 @@
</div> </div>
<button <button
@click="createOrder" @click="onClickHandler"
class="mt-5 bg-lime-500 w-full rounded-xl py-3 text-white transition disabled:bg-slate-300 hover:bg-lime-600 active:bg-lime-700" class="mt-5 bg-lime-500 w-full rounded-xl py-3 text-white transition disabled:bg-slate-300 hover:bg-lime-600 active:bg-lime-700"
:disabled="isCreatingOrder" :disabled="isCreatingOrder"
> >
@ -67,15 +73,18 @@
</div> </div>
</div> </div>
<InfoBlock
v-else-if="orderDetails.id"
title="Заказ оформлен"
:description="`Ваш заказ №${orderDetails.id} скоро будет передан курьерской службе`"
image-url="/order-success-icon.png"
/>
<InfoBlock <InfoBlock
v-else v-else
title="Корзина пуста" title="Корзина пуста"
description="Добавьте хотябы одну пару кроссовок, чтобы сделать заказ" description="Добавьте хотябы одну пару кроссовок, чтобы сделать заказ"
image-url="/package-icon.png" image-url="/package-icon.png"
/> />
<!-- <h2 v-else class="text-lg font-bold text-center mt-10 text-slate-500">-->
<!-- В корзине нет товаров-->
<!-- </h2>-->
</div> </div>
</template> </template>