@@ -62,6 +62,7 @@
|
||||
"amount": "Amount",
|
||||
"result": "Result",
|
||||
"actions": "",
|
||||
"state": "Payment status",
|
||||
"emptyMessage": "No plagiarism checks found.",
|
||||
"tryAgain": "Try again",
|
||||
"view": "View",
|
||||
@@ -121,7 +122,9 @@
|
||||
"certificateId": "Certificate ID",
|
||||
"downloadCertificate": "Download Certificate",
|
||||
"unknownError": "Unknown error",
|
||||
"words": "words"
|
||||
"words": "words",
|
||||
"aiProbabilityText": "Probability that the text was generated with AI has been detected",
|
||||
"documentNumber": "Document subject"
|
||||
},
|
||||
"Hero": {
|
||||
"badge": "Academic Integrity Platform",
|
||||
@@ -228,6 +231,7 @@
|
||||
"serviceFee": "Service fee",
|
||||
"certificateLabel": "Certificate",
|
||||
"total": "Total",
|
||||
"paymentRequired": "Payment not completed",
|
||||
"connecting": "Connecting to Payme…",
|
||||
"payButton": "Pay with Payme"
|
||||
},
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
"amount": "Сумма",
|
||||
"result": "Результат",
|
||||
"actions": "",
|
||||
"state": "Статус оплаты",
|
||||
"emptyMessage": "Проверки на плагиат не найдены.",
|
||||
"tryAgain": "Попробовать снова",
|
||||
"view": "Просмотр",
|
||||
@@ -121,7 +122,9 @@
|
||||
"certificateId": "ID сертификата",
|
||||
"downloadCertificate": "Скачать сертификат",
|
||||
"unknownError": "Неизвестная ошибка",
|
||||
"words": "слов"
|
||||
"words": "слов",
|
||||
"aiProbabilityText": "Обнаружена вероятность того, что текст создан с помощью ИИ",
|
||||
"documentNumber": "Тема документа"
|
||||
},
|
||||
"Hero": {
|
||||
"badge": "Платформа академической честности",
|
||||
@@ -228,6 +231,7 @@
|
||||
"serviceFee": "Стоимость услуги",
|
||||
"certificateLabel": "Сертификат",
|
||||
"total": "Итого",
|
||||
"paymentRequired": "Оплата не произведена",
|
||||
"connecting": "Подключение к Payme…",
|
||||
"payButton": "Оплатить через Payme"
|
||||
},
|
||||
|
||||
@@ -65,6 +65,7 @@ declare const messages: {
|
||||
amount: 'Summa';
|
||||
result: 'Natija';
|
||||
actions: '';
|
||||
state: "To'lov holati";
|
||||
emptyMessage: 'Plagiat tekshiruvlari topilmadi.';
|
||||
tryAgain: "Qayta urinib ko'ring";
|
||||
view: "Ko'rish";
|
||||
@@ -125,6 +126,8 @@ declare const messages: {
|
||||
downloadCertificate: 'Sertifikatni yuklab olish';
|
||||
unknownError: "Noma'lum xato";
|
||||
words: "so'z";
|
||||
aiProbabilityText: 'Ai yordamida yaratilganlik ehtimoli aniqlandi';
|
||||
documentNumber: 'Dokument mavzusi';
|
||||
};
|
||||
Hero: {
|
||||
badge: 'Akademik halollik platformasi';
|
||||
@@ -231,6 +234,7 @@ declare const messages: {
|
||||
serviceFee: "Xizmat to'lovi";
|
||||
certificateLabel: 'Sertifikat';
|
||||
total: 'Jami';
|
||||
paymentRequired: "To'lov qilinmagan";
|
||||
connecting: 'Paymega ulanmoqda…';
|
||||
payButton: "Payme orqali to'lash";
|
||||
};
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
"amount": "Summa",
|
||||
"result": "Natija",
|
||||
"actions": "",
|
||||
"state": "To'lov holati",
|
||||
"emptyMessage": "Plagiat tekshiruvlari topilmadi.",
|
||||
"tryAgain": "Qayta urinib ko'ring",
|
||||
"view": "Ko'rish",
|
||||
@@ -121,7 +122,9 @@
|
||||
"certificateId": "Sertifikat ID",
|
||||
"downloadCertificate": "Sertifikatni yuklab olish",
|
||||
"unknownError": "Noma'lum xato",
|
||||
"words": "so'z"
|
||||
"words": "so'z",
|
||||
"aiProbabilityText":"Ai yordamida yaratilganlik ehtimoli aniqlandi",
|
||||
"documentNumber":"Dokument mavzusi"
|
||||
},
|
||||
"Hero": {
|
||||
"badge": "Akademik halollik platformasi",
|
||||
@@ -228,6 +231,7 @@
|
||||
"serviceFee": "Xizmat to'lovi",
|
||||
"certificateLabel": "Sertifikat",
|
||||
"total": "Jami",
|
||||
"paymentRequired":"To'lov qilinmagan",
|
||||
"connecting": "Paymega ulanmoqda…",
|
||||
"payButton": "Payme orqali to'lash"
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useParams } from 'next/navigation';
|
||||
import { links } from '@/shared/request/links';
|
||||
import { apiRequest } from '@/shared/request/apiRequest';
|
||||
import Sertifikat from './sertifikat';
|
||||
import PaymentStatus from './paidStatus';
|
||||
|
||||
// ── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -46,6 +47,7 @@ interface Document {
|
||||
text: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
state: 'paid' | 'unpaid';
|
||||
results: Result[];
|
||||
}
|
||||
|
||||
@@ -394,6 +396,7 @@ export default function DocumentDetailPage({ id }: { id: number }) {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<PaymentStatus status={doc.state} />
|
||||
{doc.certificate && <Sertifikat document_id={Number(id)} />}
|
||||
{doc.file && (
|
||||
<a
|
||||
|
||||
@@ -157,7 +157,9 @@ export function usePlagiarismForm() {
|
||||
form,
|
||||
errors,
|
||||
submission,
|
||||
senderFullName: user ? `${user?.name} ${user?.surname}` : null,
|
||||
senderFullName: localUser
|
||||
? `${localUser?.name} ${localUser?.surname}`
|
||||
: null,
|
||||
isLoading,
|
||||
setTopic,
|
||||
setFile,
|
||||
|
||||
@@ -6,7 +6,7 @@ export const TABLE_COLUMNS = [
|
||||
{ key: 'senderFullName', labelKey: 'sender' },
|
||||
{ key: 'fileName', labelKey: 'file' },
|
||||
{ key: 'date', labelKey: 'date' },
|
||||
{ key: 'result', labelKey: 'result' },
|
||||
{ key: 'state', labelKey: 'state' },
|
||||
{ key: 'actions', labelKey: 'actions' },
|
||||
] as const;
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ export interface DocumentData {
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
results: [];
|
||||
state: 'paid' | 'unpaid';
|
||||
order_id: number;
|
||||
}
|
||||
|
||||
export interface PlagiarismCheckDetail extends DocumentData {
|
||||
|
||||
@@ -1,23 +1,68 @@
|
||||
'use client';
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { HistoryTableRowProps } from '../lib/types';
|
||||
import { formatDate } from '../lib/utils';
|
||||
import { ResultBadge } from './resultBadge';
|
||||
import { useRouter } from '@/shared/config/i18n/navigation';
|
||||
import { useUserPlagiatStore } from '@/shared/zustand/user';
|
||||
import PaymentStatus from '@/widgets/detail/paidStatus';
|
||||
import { PaymentModal } from '@/widgets/paymentModal/ui/Paymentmodal';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { apiRequest } from '@/shared/request/apiRequest';
|
||||
import { links } from '@/shared/request/links';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
export const HistoryTableRow: React.FC<HistoryTableRowProps> = ({ item }) => {
|
||||
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);
|
||||
|
||||
const userName = user
|
||||
? `${user.name} ${user.surname}`
|
||||
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'],
|
||||
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);
|
||||
setIsPaymentOpen(false);
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = ({ document_id }: { document_id: number }) => {
|
||||
payment.mutate({ order_id: document_id });
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<tr className="border-b border-slate-100 hover:bg-slate-50/70 transition-colors duration-100 group">
|
||||
{/* Sender */}
|
||||
<td className="px-4 py-3.5">
|
||||
@@ -44,7 +89,10 @@ export const HistoryTableRow: React.FC<HistoryTableRowProps> = ({ item }) => {
|
||||
>
|
||||
<path d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||
</svg>
|
||||
<span className="text-sm text-slate-600 font-mono" title={item.file}>
|
||||
<span
|
||||
className="text-sm text-slate-600 font-mono"
|
||||
title={item.file}
|
||||
>
|
||||
{tUnknown('file')}
|
||||
</span>
|
||||
</a>
|
||||
@@ -57,22 +105,30 @@ export const HistoryTableRow: React.FC<HistoryTableRowProps> = ({ item }) => {
|
||||
</span>
|
||||
</td>
|
||||
|
||||
{/* Amount */}
|
||||
{/* <td className="px-4 py-3.5">
|
||||
<span className="text-sm font-medium text-slate-700 whitespace-nowrap tabular-nums">
|
||||
{item.} UZS
|
||||
</span>
|
||||
</td> */}
|
||||
|
||||
{/* Result */}
|
||||
{/* State */}
|
||||
<td className="px-4 py-3.5">
|
||||
<ResultBadge result={'clean'} />
|
||||
<span
|
||||
onClick={() => {
|
||||
if (item.state === 'unpaid') {
|
||||
setIsPaymentOpen(true);
|
||||
}
|
||||
}}
|
||||
className="text-sm font-medium text-slate-700 whitespace-nowrap tabular-nums"
|
||||
>
|
||||
<PaymentStatus status={item.state} />
|
||||
</span>
|
||||
</td>
|
||||
|
||||
{/* View Button */}
|
||||
<td className="px-4 py-3.5 text-right">
|
||||
<button
|
||||
onClick={() => router.push(`/${item.id}`)}
|
||||
onClick={() => {
|
||||
if (item.state === 'paid') {
|
||||
router.push(`/${item.id}`);
|
||||
} else {
|
||||
toast.error(tPay('paymentRequired'));
|
||||
}
|
||||
}}
|
||||
aria-label={t('viewDetails', { sender: item.title })}
|
||||
className="
|
||||
inline-flex items-center gap-1.5 px-3 py-1.5
|
||||
@@ -100,5 +156,16 @@ export const HistoryTableRow: React.FC<HistoryTableRowProps> = ({ item }) => {
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<PaymentModal
|
||||
isOpen={isPaymentOpen}
|
||||
onClose={() => setIsPaymentOpen(false)}
|
||||
hasCertificate={false}
|
||||
onConfirmPayment={() => {
|
||||
handleSubmit({ document_id: Number(item.order_id) });
|
||||
}}
|
||||
isLoading={payment.isPending}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
import { MenuItem } from '../lib/model';
|
||||
|
||||
const SubMenuLink = ({ item }: { item: MenuItem }) => {
|
||||
const SubMenuLink = ({
|
||||
item,
|
||||
logOut,
|
||||
}: {
|
||||
item: MenuItem;
|
||||
logOut?: () => void;
|
||||
}) => {
|
||||
return (
|
||||
<a
|
||||
className="flex flex-row gap-4 rounded-md p-3 leading-none no-underline transition-colors outline-none select-none hover:bg-muted hover:text-accent-foreground"
|
||||
href={item.url}
|
||||
onClick={() => {
|
||||
if (logOut) {
|
||||
logOut();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="text-foreground">
|
||||
{item.icon && <item.icon className="size-5 shrink-0" />}
|
||||
|
||||
@@ -41,6 +41,7 @@ function AuthButtons() {
|
||||
localStorage.removeItem('access');
|
||||
localStorage.removeItem('refresh');
|
||||
localStorage.removeItem('user');
|
||||
clearUser();
|
||||
};
|
||||
console.log('Current user:', user);
|
||||
|
||||
@@ -71,12 +72,8 @@ function AuthButtons() {
|
||||
asChild
|
||||
key={subItem.title}
|
||||
className="w-80"
|
||||
onClick={() => {
|
||||
clearTokens();
|
||||
clearUser();
|
||||
}}
|
||||
>
|
||||
<SubMenuLink item={subItem} />
|
||||
<SubMenuLink logOut={clearTokens} item={subItem} />
|
||||
</NavigationMenuLink>
|
||||
))}
|
||||
</NavigationMenuContent>
|
||||
|
||||
Reference in New Issue
Block a user