fix issues for payment requst
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "no-copy-frontend",
|
"name": "no-copy-frontend",
|
||||||
"version": "0.65.0",
|
"version": "0.66.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 2999",
|
"dev": "next dev -p 2999",
|
||||||
|
|||||||
@@ -359,8 +359,6 @@ export async function createPayoutRequest(
|
|||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
const amount = formData.get('amount') as string || '';
|
const amount = formData.get('amount') as string || '';
|
||||||
const payoutMethodId = formData.get('payoutMethodId') as string || '';
|
const payoutMethodId = formData.get('payoutMethodId') as string || '';
|
||||||
console.log('createPayoutRequest');
|
|
||||||
console.log(token);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE_URL}/api/payouts/create-request`, {
|
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) {
|
if (response.status === 400) {
|
||||||
const responseText = await response.text();
|
const responseText = await response.text();
|
||||||
throw JSON.parse(responseText)?.message;
|
throw JSON.parse(responseText)?.message;
|
||||||
@@ -393,12 +389,23 @@ export async function createPayoutRequest(
|
|||||||
error: null
|
error: null
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
throw 'error-request';
|
throw 'payment-error';
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
|
|
||||||
if (error) {
|
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 {
|
return {
|
||||||
previousState: {
|
previousState: {
|
||||||
@@ -412,7 +419,7 @@ export async function createPayoutRequest(
|
|||||||
previousState: {
|
previousState: {
|
||||||
amount
|
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 { useQuery } from '@tanstack/react-query';
|
||||||
import { fetchReferralUserStats } from '@/app/actions/referralsActions';
|
import { fetchReferralUserStats } from '@/app/actions/referralsActions';
|
||||||
import RequestPayment from '@/app/ui/referral-page/request-payment';
|
import RequestPayment from '@/app/ui/referral-page/request-payment';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export default function IncomeAndPayments() {
|
export default function IncomeAndPayments() {
|
||||||
const {
|
const {
|
||||||
@@ -23,24 +24,28 @@ export default function IncomeAndPayments() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(activeInvites)
|
||||||
|
}, [activeInvites])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="block-wrapper income-and-payments">
|
<div className="block-wrapper income-and-payments">
|
||||||
<div className="section-title">
|
<div className="section-title">
|
||||||
<span className="icon">💳</span>
|
<span className="icon"></span>
|
||||||
Доходы и выплаты
|
Доходы и выплаты
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="earnings-cards">
|
<div className="earnings-cards">
|
||||||
<div className="earning-card success">
|
<div className="earning-card success">
|
||||||
<h4>💰 Доступно к выводу</h4>
|
<h4>Доступно к выводу</h4>
|
||||||
<p>
|
<p>
|
||||||
{activeInvites?.availableIncome ?? 0}
|
{activeInvites?.availableIncome ?? 0}
|
||||||
</p>
|
</p>
|
||||||
<small>Минимальная сумма вывода: 100 Б</small>
|
<small>Минимальная сумма вывода: 1000</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="earning-card">
|
<div className="earning-card">
|
||||||
<h4>📈 Всего заработано</h4>
|
<h4>Всего заработано</h4>
|
||||||
<p>
|
<p>
|
||||||
{activeInvites?.totalIncome ?? 0}
|
{activeInvites?.totalIncome ?? 0}
|
||||||
</p>
|
</p>
|
||||||
@@ -48,9 +53,9 @@ export default function IncomeAndPayments() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="earning-card warning">
|
<div className="earning-card warning">
|
||||||
<h4>✅ Выплачено</h4>
|
<h4>Выплачено</h4>
|
||||||
<p>
|
<p>
|
||||||
0
|
{activeInvites?.totalIncome ?? 0}
|
||||||
</p>
|
</p>
|
||||||
<small>Успешно выплачено на ваши счета</small>
|
<small>Успешно выплачено на ваши счета</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function RequestPayment() {
|
|||||||
queryClient.invalidateQueries({ queryKey: ['referralUserStats'] });
|
queryClient.invalidateQueries({ queryKey: ['referralUserStats'] });
|
||||||
queryClient.invalidateQueries({ queryKey: ['referralInvitees'] });
|
queryClient.invalidateQueries({ queryKey: ['referralInvitees'] });
|
||||||
} else if (state?.error) {
|
} else if (state?.error) {
|
||||||
toast.error(state.error);
|
toast.error(t(state.error));
|
||||||
}
|
}
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
@@ -68,18 +68,30 @@ export default function RequestPayment() {
|
|||||||
formAction(e);
|
formAction(e);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h4>Запросить выплату</h4>
|
<h4>
|
||||||
|
{t('request-payment')}
|
||||||
|
</h4>
|
||||||
<div className="payout-wrapper">
|
<div className="payout-wrapper">
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Сумма к выводу (Б)</label>
|
<label>
|
||||||
|
{t('amount-to-be-withdrawn')}
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
name="amount"
|
name="amount"
|
||||||
placeholder="Введите сумму">
|
placeholder="Введите сумму"
|
||||||
</input>
|
inputMode="numeric"
|
||||||
|
defaultValue={state?.previousState?.amount ?? 0}
|
||||||
|
onChange={(e) => {
|
||||||
|
const value = e.target.value.replace(/[^0-9]/g, '');
|
||||||
|
e.target.value = value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group" >
|
<div className="form-group" >
|
||||||
<label>Способ выплаты</label>
|
<label>
|
||||||
|
{t('payment-method')}
|
||||||
|
</label>
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
name="payoutMethodId"
|
name="payoutMethodId"
|
||||||
@@ -142,7 +154,7 @@ export default function RequestPayment() {
|
|||||||
className="btn-success btn-primary"
|
className="btn-success btn-primary"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
>
|
>
|
||||||
Заказать выплату
|
{t('request-payment')}
|
||||||
{isPending && (
|
{isPending && (
|
||||||
<div className="loading-animation">
|
<div className="loading-animation">
|
||||||
<div className="global-spinner"></div>
|
<div className="global-spinner"></div>
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ export default function PaymentsHistory() {
|
|||||||
<h3
|
<h3
|
||||||
className="tanstak-table-title"
|
className="tanstak-table-title"
|
||||||
>
|
>
|
||||||
История выплат
|
{t('payment-history')}
|
||||||
</h3>
|
</h3>
|
||||||
{/* Фильтры */}
|
{/* Фильтры */}
|
||||||
<div className="tanstak-table-filtres" style={{ display: "none" }}>
|
<div className="tanstak-table-filtres" style={{ display: "none" }}>
|
||||||
|
|||||||
@@ -349,7 +349,13 @@
|
|||||||
"your-files": "Your files",
|
"your-files": "Your files",
|
||||||
"files-under-protection": "Files under protection",
|
"files-under-protection": "Files under protection",
|
||||||
"matches-found": "Matches found",
|
"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": {
|
"Login-register-form": {
|
||||||
"and": "and",
|
"and": "and",
|
||||||
|
|||||||
@@ -349,7 +349,13 @@
|
|||||||
"your-files": "Ваши файлы",
|
"your-files": "Ваши файлы",
|
||||||
"files-under-protection": "Файлов под защитой",
|
"files-under-protection": "Файлов под защитой",
|
||||||
"matches-found": "Найдено совпадений",
|
"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": {
|
"Login-register-form": {
|
||||||
"and": "и",
|
"and": "и",
|
||||||
|
|||||||
Reference in New Issue
Block a user