diff --git a/src/shared/config/i18n/messages/en.json b/src/shared/config/i18n/messages/en.json index 74e5772..8b03f3a 100644 --- a/src/shared/config/i18n/messages/en.json +++ b/src/shared/config/i18n/messages/en.json @@ -61,6 +61,8 @@ "date": "Date", "amount": "Amount", "result": "Result", + "fileName":"File name", + "count":"N_", "actions": "", "state": "Payment status", "emptyMessage": "No plagiarism checks found.", diff --git a/src/shared/config/i18n/messages/ru.json b/src/shared/config/i18n/messages/ru.json index 08d56a1..a18b0ba 100644 --- a/src/shared/config/i18n/messages/ru.json +++ b/src/shared/config/i18n/messages/ru.json @@ -61,6 +61,7 @@ "date": "Дата", "amount": "Сумма", "result": "Результат", + "count":"H_", "actions": "", "state": "Статус оплаты", "emptyMessage": "Проверки на плагиат не найдены.", diff --git a/src/shared/config/i18n/messages/uz.d.json.ts b/src/shared/config/i18n/messages/uz.d.json.ts index 1b6f044..3ce275f 100644 --- a/src/shared/config/i18n/messages/uz.d.json.ts +++ b/src/shared/config/i18n/messages/uz.d.json.ts @@ -61,6 +61,8 @@ declare const messages: { description: 'Siz tomonidan yuborilgan barcha plagiat tekshiruvlari'; sender: 'Yuboruvchi'; file: 'Fayl'; + fileName: 'Fayl nomi'; + count: 'N_'; date: 'Sana'; amount: 'Summa'; result: 'Natija'; diff --git a/src/shared/config/i18n/messages/uz.json b/src/shared/config/i18n/messages/uz.json index b9c9baa..e096022 100644 --- a/src/shared/config/i18n/messages/uz.json +++ b/src/shared/config/i18n/messages/uz.json @@ -58,6 +58,8 @@ "description": "Siz tomonidan yuborilgan barcha plagiat tekshiruvlari", "sender": "Yuboruvchi", "file": "Fayl", + "fileName":"Fayl nomi", + "count":"N_", "date": "Sana", "amount": "Summa", "result": "Natija", diff --git a/src/widgets/cabinet/ui/Sidebar.tsx b/src/widgets/cabinet/ui/Sidebar.tsx index 019ffd0..b10a062 100644 --- a/src/widgets/cabinet/ui/Sidebar.tsx +++ b/src/widgets/cabinet/ui/Sidebar.tsx @@ -134,13 +134,6 @@ export const Sidebar: React.FC = ({ ); })} - - {/* Footer */} -
-

- © 2026 Plagat.uz -

