vulneribilty fixed
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Clock, XCircle, ReceiptText } from 'lucide-react';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { apiRequest } from '@/shared/request/apiRequest';
|
||||
import { links } from '@/shared/request/links';
|
||||
import PaymentStatus from '@/widgets/detail/paidStatus';
|
||||
@@ -36,6 +37,7 @@ function formatPrice(price: string) {
|
||||
// ─── Component ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export function PaymentsTable() {
|
||||
const t = useTranslations('Cabinet');
|
||||
const [isPaymentOpen, setIsPaymentOpen] = useState(false);
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ['pay_history'],
|
||||
@@ -50,9 +52,7 @@ export function PaymentsTable() {
|
||||
mutationFn: ({ order_id }: { order_id: number }) =>
|
||||
apiRequest<{ payment_link: string }>('POST', links.payment(order_id)),
|
||||
onSuccess: (res) => {
|
||||
console.log('payment res: ', res);
|
||||
window.open(res.data.payment_link, '_self');
|
||||
//route.push(`/${document_id}`);
|
||||
setIsPaymentOpen(false);
|
||||
},
|
||||
onError: (err) => {
|
||||
@@ -75,11 +75,9 @@ export function PaymentsTable() {
|
||||
<>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-slate-900">
|
||||
To'lovlar tarixi
|
||||
</h2>
|
||||
<h2 className="text-xl font-bold text-slate-900">{t('payments')}</h2>
|
||||
<p className="text-sm text-slate-500 mt-0.5">
|
||||
{data?.length ?? 0} ta to'lov
|
||||
{t('paymentsCount', { count: data?.length ?? 0 })}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -87,28 +85,33 @@ export function PaymentsTable() {
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center py-16 gap-3 text-slate-400">
|
||||
<Clock size={20} className="animate-spin" />
|
||||
<span className="text-sm">Yuklanmoqda...</span>
|
||||
<span className="text-sm">{t('loading')}</span>
|
||||
</div>
|
||||
) : !data || data.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center py-16 gap-3 text-slate-400">
|
||||
<ReceiptText size={40} strokeWidth={1.5} />
|
||||
<p className="text-sm">To'lovlar tarixi mavjud emas</p>
|
||||
<p className="text-sm">{t('noPayments')}</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="bg-slate-50 border-b border-slate-100">
|
||||
{['#', 'Xizmat', 'Summa', 'Chegirma', 'Sana', 'Holat'].map(
|
||||
(h) => (
|
||||
<th
|
||||
key={h}
|
||||
className="text-left px-5 py-3 text-[11px] font-semibold text-slate-400 uppercase tracking-wider whitespace-nowrap"
|
||||
>
|
||||
{h}
|
||||
</th>
|
||||
),
|
||||
)}
|
||||
{[
|
||||
t('tableNum'),
|
||||
t('service'),
|
||||
t('amount'),
|
||||
t('discount'),
|
||||
t('date'),
|
||||
t('status'),
|
||||
].map((h) => (
|
||||
<th
|
||||
key={h}
|
||||
className="text-left px-5 py-3 text-[11px] font-semibold text-slate-400 uppercase tracking-wider whitespace-nowrap"
|
||||
>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-slate-50">
|
||||
@@ -155,7 +158,7 @@ export function PaymentsTable() {
|
||||
) : (
|
||||
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium text-slate-400 bg-slate-50">
|
||||
<XCircle size={12} />
|
||||
Noma'lum
|
||||
{t('unknown')}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user