fix issues for payment requst
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "no-copy-frontend",
|
||||
"version": "0.65.0",
|
||||
"version": "0.66.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 2999",
|
||||
|
||||
@@ -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'
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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 (
|
||||
<div className="block-wrapper income-and-payments">
|
||||
<div className="section-title">
|
||||
<span className="icon">💳</span>
|
||||
<span className="icon"></span>
|
||||
Доходы и выплаты
|
||||
</div>
|
||||
|
||||
<div className="earnings-cards">
|
||||
<div className="earning-card success">
|
||||
<h4>💰 Доступно к выводу</h4>
|
||||
<h4>Доступно к выводу</h4>
|
||||
<p>
|
||||
{activeInvites?.availableIncome ?? 0}
|
||||
</p>
|
||||
<small>Минимальная сумма вывода: 100 Б</small>
|
||||
<small>Минимальная сумма вывода: 1000</small>
|
||||
</div>
|
||||
|
||||
<div className="earning-card">
|
||||
<h4>📈 Всего заработано</h4>
|
||||
<h4>Всего заработано</h4>
|
||||
<p>
|
||||
{activeInvites?.totalIncome ?? 0}
|
||||
</p>
|
||||
@@ -48,9 +53,9 @@ export default function IncomeAndPayments() {
|
||||
</div>
|
||||
|
||||
<div className="earning-card warning">
|
||||
<h4>✅ Выплачено</h4>
|
||||
<h4>Выплачено</h4>
|
||||
<p>
|
||||
0
|
||||
{activeInvites?.totalIncome ?? 0}
|
||||
</p>
|
||||
<small>Успешно выплачено на ваши счета</small>
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
}}
|
||||
>
|
||||
<h4>Запросить выплату</h4>
|
||||
<h4>
|
||||
{t('request-payment')}
|
||||
</h4>
|
||||
<div className="payout-wrapper">
|
||||
<div className="form-group">
|
||||
<label>Сумма к выводу (Б)</label>
|
||||
<label>
|
||||
{t('amount-to-be-withdrawn')}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
type="text"
|
||||
name="amount"
|
||||
placeholder="Введите сумму">
|
||||
</input>
|
||||
placeholder="Введите сумму"
|
||||
inputMode="numeric"
|
||||
defaultValue={state?.previousState?.amount ?? 0}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value.replace(/[^0-9]/g, '');
|
||||
e.target.value = value;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group" >
|
||||
<label>Способ выплаты</label>
|
||||
<label>
|
||||
{t('payment-method')}
|
||||
</label>
|
||||
<input
|
||||
type="hidden"
|
||||
name="payoutMethodId"
|
||||
@@ -142,7 +154,7 @@ export default function RequestPayment() {
|
||||
className="btn-success btn-primary"
|
||||
disabled={isPending}
|
||||
>
|
||||
Заказать выплату
|
||||
{t('request-payment')}
|
||||
{isPending && (
|
||||
<div className="loading-animation">
|
||||
<div className="global-spinner"></div>
|
||||
|
||||
@@ -313,7 +313,7 @@ export default function PaymentsHistory() {
|
||||
<h3
|
||||
className="tanstak-table-title"
|
||||
>
|
||||
История выплат
|
||||
{t('payment-history')}
|
||||
</h3>
|
||||
{/* Фильтры */}
|
||||
<div className="tanstak-table-filtres" style={{ display: "none" }}>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "и",
|
||||
|
||||
Reference in New Issue
Block a user