-
); diff --git a/src/widgets/cabinet/ui/index.tsx b/src/widgets/cabinet/ui/index.tsx index e8f85af..ff62ab3 100644 --- a/src/widgets/cabinet/ui/index.tsx +++ b/src/widgets/cabinet/ui/index.tsx @@ -6,13 +6,7 @@ import { Sidebar } from './Sidebar'; import { CabinetNav } from './CabinetNav'; import { Dashboard } from './dashboard'; import { useCabinet } from '../lib/hooks/useCabinet'; -import { - MOCK_USER, - MOCK_STATS, - MOCK_PLAGIAT, - MOCK_SI, - MOCK_PAYMENTS, -} from '../lib/mock'; +import { MOCK_USER, MOCK_STATS, MOCK_SI, MOCK_PAYMENTS } from '../lib/mock'; import type { CabinetSection } from '../lib/types'; // ─── Lazy sections (separate JS chunks) ─────────────────────────────────────── @@ -53,7 +47,7 @@ function SectionContent({ section }: { section: CabinetSection }) { case 'dashboard': return ; case 'plagiat': - return ; + return ; case 'si': return ; case 'payments': diff --git a/src/widgets/cabinet/ui/tables/PlagiatTable.tsx b/src/widgets/cabinet/ui/tables/PlagiatTable.tsx index 787e669..512ab46 100644 --- a/src/widgets/cabinet/ui/tables/PlagiatTable.tsx +++ b/src/widgets/cabinet/ui/tables/PlagiatTable.tsx @@ -1,128 +1,6 @@ import React from 'react'; -import { Download, Clock, CheckCircle, XCircle } from 'lucide-react'; -import type { PlagiatCheck } from '../../lib/types'; +import { HistoryPage } from '@/widgets/history'; -// ─── Helpers ─────────────────────────────────────────────────────────────────── - -const STATUS_MAP = { - completed: { - label: 'Yakunlandi', - icon: CheckCircle, - cls: 'text-emerald-600 bg-emerald-50', - }, - pending: { - label: 'Kutilmoqda', - icon: Clock, - cls: 'text-amber-600 bg-amber-50', - }, - failed: { label: 'Xato', icon: XCircle, cls: 'text-red-600 bg-red-50' }, -} as const; - -const PercentBadge: React.FC<{ value: number }> = ({ value }) => { - const cls = - value < 15 - ? 'text-emerald-700 bg-emerald-50' - : value < 30 - ? 'text-amber-700 bg-amber-50' - : 'text-red-700 bg-red-50'; - return ( - - {value}% - - ); +export const PlagiatTable = () => { + return ; }; - -// ─── Component ───────────────────────────────────────────────────────────────── - -interface PlagiatTableProps { - data: PlagiatCheck[]; -} - -export const PlagiatTable: React.FC = ({ data }) => ( -
-
-

Plagiat tekshiruvlar

-

- {data.length} ta tekshiruv -

