add ref link error, add refill button, update referral invites table
This commit is contained in:
+11
-7
@@ -214,8 +214,8 @@ export async function registration(
|
||||
phone: phone,
|
||||
password,
|
||||
accountType,
|
||||
/* referralLink: referralCode, */
|
||||
...(accountType === 'b2b' && { companyName: companyName })
|
||||
...(accountType === 'b2b' && { companyName: companyName }),
|
||||
...(referralCode !== '' && { referralLink: referralCode })
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
@@ -230,8 +230,8 @@ export async function registration(
|
||||
phone: phone,
|
||||
password,
|
||||
accountType,
|
||||
/* referralLink: referralCode, */
|
||||
...(accountType === 'b2b' && { companyName: companyName })
|
||||
...(accountType === 'b2b' && { companyName: companyName }),
|
||||
...(referralCode !== '' && { referralLink: referralCode })
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
@@ -282,9 +282,13 @@ export async function registration(
|
||||
|
||||
switch (typedError.message_code) {
|
||||
case 1:
|
||||
errors['server'] = 'email-or-already-registered'
|
||||
break;
|
||||
|
||||
if (typedError.message_desc === 'Refferal link is not exist') {
|
||||
errors['server'] = 'referral-link-is-not-exist'
|
||||
break;
|
||||
} else {
|
||||
errors['server'] = 'email-or-already-registered'
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
if (typedError.message_body?.fieldErrors) {
|
||||
typedError.message_body?.fieldErrors?.forEach((obj: {
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function fetchReferralInvitees() {
|
||||
message_body: {
|
||||
action: 'invitees',
|
||||
token: token,
|
||||
pageSize: 10,
|
||||
pageSize: 100,
|
||||
pageNumber: 0
|
||||
}
|
||||
}),
|
||||
@@ -109,6 +109,60 @@ export async function fetchReferralInvitees() {
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
console.log({
|
||||
action: 'invitees',
|
||||
token: token,
|
||||
pageSize: 10,
|
||||
pageNumber: 0
|
||||
})
|
||||
console.log(parsed);
|
||||
|
||||
if (parsed.message_code === 0) {
|
||||
return parsed.message_body;
|
||||
} else {
|
||||
throw parsed;
|
||||
}
|
||||
} else {
|
||||
throw (`${response.status}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
error: error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function referralRefill() {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 30003,
|
||||
message_body: {
|
||||
action: 'refill',
|
||||
token: token,
|
||||
amount: 1,
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log('referralRefill');
|
||||
console.log({
|
||||
action: 'refill',
|
||||
token: token,
|
||||
amount: 1,
|
||||
})
|
||||
let parsed = await response.json();
|
||||
console.log(parsed);
|
||||
|
||||
if (parsed.message_code === 0) {
|
||||
return parsed.message_body;
|
||||
|
||||
@@ -1,9 +1,31 @@
|
||||
'use client'
|
||||
|
||||
import { referralRefill } from '@/app/actions/referralsActions';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export default function SecurePayments() {
|
||||
|
||||
return (
|
||||
<div className="secure-payments-wrapper">
|
||||
<h3>
|
||||
🔒 Безопасные платежи
|
||||
</h3>
|
||||
<div>
|
||||
<button
|
||||
className='btn btn-primary'
|
||||
onClick={async () => {
|
||||
const response = await referralRefill();
|
||||
console.log(response);
|
||||
if (response?.account === 'refill') {
|
||||
toast.success('refill');
|
||||
} else {
|
||||
toast.error(`error refill: ${response?.error?.message_desc}`);
|
||||
}
|
||||
}}
|
||||
>
|
||||
referralRefill
|
||||
</button>
|
||||
</div>
|
||||
<div className="secure-payments-grid">
|
||||
<div className="secure-payments-card">
|
||||
<div className="secure-payments-card-header">
|
||||
|
||||
@@ -11,24 +11,23 @@ import {
|
||||
SortingState,
|
||||
ColumnFiltersState,
|
||||
} from '@tanstack/react-table';
|
||||
import { IconEye, IconDoubleArrowRight, IconArrowRight, IconDoubleArrowLeft, IconArrowLeft, IconArrowUp, IconArrowDown, IconFilter, IconFileDownload, IconShieldExclamation } from '@/app/ui/icons/icons';
|
||||
import { IconDoubleArrowRight, IconArrowRight, IconDoubleArrowLeft, IconArrowLeft, IconArrowUp, IconArrowDown, IconFilter } from '@/app/ui/icons/icons';
|
||||
import { useTranslations, useLocale } from 'next-intl';
|
||||
import DropDownList from '@/app/components/DropDownList';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { toast } from 'sonner';
|
||||
import { pluralize } from '@/app/lib/pluralize';
|
||||
import { fetchReferralInvitees } from '@/app/actions/referralsActions';
|
||||
|
||||
type InviteesType = {
|
||||
status?: string;
|
||||
email?: string;
|
||||
registrationData: number;
|
||||
registrationData: string;
|
||||
};
|
||||
|
||||
type InviteType = {
|
||||
active?: string;
|
||||
email?: string;
|
||||
regDate: number;
|
||||
regDate: string;
|
||||
};
|
||||
|
||||
export default function InvitationsTable() {
|
||||
@@ -45,28 +44,14 @@ export default function InvitationsTable() {
|
||||
|
||||
select: (data: InviteType[]): InviteesType[] => {
|
||||
if (!data) return [
|
||||
{
|
||||
status: 'string1',
|
||||
email: 'string1',
|
||||
registrationData: 1
|
||||
},
|
||||
{
|
||||
status: 'string2',
|
||||
email: 'string2',
|
||||
registrationData: 2
|
||||
},
|
||||
{
|
||||
status: 'string3',
|
||||
email: 'string3',
|
||||
registrationData: 3
|
||||
}
|
||||
];
|
||||
|
||||
return data.map((item: InviteType) => {
|
||||
console.log(item);
|
||||
return {
|
||||
status: item.active,
|
||||
email: item.email,
|
||||
registrationData: item.regDate
|
||||
status: item?.active ? 'active' : 'not-active',
|
||||
email: item?.email,
|
||||
registrationData: item?.regDate
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -191,7 +176,7 @@ export default function InvitationsTable() {
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="text-center table-item">
|
||||
{row.original.registrationData}
|
||||
{row.original.registrationData?.split('T')[0]}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
@@ -214,7 +199,7 @@ export default function InvitationsTable() {
|
||||
}
|
||||
|
||||
// Фильтр по дате
|
||||
if (dateFilter !== 'all') {
|
||||
/* if (dateFilter !== 'all') {
|
||||
const now = Date.now();
|
||||
const oneDay = 24 * 60 * 60 * 1000;
|
||||
const sevenDays = 7 * oneDay;
|
||||
@@ -256,7 +241,7 @@ export default function InvitationsTable() {
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
return result;
|
||||
}, [referralInvitees, statusFilter, dateFilter]);
|
||||
|
||||
@@ -287,6 +287,7 @@
|
||||
"change-password": "Change Password",
|
||||
"recovery-code": "Recovery code",
|
||||
"referal-code": "Referal code",
|
||||
"email-invalid": "Invalid email address"
|
||||
"email-invalid": "Invalid email address",
|
||||
"referral-link-is-not-exist" : "Referral link is not exist"
|
||||
}
|
||||
}
|
||||
@@ -287,6 +287,7 @@
|
||||
"change-password": "Изменить пароль",
|
||||
"recovery-code": "Код восстановления",
|
||||
"referal-code": "Реферальный код",
|
||||
"email-invalid": "Неверный адрес электронной почты"
|
||||
"email-invalid": "Неверный адрес электронной почты",
|
||||
"referral-link-is-not-exist" : "Отсутствует реферальная ссылка."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user