edit payments history
This commit is contained in:
@@ -14,7 +14,6 @@ export default function IncomeAndPayments() {
|
||||
return fetchReferralUserStats();
|
||||
},
|
||||
select: (data) => {
|
||||
console.log(data);
|
||||
if (data?.referralLink) {
|
||||
return data
|
||||
} else {
|
||||
|
||||
@@ -6,57 +6,12 @@ import { useReactTable, getCoreRowModel, getSortedRowModel, getPaginationRowMode
|
||||
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 { useQueryClient, useQuery } from '@tanstack/react-query';
|
||||
import { pluralize } from '@/app/lib/pluralize';
|
||||
import { fetchReferralInvitees } from '@/app/actions/referralsActions';
|
||||
|
||||
type InviteesType = {
|
||||
status?: string;
|
||||
email?: string;
|
||||
registrationData: string;
|
||||
};
|
||||
|
||||
type InviteType = {
|
||||
active?: string;
|
||||
email?: string;
|
||||
regDate: string;
|
||||
};
|
||||
import { ReferralPayments } from '@/app/hooks/react-query/useGetReferralPayments';
|
||||
import { formatDate } from '@/app/lib/formatDate';
|
||||
|
||||
export default function PaymentsHistory() {
|
||||
|
||||
const { data: paymentsData } = useGetReferralPayments();
|
||||
|
||||
useEffect(() => {
|
||||
console.log(paymentsData);
|
||||
}, [paymentsData]);
|
||||
|
||||
const {
|
||||
data: referralInvitees,
|
||||
isLoading,
|
||||
isError,
|
||||
error,
|
||||
} = useQuery<InviteType[], Error, InviteesType[], ['referralInvitees']>({
|
||||
queryKey: ['referralInvitees'],
|
||||
queryFn: () => {
|
||||
return fetchReferralInvitees();
|
||||
},
|
||||
|
||||
select: (data: InviteType[]): InviteesType[] => {
|
||||
if (!data) return [
|
||||
];
|
||||
|
||||
return data.map((item: InviteType) => {
|
||||
|
||||
return {
|
||||
status: item?.active ? 'active' : 'not-active',
|
||||
email: item?.email,
|
||||
registrationData: item?.regDate
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const { data: paymentsData, isLoading, isError, error, } = useGetReferralPayments();
|
||||
|
||||
// Состояния
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
@@ -72,7 +27,7 @@ export default function PaymentsHistory() {
|
||||
const locale = useLocale();
|
||||
|
||||
// Определение колонок
|
||||
const columns = useMemo<ColumnDef<InviteesType>[]>(
|
||||
const columns = useMemo<ColumnDef<ReferralPayments>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorKey: 'amount',
|
||||
@@ -103,9 +58,7 @@ export default function PaymentsHistory() {
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<div className="text-center table-item">
|
||||
{/* {row.original.size !== undefined ? convertBytes(row.original.size) : '-'} */}
|
||||
{/* {row.original.email} */}
|
||||
---
|
||||
{row.original.amount ?? '-'}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
@@ -211,7 +164,7 @@ export default function PaymentsHistory() {
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="text-center table-item">
|
||||
{row.original.registrationData?.split('T')[0]}
|
||||
{formatDate(row.original.createdAt) ? formatDate(row.original.createdAt) : '---'}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
@@ -247,7 +200,7 @@ export default function PaymentsHistory() {
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="text-center table-item">
|
||||
{row.original.registrationData?.split('T')[0]}
|
||||
{row.original.updatedAt ? formatDate(row.original.updatedAt) : '---'}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
@@ -259,7 +212,7 @@ export default function PaymentsHistory() {
|
||||
|
||||
// Фильтрация по типу файла и дате
|
||||
const filteredData = useMemo(() => {
|
||||
let result = referralInvitees;
|
||||
let result = paymentsData?.payments;
|
||||
if (!result) {
|
||||
return [];
|
||||
}
|
||||
@@ -315,7 +268,7 @@ export default function PaymentsHistory() {
|
||||
} */
|
||||
|
||||
return result;
|
||||
}, [referralInvitees, statusFilter, dateFilter]);
|
||||
}, [paymentsData, statusFilter, dateFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
const currentPageRows = table.getRowModel().rows;
|
||||
|
||||
Reference in New Issue
Block a user