From 7dc0f59ffb2f8770784b9225b6a688d1b18c48d5 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev Date: Sat, 4 Apr 2026 11:05:31 +0700 Subject: [PATCH] Simplify order detail layout --- app/composables/useOrderDetailPresentation.ts | 9 ++ app/pages/client-orders/[id].vue | 102 ++++++------------ app/pages/orders/[id].vue | 15 ++- 3 files changed, 49 insertions(+), 77 deletions(-) create mode 100644 app/composables/useOrderDetailPresentation.ts diff --git a/app/composables/useOrderDetailPresentation.ts b/app/composables/useOrderDetailPresentation.ts new file mode 100644 index 0000000..c82c97f --- /dev/null +++ b/app/composables/useOrderDetailPresentation.ts @@ -0,0 +1,9 @@ +export function orderLineStateText(totalPrice?: number | null) { + return totalPrice == null + ? 'Цена уточняется менеджером' + : 'Цена согласована менеджером'; +} + +export function orderDeliveryStateText(deliveryTerms?: string | null) { + return deliveryTerms?.trim() || 'Доставка уточняется менеджером'; +} diff --git a/app/pages/client-orders/[id].vue b/app/pages/client-orders/[id].vue index d29c6d7..0663526 100644 --- a/app/pages/client-orders/[id].vue +++ b/app/pages/client-orders/[id].vue @@ -5,9 +5,12 @@ import { CompleteOrderDocument, ManagerFinalizeOrderDocument, ManagerOrdersDocument, - ManagerSetOrderOfferDocument, StartOrderWorkDocument, } from '~/composables/graphql/generated'; +import { + orderDeliveryStateText, + orderLineStateText, +} from '~/composables/useOrderDetailPresentation'; definePageMeta({ middleware: ['manager-only'], @@ -18,7 +21,6 @@ const orderId = computed(() => String(route.params.id || '')); const ordersQuery = useQuery(ManagerOrdersDocument, { status: null }); -const setOfferMutation = useMutation(ManagerSetOrderOfferDocument); const finalizeMutation = useMutation(ManagerFinalizeOrderDocument); const blockMutation = useMutation(BlockOrderDocument); const startWorkMutation = useMutation(StartOrderWorkDocument); @@ -28,43 +30,10 @@ const currentOrder = computed(() => (ordersQuery.result.value?.managerOrders ?? []).find((item) => item.id === orderId.value), ); -const offerForm = reactive({ - deliveryTerms: '', - deliveryFee: 0, - totalPrice: 0, -}); - -watchEffect(() => { - if (!currentOrder.value) { - return; - } - - offerForm.deliveryTerms = currentOrder.value.deliveryTerms || 'Доставка 3-5 дней'; - offerForm.deliveryFee = Number(currentOrder.value.deliveryFee ?? 1000); - offerForm.totalPrice = Number(currentOrder.value.totalPrice ?? 12500); -}); - async function refetchOrder() { await ordersQuery.refetch({ status: null }); } -async function publishOffer() { - if (!currentOrder.value) { - return; - } - - await setOfferMutation.mutate({ - input: { - orderId: currentOrder.value.id, - deliveryTerms: offerForm.deliveryTerms, - deliveryFee: Number(offerForm.deliveryFee), - totalPrice: Number(offerForm.totalPrice), - }, - }); - - await refetchOrder(); -} - async function approveOrder() { if (!currentOrder.value) { return; @@ -134,49 +103,38 @@ async function completeOrder() {

{{ currentOrder.code }}

-
-
- +
+ -
-

Состав заказа

-
    -
  • - {{ item.productName }} × {{ item.quantity }} -
  • -
-
+
+

Состав заказа

+
    +
  • +

    {{ item.productName }} × {{ item.quantity }}

    +

    {{ orderLineStateText(currentOrder.totalPrice) }}

    +
  • +
+
-
-

Доставка

-
-
- Адрес: {{ currentOrder.deliveryAddress || 'не выбран' }} -
-
- Условия: {{ currentOrder.deliveryTerms || 'еще не указаны' }} -
+
+

Доставка

+
+
+ Адрес: {{ currentOrder.deliveryAddress || 'Адрес пока не указан' }} +
+
+ {{ orderDeliveryStateText(currentOrder.deliveryTerms) }}
-
-
-

Оффер

-
- - - - -
-
- -
-

Действия

-
+
+
+

Действия менеджера

+
diff --git a/app/pages/orders/[id].vue b/app/pages/orders/[id].vue index 261e697..16e1f3a 100644 --- a/app/pages/orders/[id].vue +++ b/app/pages/orders/[id].vue @@ -4,6 +4,10 @@ import { MyOrdersDocument, type MyOrdersQuery, } from '~/composables/graphql/generated'; +import { + orderDeliveryStateText, + orderLineStateText, +} from '~/composables/useOrderDetailPresentation'; type OrderItem = MyOrdersQuery['myOrders'][number]; @@ -46,21 +50,22 @@ const currentOrder = computed(() =>
  • - {{ item.productName }} × {{ item.quantity }} +

    {{ item.productName }} × {{ item.quantity }}

    +

    {{ orderLineStateText(currentOrder.totalPrice) }}

  • Доставка

    -
    +
    - Адрес: {{ currentOrder.deliveryAddress || 'не выбран' }} + Адрес: {{ currentOrder.deliveryAddress || 'Адрес пока не указан' }}
    - Условия: {{ currentOrder.deliveryTerms || 'еще не указаны' }} + {{ orderDeliveryStateText(currentOrder.deliveryTerms) }}