Improve order detail UX, confirm check actions, and fix notification deep links.
Normalize inbox /orders/:id links, open related admin pages on click, and keep Jalali dates consistent. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,8 +5,9 @@ import AdminIcon from '@/components/icons/AdminIcon.vue'
|
||||
import StatusBadge from '@/components/ui/StatusBadge.vue'
|
||||
import { checksApi, mapAdminOrder, ordersApi, type ApiOrder } from '@/services/api'
|
||||
import { ApiError } from '@/services/http'
|
||||
import { formatCurrency } from '@/utils/format'
|
||||
import { formatCurrency, formatDate } from '@/utils/format'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import { confirm } from '@/composables/useConfirm'
|
||||
import type { Check } from '@/types'
|
||||
|
||||
const route = useRoute()
|
||||
@@ -55,6 +56,28 @@ function checkBadgeStatus(status: Check['status']) {
|
||||
}
|
||||
|
||||
async function updateCheckStatus(check: Check, status: Check['status']) {
|
||||
if (status !== 'approved' && status !== 'rejected') return
|
||||
|
||||
const amountLabel = formatCurrency(check.amount)
|
||||
const ok = await confirm(
|
||||
status === 'approved'
|
||||
? {
|
||||
title: 'تأیید چک',
|
||||
message: `آیا از تأیید چک ردیف ${check.row} به مبلغ ${amountLabel} مطمئن هستید؟`,
|
||||
tone: 'primary',
|
||||
confirmLabel: 'تأیید چک',
|
||||
cancelLabel: 'انصراف',
|
||||
}
|
||||
: {
|
||||
title: 'رد چک',
|
||||
message: `آیا از رد چک ردیف ${check.row} به مبلغ ${amountLabel} مطمئن هستید؟`,
|
||||
tone: 'danger',
|
||||
confirmLabel: 'رد چک',
|
||||
cancelLabel: 'انصراف',
|
||||
},
|
||||
)
|
||||
if (!ok) return
|
||||
|
||||
busyId.value = check.id
|
||||
try {
|
||||
const updated = await checksApi.updateStatus(check.id, { status })
|
||||
@@ -70,9 +93,34 @@ async function updateCheckStatus(check: Check, status: Check['status']) {
|
||||
|
||||
async function approveAll() {
|
||||
const pending = orderChecks.value.filter((c) => c.status === 'pending_review')
|
||||
for (const check of pending) {
|
||||
await updateCheckStatus(check, 'approved')
|
||||
if (!pending.length) {
|
||||
toast.error('چکی برای تأیید وجود ندارد.')
|
||||
return
|
||||
}
|
||||
|
||||
const ok = await confirm({
|
||||
title: 'تأیید همه چکها',
|
||||
message: `آیا از تأیید ${pending.length} چک در انتظار بررسی مطمئن هستید؟`,
|
||||
tone: 'primary',
|
||||
confirmLabel: 'تأیید همه',
|
||||
cancelLabel: 'انصراف',
|
||||
})
|
||||
if (!ok) return
|
||||
|
||||
for (const check of pending) {
|
||||
busyId.value = check.id
|
||||
try {
|
||||
const updated = await checksApi.updateStatus(check.id, { status: 'approved' })
|
||||
const index = orderChecks.value.findIndex((c) => c.id === check.id)
|
||||
if (index !== -1) orderChecks.value[index] = updated
|
||||
} catch (err) {
|
||||
toast.error(err instanceof ApiError ? err.message : 'بهروزرسانی وضعیت چک انجام نشد.')
|
||||
busyId.value = null
|
||||
return
|
||||
}
|
||||
}
|
||||
busyId.value = null
|
||||
toast.success('همه چکهای در انتظار تأیید شدند.')
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -129,7 +177,7 @@ async function approveAll() {
|
||||
{{ order?.checkRassDays ?? '—' }} روز
|
||||
</p>
|
||||
<p v-if="order?.checkRassDate" class="checks-page__rass-date">
|
||||
تاریخ راس: {{ order.checkRassDate.slice(0, 10) }}
|
||||
تاریخ راس: {{ formatDate(order.checkRassDate) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="admin-summary-item">
|
||||
@@ -164,7 +212,7 @@ async function approveAll() {
|
||||
<td>{{ formatCurrency(check.amount) }}</td>
|
||||
<td>{{ check.bankName }}</td>
|
||||
<td>{{ check.sayadId }}</td>
|
||||
<td>{{ check.dueDate.slice(0, 10) }}</td>
|
||||
<td>{{ formatDate(check.dueDate) }}</td>
|
||||
<td><StatusBadge :status="checkBadgeStatus(check.status)" /></td>
|
||||
<td>
|
||||
<div v-if="check.status === 'pending_review'" class="admin-action-group">
|
||||
@@ -201,7 +249,7 @@ async function approveAll() {
|
||||
</div>
|
||||
<div class="admin-card-item__meta">
|
||||
<span>بانک {{ check.bankName }}</span>
|
||||
<span>سررسید {{ check.dueDate.slice(0, 10) }}</span>
|
||||
<span>سررسید {{ formatDate(check.dueDate) }}</span>
|
||||
<span dir="ltr">{{ check.sayadId }}</span>
|
||||
</div>
|
||||
<div v-if="check.status === 'pending_review'" class="admin-card-item__actions">
|
||||
|
||||
Reference in New Issue
Block a user