-
- -
-
- - - - {['#', 'Fayl', 'Turi', '%', 'Sana', 'Holat', 'Yuklab olish'].map( - (h) => ( - - ), - )} - - - - {data.map((row) => { - const s = STATUS_MAP[row.status]; - const Icon = s.icon; - return ( - - - - - - - - - - ); - })} - -
- {h} -
- {String(row.id).padStart(2, '0')} - - - {row.file} - - - {row.type} - - {row.status === 'pending' ? ( - - ) : ( - - )} - - {row.date} - - - - {s.label} - - - {row.downloadUrl ? ( - - - - ) : ( - - )} -
-
-
-
-); diff --git a/src/widgets/history/lib/constants.ts b/src/widgets/history/lib/constants.ts index 84657e3..09e8d82 100644 --- a/src/widgets/history/lib/constants.ts +++ b/src/widgets/history/lib/constants.ts @@ -3,8 +3,9 @@ import { CheckResult } from './types'; export const TABLE_COLUMNS = [ - { key: 'senderFullName', labelKey: 'sender' }, - { key: 'fileName', labelKey: 'file' }, + { key: 'id', labelKey: 'count' }, + { key: 'fileName', labelKey: 'fileName' }, + { key: 'file', labelKey: 'file' }, { key: 'date', labelKey: 'date' }, { key: 'state', labelKey: 'state' }, { key: 'actions', labelKey: 'actions' }, diff --git a/src/widgets/history/ui/historyTable.tsx b/src/widgets/history/ui/historyTable.tsx index c65b7ea..0ccaae8 100644 --- a/src/widgets/history/ui/historyTable.tsx +++ b/src/widgets/history/ui/historyTable.tsx @@ -72,7 +72,7 @@ const TableBody: React.FC = ({ return ( {items.map((item) => ( - + ))} ); diff --git a/src/widgets/history/ui/historyTableRow.tsx b/src/widgets/history/ui/historyTableRow.tsx index d698843..94b574c 100644 --- a/src/widgets/history/ui/historyTableRow.tsx +++ b/src/widgets/history/ui/historyTableRow.tsx @@ -1,158 +1,132 @@ 'use client'; -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { useTranslations } from 'next-intl'; +import { ArrowRight, Download } from 'lucide-react'; import { HistoryTableRowProps } from '../lib/types'; import { formatDate } from '../lib/utils'; import { useRouter } from '@/shared/config/i18n/navigation'; -import { useUserPlagiatStore } from '@/shared/zustand/user'; -import PaymentStatus from '@/widgets/detail/paidStatus'; import { useMutation } from '@tanstack/react-query'; import { apiRequest } from '@/shared/request/apiRequest'; import { links } from '@/shared/request/links'; import { toast } from 'react-toastify'; import { PaymentModal } from '@/features/modals/paymentModal/ui/Paymentmodal'; -export const HistoryTableRow: React.FC = ({ item }) => { +// ─── State badge ─────────────────────────────────────────────────────────────── + +const StateBadge: React.FC<{ state: 'paid' | 'unpaid' }> = ({ state }) => { + const isPaid = state === 'paid'; + return ( + + + {isPaid ? "To'langan" : "To'lanmagan"} + + ); +}; + +// ─── Row ─────────────────────────────────────────────────────────────────────── + +export const HistoryTableRow: React.FC< + HistoryTableRowProps & { index: number } +> = ({ item, index }) => { const router = useRouter(); - const t = useTranslations('HistoryPage'); - const tPay = useTranslations('Payment'); const tUnknown = useTranslations(); - const user = useUserPlagiatStore((state) => state.user); const [isPaymentOpen, setIsPaymentOpen] = useState(false); - const [localUser, setLocalUser] = useState<{ - id: number; - name: string; - surname: string; - } | null>(null); - - useEffect(() => { - const data = localStorage.getItem('user'); - - if (data) { - setLocalUser(JSON.parse(data)); - } else { - setLocalUser(null); - } - }, [user]); - - const userName = localUser - ? `${localUser.name} ${localUser.surname}` - : tUnknown('unknownUser'); const payment = useMutation({ - mutationKey: ['payload'], + mutationKey: ['payment', item.order_id], 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) => { - const message = - err instanceof Error ? err.message : 'An unexpected error occurred.'; - toast.error(message); + toast.error(err instanceof Error ? err.message : 'Xatolik yuz berdi'); setIsPaymentOpen(false); }, }); - const handleSubmit = ({ document_id }: { document_id: number }) => { - payment.mutate({ order_id: document_id }); + const price = item.price_calculation ?? { + service_fee: 41200, + discount: 0, + total_price: 41200, + currency: 'UZS', }; return ( <> - - {/* Sender */} - - - {userName} + + {/* # */} + + {String(index).padStart(2, '0')} + + + {/* Sarlavha */} + + + {item.title || '—'} - {/* File Name */} - - - + {item.file ? ( + - - - - {tUnknown('file')} - - + + {tUnknown('file')} + + ) : ( + + )} - {/* Date */} - - - {formatDate(item.created_at)} - + {/* Sana */} + + {formatDate(item.created_at)} - {/* State */} - + {/* Holat */} + { - if (item.state === 'unpaid') { - setIsPaymentOpen(true); - } + if (item.state === 'unpaid') setIsPaymentOpen(true); }} - className="text-sm font-medium text-slate-700 whitespace-nowrap tabular-nums" + className={item.state === 'unpaid' ? 'cursor-pointer' : ''} > - + - {/* View Button */} - + {/* Amal */} + @@ -160,15 +134,10 @@ export const HistoryTableRow: React.FC = ({ item }) => { setIsPaymentOpen(false)} - price={{ - service_fee: 41200, - discount: 5200, - total_price: 36000, - currency: 'UZS', - }} - onConfirmPayment={() => { - handleSubmit({ document_id: Number(item.order_id) }); - }} + price={price} + onConfirmPayment={() => + payment.mutate({ order_id: Number(item.order_id) }) + } isLoading={payment.isPending} />