From ad76b06e8a001e004d02d69f5eef7e65f84d8001 Mon Sep 17 00:00:00 2001 From: smanylov Date: Fri, 20 Mar 2026 12:24:01 +0700 Subject: [PATCH] fix issues for payment requst --- package.json | 2 +- src/app/actions/referralsActions.ts | 21 +++++++++----- .../ui/referral-page/Income-and-payments.tsx | 17 +++++++---- src/app/ui/referral-page/request-payment.tsx | 28 +++++++++++++------ .../referral-page/table/payments-history.tsx | 2 +- src/i18n/messages/en.json | 8 +++++- src/i18n/messages/ru.json | 8 +++++- 7 files changed, 61 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index a1da050..4075b81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "no-copy-frontend", - "version": "0.65.0", + "version": "0.66.0", "private": true, "scripts": { "dev": "next dev -p 2999", diff --git a/src/app/actions/referralsActions.ts b/src/app/actions/referralsActions.ts index 294064f..60964c4 100644 --- a/src/app/actions/referralsActions.ts +++ b/src/app/actions/referralsActions.ts @@ -359,8 +359,6 @@ export async function createPayoutRequest( const token = await getSessionData('token'); const amount = formData.get('amount') as string || ''; const payoutMethodId = formData.get('payoutMethodId') as string || ''; - console.log('createPayoutRequest'); - console.log(token); try { const response = await fetch(`${API_BASE_URL}/api/payouts/create-request`, { @@ -375,8 +373,6 @@ export async function createPayoutRequest( } }); - console.log(response); - if (response.status === 400) { const responseText = await response.text(); throw JSON.parse(responseText)?.message; @@ -393,12 +389,23 @@ export async function createPayoutRequest( error: null }; } else { - throw 'error-request'; + throw 'payment-error'; } } catch (error: unknown) { if (error) { - const typedError = error as string; + let typedError: string; + + switch (error) { + case 'Sum of pay is required': + typedError = 'sum-of-pay-is-required'; + break; + case 'Min sum for pay 1000': + typedError = 'min-sum-for-payout-1000'; + break; + default: + typedError = 'payment-error'; + } return { previousState: { @@ -412,7 +419,7 @@ export async function createPayoutRequest( previousState: { amount }, - error: 'error-request' + error: 'payment-error' }; } } \ No newline at end of file diff --git a/src/app/ui/referral-page/Income-and-payments.tsx b/src/app/ui/referral-page/Income-and-payments.tsx index 76c8c3b..04c0beb 100644 --- a/src/app/ui/referral-page/Income-and-payments.tsx +++ b/src/app/ui/referral-page/Income-and-payments.tsx @@ -4,6 +4,7 @@ import PaymentsHistory from '@/app/ui/referral-page/table/payments-history'; import { useQuery } from '@tanstack/react-query'; import { fetchReferralUserStats } from '@/app/actions/referralsActions'; import RequestPayment from '@/app/ui/referral-page/request-payment'; +import { useEffect } from 'react'; export default function IncomeAndPayments() { const { @@ -23,24 +24,28 @@ export default function IncomeAndPayments() { } }); + useEffect(() => { + console.log(activeInvites) + }, [activeInvites]) + return (
- 💳 + Доходы и выплаты
-

💰 Доступно к выводу

+

Доступно к выводу

{activeInvites?.availableIncome ?? 0}

- Минимальная сумма вывода: 100 Б + Минимальная сумма вывода: 1000
-

📈 Всего заработано

+

Всего заработано

{activeInvites?.totalIncome ?? 0}

@@ -48,9 +53,9 @@ export default function IncomeAndPayments() {
-

✅ Выплачено

+

Выплачено

- 0 + {activeInvites?.totalIncome ?? 0}

Успешно выплачено на ваши счета
diff --git a/src/app/ui/referral-page/request-payment.tsx b/src/app/ui/referral-page/request-payment.tsx index 38d78a5..c9d3006 100644 --- a/src/app/ui/referral-page/request-payment.tsx +++ b/src/app/ui/referral-page/request-payment.tsx @@ -37,7 +37,7 @@ export default function RequestPayment() { queryClient.invalidateQueries({ queryKey: ['referralUserStats'] }); queryClient.invalidateQueries({ queryKey: ['referralInvitees'] }); } else if (state?.error) { - toast.error(state.error); + toast.error(t(state.error)); } }, [state]); @@ -68,18 +68,30 @@ export default function RequestPayment() { formAction(e); }} > -

Запросить выплату

+

+ {t('request-payment')} +

- + - + placeholder="Введите сумму" + inputMode="numeric" + defaultValue={state?.previousState?.amount ?? 0} + onChange={(e) => { + const value = e.target.value.replace(/[^0-9]/g, ''); + e.target.value = value; + }} + />
- + - Заказать выплату + {t('request-payment')} {isPending && (
diff --git a/src/app/ui/referral-page/table/payments-history.tsx b/src/app/ui/referral-page/table/payments-history.tsx index 5f69522..bbc0aba 100644 --- a/src/app/ui/referral-page/table/payments-history.tsx +++ b/src/app/ui/referral-page/table/payments-history.tsx @@ -313,7 +313,7 @@ export default function PaymentsHistory() {

- История выплат + {t('payment-history')}

{/* Фильтры */}
diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index d4dc71a..b6530e8 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -349,7 +349,13 @@ "your-files": "Your files", "files-under-protection": "Files under protection", "matches-found": "Matches found", - "violations-in-progress": "Violations in progress" + "violations-in-progress": "Violations in progress", + "sum-of-pay-is-required": "Sum of payout is required", + "min-sum-for-payout-1000": "Min sum for payout 1000", + "request-payment": "Request payment", + "amount-to-be-withdrawn": "Amount to be withdrawn", + "payment-method": "Payment method", + "payment-history": "Payment history" }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index c582b4b..6efc9d6 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -349,7 +349,13 @@ "your-files": "Ваши файлы", "files-under-protection": "Файлов под защитой", "matches-found": "Найдено совпадений", - "violations-in-progress": "Нарушений в работе" + "violations-in-progress": "Нарушений в работе", + "sum-of-pay-is-required": "Введите сумму выплаты", + "min-sum-for-payout-1000": "Минимальная сумма выплаты: 1000", + "request-payment": "Запросить выплату", + "amount-to-be-withdrawn": "Сумма к выводу", + "payment-method": "Способ выплаты", + "payment-history": "История выплат" }, "Login-register-form": { "and": "и",