Merge manager tools into main cabinet
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useMutation, useQuery } from '@vue/apollo-composable';
|
||||
import { useQuery } from '@vue/apollo-composable';
|
||||
import OrderStatusBadge from '~/components/orders/OrderStatusBadge.vue';
|
||||
import {
|
||||
ClientReviewOrderDocument,
|
||||
MyOrdersDocument,
|
||||
type MyOrdersQuery,
|
||||
} from '~/composables/graphql/generated';
|
||||
@@ -10,30 +9,12 @@ import {
|
||||
type OrderItem = MyOrdersQuery['myOrders'][number];
|
||||
|
||||
const allOrders = useQuery(MyOrdersDocument);
|
||||
const reviewOrder = useMutation(ClientReviewOrderDocument);
|
||||
const actionError = ref('');
|
||||
const search = ref('');
|
||||
const statusFilter = ref<'ALL' | 'WAITING' | 'ACTIVE' | 'CLOSED'>('ALL');
|
||||
|
||||
const ACTIVE_STATUSES = new Set(['NEW', 'MANAGER_PROCESSING', 'WAITING_DOUBLE_CONFIRM', 'CONFIRMED', 'IN_PROGRESS']);
|
||||
const CLOSED_STATUSES = new Set(['COMPLETED', 'CLIENT_REJECTED', 'MANAGER_REJECTED', 'MANAGER_BLOCKED']);
|
||||
|
||||
reviewOrder.onError((error) => {
|
||||
actionError.value = error.message;
|
||||
});
|
||||
|
||||
async function approve(orderId: string) {
|
||||
actionError.value = '';
|
||||
await reviewOrder.mutate({ orderId, decision: 'APPROVE' });
|
||||
await allOrders.refetch();
|
||||
}
|
||||
|
||||
async function reject(orderId: string) {
|
||||
actionError.value = '';
|
||||
await reviewOrder.mutate({ orderId, decision: 'REJECT' });
|
||||
await allOrders.refetch();
|
||||
}
|
||||
|
||||
function matchesFilter(order: OrderItem) {
|
||||
if (statusFilter.value === 'ALL') {
|
||||
return true;
|
||||
@@ -69,8 +50,6 @@ const filteredOrders = computed(() => {
|
||||
<section class="space-y-6">
|
||||
<h1 class="text-3xl font-extrabold text-[#0f2f20]">Заказы</h1>
|
||||
|
||||
<div v-if="actionError" class="alert alert-error">{{ actionError }}</div>
|
||||
|
||||
<div class="surface-card rounded-3xl p-4 md:p-5">
|
||||
<div class="grid gap-3 md:grid-cols-[1fr_auto]">
|
||||
<label class="form-control">
|
||||
@@ -136,15 +115,6 @@ const filteredOrders = computed(() => {
|
||||
<div class="mt-3 rounded-xl border border-[#d6ebde] bg-white/75 px-3 py-2 text-sm text-[#214735]">
|
||||
Адрес доставки: {{ order.deliveryAddress || 'адрес не был выбран' }}
|
||||
</div>
|
||||
|
||||
<div v-if="order.status === 'WAITING_DOUBLE_CONFIRM'" class="mt-4 flex flex-wrap gap-2">
|
||||
<button class="btn btn-sm border-0 bg-[#139957] text-white hover:bg-[#0d854a]" @click="approve(order.id)">
|
||||
Подтвердить
|
||||
</button>
|
||||
<button class="btn btn-sm border-0 bg-[#d32422] text-white hover:bg-[#b31f1d]" @click="reject(order.id)">
|
||||
Отклонить
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user