vulneribilty fixed

This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-04-09 12:00:06 +05:00
parent dfb8d3bdbc
commit 73158a1972
26 changed files with 553 additions and 175 deletions

View File

@@ -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&apos;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&apos;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&apos;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&apos;lum
{t('unknown')}
</span>
)}
</td>