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