From e8d34dafba2e88fd8ec1302c4160f19c9a5237c4 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 30 Apr 2025 09:38:33 +0300 Subject: [PATCH] PM-1152 - cleanup wallet admin --- .../src/home/tabs/WalletAdminTabs.tsx | 6 - .../PaymentMethodsTab.module.scss | 35 --- .../payment-methods/PaymentMethodsTab.tsx | 209 ---------------- .../src/home/tabs/payment-methods/index.ts | 1 - .../tabs/tax-forms/TaxFormsTab.module.scss | 35 --- .../src/home/tabs/tax-forms/TaxFormsTab.tsx | 228 ------------------ .../src/home/tabs/tax-forms/index.ts | 1 - .../wallet-admin/src/lib/components/index.ts | 2 - .../PaymentMethodTable.module.scss | 109 --------- .../PaymentMethodTable.tsx | 112 --------- .../components/payment-method-table/index.ts | 1 - .../tax-forms-table/TaxFormTable.module.scss | 109 --------- .../tax-forms-table/TaxFormTable.tsx | 123 ---------- .../lib/components/tax-forms-table/index.ts | 1 - .../wallet-admin/src/lib/services/wallet.ts | 196 +++++---------- 15 files changed, 56 insertions(+), 1112 deletions(-) delete mode 100644 src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.module.scss delete mode 100644 src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.tsx delete mode 100644 src/apps/wallet-admin/src/home/tabs/payment-methods/index.ts delete mode 100644 src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.module.scss delete mode 100644 src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.tsx delete mode 100644 src/apps/wallet-admin/src/home/tabs/tax-forms/index.ts delete mode 100644 src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.module.scss delete mode 100644 src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.tsx delete mode 100644 src/apps/wallet-admin/src/lib/components/payment-method-table/index.ts delete mode 100644 src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.module.scss delete mode 100644 src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.tsx delete mode 100644 src/apps/wallet-admin/src/lib/components/tax-forms-table/index.ts diff --git a/src/apps/wallet-admin/src/home/tabs/WalletAdminTabs.tsx b/src/apps/wallet-admin/src/home/tabs/WalletAdminTabs.tsx index 73d694e1d..a26d94225 100644 --- a/src/apps/wallet-admin/src/home/tabs/WalletAdminTabs.tsx +++ b/src/apps/wallet-admin/src/home/tabs/WalletAdminTabs.tsx @@ -7,8 +7,6 @@ import { PageTitle, TabsNavbar, TabsNavItem } from '~/libs/ui' import { getHashFromTabId, getTabIdFromHash, WalletAdminTabsConfig, WalletAdminTabViews } from './config' import { PaymentsTab } from './payments' import { HomeTab } from './home' -import { TaxFormsTab } from './tax-forms' -import { PaymentMethodsTab } from './payment-methods' import styles from './WalletAdminTabs.module.scss' interface WalletHomeProps { @@ -46,10 +44,6 @@ const WalletAdminTabs: FC = (props: WalletHomeProps) => { {activeTab === WalletAdminTabViews.home && } {activeTab === WalletAdminTabViews.payments && } - - {activeTab === WalletAdminTabViews.taxforms && } - - {activeTab === WalletAdminTabViews.withdrawalmethods && } ) } diff --git a/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.module.scss b/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.module.scss deleted file mode 100644 index 4d5773ab0..000000000 --- a/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.module.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import '@libs/ui/styles/includes'; - -.container { - background-color: $black-5; - padding: $sp-6; - margin: $sp-8 0; - border-radius: 6px; - - @include ltelg { - padding: $sp-4; - } - - .header { - display: flex; - justify-content: flex-start; - gap: 5px; - align-items: center; - - @include ltelg { - flex-direction: column; - } - } - - .content { - background-color: $tc-white; - border-radius: 4px; - margin-top: $sp-4; - .centered { - height: 200px; - display: flex; - justify-content: space-around; - align-items: center; - } - } -} diff --git a/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.tsx b/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.tsx deleted file mode 100644 index 9539b9f7a..000000000 --- a/src/apps/wallet-admin/src/home/tabs/payment-methods/PaymentMethodsTab.tsx +++ /dev/null @@ -1,209 +0,0 @@ -/* eslint-disable max-len */ -/* eslint-disable react/jsx-no-bind */ -import { toast } from 'react-toastify' -import React, { FC, useCallback, useEffect } from 'react' - -import { Collapsible, ConfirmModal, LoadingCircles } from '~/libs/ui' -import { UserProfile } from '~/libs/core' - -import { PaymentProvider } from '../../../lib/models/PaymentProvider' -import { deletePaymentProvider, getMemberHandle, getPaymentMethods } from '../../../lib/services/wallet' -import { FilterBar, PaymentMethodTable } from '../../../lib' -import { PaginationInfo } from '../../../lib/models/PaginationInfo' - -import styles from './PaymentMethodsTab.module.scss' - -interface ListViewProps { - // eslint-disable-next-line react/no-unused-prop-types - profile: UserProfile -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const ListView: FC = (props: ListViewProps) => { - const [confirmFlow, setConfirmFlow] = React.useState<{ - provider: PaymentProvider - } | undefined>(undefined) - const [isLoading, setIsLoading] = React.useState(false) - const [filters, setFilters] = React.useState>({}) - const [paymentMethods, setPaymentMethods] = React.useState([]) - const [userIds, setUserIds] = React.useState([]) - const [pagination, setPagination] = React.useState({ - currentPage: 1, - pageSize: 10, - totalItems: 0, - totalPages: 0, - }) - - const fetchPaymentProviders = useCallback(async () => { - if (isLoading) { - return - } - - setIsLoading(true) - try { - - const paymentMethodsResponse = await getPaymentMethods(pagination.pageSize, (pagination.currentPage - 1) * pagination.pageSize, userIds) - const tmpUserIds = paymentMethodsResponse.paymentMethods.map(provider => provider.userId) - const handleMap = await getMemberHandle(tmpUserIds) - - const userPaymentMethods = paymentMethodsResponse.paymentMethods.map((provider: PaymentProvider) => ({ ...provider, handle: handleMap.get(parseInt(provider.userId, 10)) ?? provider.userId })) - - setPaymentMethods(userPaymentMethods) - setPagination(paymentMethodsResponse.pagination) - } catch (apiError) { - console.error('Failed to fetch winnings:', apiError) - } finally { - setIsLoading(false) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [pagination.pageSize, pagination.currentPage, userIds]) - - useEffect(() => { - fetchPaymentProviders() - }, [fetchPaymentProviders]) - - return ( - <> -
-
-

Member Payment Providers

-
-
- Member Payment Providers Listing}> - { - const newPagination = { - ...pagination, - currentPage: 1, - } - if (key === 'pageSize') { - newPagination.pageSize = parseInt(value[0], 10) - } - - if (key === 'userIds') { - setUserIds(value) - } - - setPagination(newPagination) - setFilters({ - ...filters, - [key]: value, - }) - }} - onResetFilters={() => { - setPagination({ - ...pagination, - currentPage: 1, - pageSize: 10, - }) - setFilters({}) - }} - /> - {isLoading && } - {!isLoading && paymentMethods.length > 0 && ( - { - setPagination({ - ...pagination, - currentPage: pagination.currentPage - 1, - }) - }} - onNextPageClick={() => { - setPagination({ - ...pagination, - currentPage: pagination.currentPage + 1, - }) - }} - onPageClick={(pageNumber: number) => { - setPagination({ - ...pagination, - currentPage: pageNumber, - }) - }} - onDeleteClick={async (provider: PaymentProvider) => { - setConfirmFlow({ provider }) - }} - /> - )} - {!isLoading && paymentMethods.length === 0 && ( -
-

- {Object.keys(filters).length === 0 - ? 'Member payment-providers will appear here.' - : 'No payment-provider found for the selected member(s).'} -

-
- )} -
-
-
- {confirmFlow && ( - { - setConfirmFlow(undefined) - }} - onConfirm={async () => { - const userId = confirmFlow.provider.userId - const providerId = confirmFlow.provider.id! - setConfirmFlow(undefined) - - toast.success('Deleting payment provider. Please wait...', { position: 'bottom-right' }) - try { - await deletePaymentProvider(userId, providerId) - toast.success('Successfully deleted payment provider.', { position: 'bottom-right' }) - } catch (err) { - toast.error('Failed to delete users payment provider. Please try again later', { position: 'bottom-right' }) - } - - fetchPaymentProviders() - }} - open={confirmFlow !== undefined} - > -
-

- Are you sure you want to reset the payment provider of the member - {' '} - {confirmFlow.provider.handle} - ? -

-
-

This action cannot be undone.

-
-
- )} - - ) -} - -export default ListView diff --git a/src/apps/wallet-admin/src/home/tabs/payment-methods/index.ts b/src/apps/wallet-admin/src/home/tabs/payment-methods/index.ts deleted file mode 100644 index ae6c8e814..000000000 --- a/src/apps/wallet-admin/src/home/tabs/payment-methods/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PaymentMethodsTab } from './PaymentMethodsTab' diff --git a/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.module.scss b/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.module.scss deleted file mode 100644 index 4d5773ab0..000000000 --- a/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.module.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import '@libs/ui/styles/includes'; - -.container { - background-color: $black-5; - padding: $sp-6; - margin: $sp-8 0; - border-radius: 6px; - - @include ltelg { - padding: $sp-4; - } - - .header { - display: flex; - justify-content: flex-start; - gap: 5px; - align-items: center; - - @include ltelg { - flex-direction: column; - } - } - - .content { - background-color: $tc-white; - border-radius: 4px; - margin-top: $sp-4; - .centered { - height: 200px; - display: flex; - justify-content: space-around; - align-items: center; - } - } -} diff --git a/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.tsx b/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.tsx deleted file mode 100644 index 1fd6e1bb0..000000000 --- a/src/apps/wallet-admin/src/home/tabs/tax-forms/TaxFormsTab.tsx +++ /dev/null @@ -1,228 +0,0 @@ -/* eslint-disable max-len */ -/* eslint-disable react/jsx-no-bind */ -import { toast } from 'react-toastify' -import { AxiosError } from 'axios' -import React, { FC, useCallback, useEffect } from 'react' - -import { Collapsible, ConfirmModal, LoadingCircles } from '~/libs/ui' -import { UserProfile } from '~/libs/core' -import { downloadBlob } from '~/libs/shared' - -import { deleteTaxForm, downloadTaxForm, getMemberHandle, getTaxForms } from '../../../lib/services/wallet' -import { TaxForm } from '../../../lib/models/TaxForm' -import { FilterBar, formatIOSDateString, TaxFormTable } from '../../../lib' -import { PaginationInfo } from '../../../lib/models/PaginationInfo' - -import styles from './TaxFormsTab.module.scss' - -interface ListViewProps { - // eslint-disable-next-line react/no-unused-prop-types - profile: UserProfile -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const ListView: FC = (props: ListViewProps) => { - const [confirmFlow, setConfirmFlow] = React.useState<{ - form: TaxForm - } | undefined>(undefined) - const [isLoading, setIsLoading] = React.useState(false) - const [filters, setFilters] = React.useState>({}) - const [forms, setForms] = React.useState([]) - const [userIds, setUserIds] = React.useState([]) - const [pagination, setPagination] = React.useState({ - currentPage: 1, - pageSize: 10, - totalItems: 0, - totalPages: 0, - }) - const [apiErrorMsg, setApiErrorMsg] = React.useState('Member earnings will appear here.') - - const fetchTaxForms = useCallback(async () => { - if (isLoading) { - return - } - - setIsLoading(true) - try { - - const taxFormsResponse = await getTaxForms(pagination.pageSize, (pagination.currentPage - 1) * pagination.pageSize, userIds) - const tmpUserIds = taxFormsResponse.forms.map(form => form.userId) - const handleMap = await getMemberHandle(tmpUserIds) - - const taxForms = taxFormsResponse.forms.map((form: TaxForm) => ({ ...form, dateFiled: form.dateFiled ? formatIOSDateString(form.dateFiled) : '-', handle: handleMap.get(parseInt(form.userId, 10)) ?? form.userId })) - - setForms(taxForms) - setPagination(taxFormsResponse.pagination) - } catch (apiError) { - if (apiError instanceof AxiosError && apiError?.response?.status === 403) { - setApiErrorMsg(apiError.response.data.message) - } else { - setApiErrorMsg('Failed to fetch winnings. Please try again later.') - } - } finally { - setIsLoading(false) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [pagination.pageSize, pagination.currentPage, userIds]) - - useEffect(() => { - fetchTaxForms() - }, [fetchTaxForms]) - - return ( - <> -
-
-

Member Tax Forms

-
-
- Tax Forms Listing}> - { - const newPagination = { - ...pagination, - currentPage: 1, - } - if (key === 'pageSize') { - newPagination.pageSize = parseInt(value[0], 10) - } - - if (key === 'userIds') { - setUserIds(value) - } - - setPagination(newPagination) - setFilters({ - ...filters, - [key]: value, - }) - }} - onResetFilters={() => { - setPagination({ - ...pagination, - currentPage: 1, - pageSize: 10, - }) - setFilters({}) - }} - /> - {isLoading && } - {!isLoading && forms.length > 0 && ( - { - setPagination({ - ...pagination, - currentPage: pagination.currentPage - 1, - }) - }} - onNextPageClick={() => { - setPagination({ - ...pagination, - currentPage: pagination.currentPage + 1, - }) - }} - onPageClick={(pageNumber: number) => { - setPagination({ - ...pagination, - currentPage: pageNumber, - }) - }} - onDownloadClick={async (form: TaxForm) => { - toast.success('Downloading tax form. Please wait...', { position: 'bottom-right' }) - try { - downloadBlob( - await downloadTaxForm(form.userId, form.id), - `tax-form-${form.userId}-${new Date() - .getTime()}.pdf`, - ) - } catch (err) { - toast.error('Failed to download tax form. Please try again later', { position: 'bottom-right' }) - } - }} - onDeleteClick={async (form: TaxForm) => { - setConfirmFlow({ form }) - }} - /> - )} - {!isLoading && forms.length === 0 && ( -
-

- {Object.keys(filters).length === 0 - ? apiErrorMsg - : 'No tax-forms found for the selected member(s).'} -

-
- )} -
-
-
- {confirmFlow && ( - { - setConfirmFlow(undefined) - }} - onConfirm={async () => { - const userId = confirmFlow.form.userId - const formId = confirmFlow.form.id - setConfirmFlow(undefined) - - toast.success('Deleting tax form. Please wait...', { position: 'bottom-right' }) - try { - await deleteTaxForm(userId, formId) - toast.success('Successfully deleted tax-form.', { position: 'bottom-right' }) - } catch (err) { - toast.error('Failed to delete users tax-form. Please try again later', { position: 'bottom-right' }) - } - - fetchTaxForms() - }} - open={confirmFlow !== undefined} - > -
-

- Are you sure you want to reset the tax-form of the member - {' '} - {confirmFlow.form.handle} - ? -

-
-

This action cannot be undone.

-
-
- )} - - ) -} - -export default ListView diff --git a/src/apps/wallet-admin/src/home/tabs/tax-forms/index.ts b/src/apps/wallet-admin/src/home/tabs/tax-forms/index.ts deleted file mode 100644 index 08eb9c245..000000000 --- a/src/apps/wallet-admin/src/home/tabs/tax-forms/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as TaxFormsTab } from './TaxFormsTab' diff --git a/src/apps/wallet-admin/src/lib/components/index.ts b/src/apps/wallet-admin/src/lib/components/index.ts index 23457ecab..820a0c53c 100644 --- a/src/apps/wallet-admin/src/lib/components/index.ts +++ b/src/apps/wallet-admin/src/lib/components/index.ts @@ -3,5 +3,3 @@ export * from './chip' export * from './filter-bar' export * from './payment-edit' export * from './payment-view' -export * from './tax-forms-table' -export * from './payment-method-table' diff --git a/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.module.scss b/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.module.scss deleted file mode 100644 index 5e4ea7c5a..000000000 --- a/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.module.scss +++ /dev/null @@ -1,109 +0,0 @@ -@import '@libs/ui/styles/includes'; - -.tableContainer { - width: 100%; - overflow-x: auto; - margin-top: $sp-2; -} - -table { - width: 100%; - border-collapse: separate; - border-spacing: 0; - margin: 16px 0; - - th, - td { - text-align: left; - padding: 8px; - - &:last-child { - width: 50px; - } - } - - tbody { - tr { - &:nth-child(odd) { - background-color: #f4f4f4; - } - &:nth-child(even) { - background-color: #ffffff; - } - - .capitalize { - text-transform: capitalize; - } - } - } - - th { - top: 0; - background-color: white !important; - text-transform: uppercase; - } - - tbody tr td:first-child { - border-top-left-radius: 8px; - border-bottom-left-radius: 8px; - } - - tbody tr td:last-child { - border-top-right-radius: 8px; - border-bottom-right-radius: 8px; - } - -} - -.selected { - background-color: #e7f4ff; -} - -.pageButtons { - display: flex; - justify-content: flex-end; - align-items: center; - margin-top: 16px; - gap: $sp-4; - - .pageNumbers { - display: flex; - justify-content: center; - align-items: center; - gap: $sp-1; - } - -} - -.footer { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: center; - margin-top: 16px; - padding-bottom: 16px; - border-radius: 8px; - background-color: white; - border: 1px solid #eaeaea; - - .total { - font-size: 18px; - font-weight: bold; - - color: #333; - } -} - -.actionButtons { - padding-right: 50px; - display: flex; - justify-content: center; - align-items: center; -} - -@media (max-width: 768px) { - .footer { - flex-direction: column; - align-items: center; - } -} diff --git a/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.tsx b/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.tsx deleted file mode 100644 index 59834b28e..000000000 --- a/src/apps/wallet-admin/src/lib/components/payment-method-table/PaymentMethodTable.tsx +++ /dev/null @@ -1,112 +0,0 @@ -/* eslint-disable max-len */ -/* eslint-disable react/jsx-no-bind */ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ -import React from 'react' - -import { Button, IconOutline, Tooltip } from '~/libs/ui' - -import { PaymentProvider } from '../../models/PaymentProvider' - -import styles from './PaymentMethodTable.module.scss' - -interface PaymentMethodTableProps { - paymentMethods: ReadonlyArray; - currentPage: number; - numPages: number; - onNextPageClick: () => void; - onPreviousPageClick: () => void; - onPageClick: (pageNumber: number) => void; - onDeleteClick?: (form: PaymentProvider) => void; -} - -const PaymentProviderTable: React.FC = (props: PaymentMethodTableProps) => ( - <> -
- - - - - - - - - - - - {props.paymentMethods.map(provider => ( - - - - - - - - ))} - -
HANDLECONNECTED PROVIDERPROVIDER IDSTATUS
{provider.handle}{provider.type}{provider.providerId === 'Legacy' ? provider.userId : provider.providerId}{provider.status} - -
-
- - {props.numPages > 1 && ( -
-
-
- {props.currentPage < props.numPages - 2 && ...} -
- - )} - -) - -export default PaymentProviderTable diff --git a/src/apps/wallet-admin/src/lib/components/payment-method-table/index.ts b/src/apps/wallet-admin/src/lib/components/payment-method-table/index.ts deleted file mode 100644 index 6fa841064..000000000 --- a/src/apps/wallet-admin/src/lib/components/payment-method-table/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PaymentMethodTable } from './PaymentMethodTable' diff --git a/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.module.scss b/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.module.scss deleted file mode 100644 index 5e4ea7c5a..000000000 --- a/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.module.scss +++ /dev/null @@ -1,109 +0,0 @@ -@import '@libs/ui/styles/includes'; - -.tableContainer { - width: 100%; - overflow-x: auto; - margin-top: $sp-2; -} - -table { - width: 100%; - border-collapse: separate; - border-spacing: 0; - margin: 16px 0; - - th, - td { - text-align: left; - padding: 8px; - - &:last-child { - width: 50px; - } - } - - tbody { - tr { - &:nth-child(odd) { - background-color: #f4f4f4; - } - &:nth-child(even) { - background-color: #ffffff; - } - - .capitalize { - text-transform: capitalize; - } - } - } - - th { - top: 0; - background-color: white !important; - text-transform: uppercase; - } - - tbody tr td:first-child { - border-top-left-radius: 8px; - border-bottom-left-radius: 8px; - } - - tbody tr td:last-child { - border-top-right-radius: 8px; - border-bottom-right-radius: 8px; - } - -} - -.selected { - background-color: #e7f4ff; -} - -.pageButtons { - display: flex; - justify-content: flex-end; - align-items: center; - margin-top: 16px; - gap: $sp-4; - - .pageNumbers { - display: flex; - justify-content: center; - align-items: center; - gap: $sp-1; - } - -} - -.footer { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: center; - margin-top: 16px; - padding-bottom: 16px; - border-radius: 8px; - background-color: white; - border: 1px solid #eaeaea; - - .total { - font-size: 18px; - font-weight: bold; - - color: #333; - } -} - -.actionButtons { - padding-right: 50px; - display: flex; - justify-content: center; - align-items: center; -} - -@media (max-width: 768px) { - .footer { - flex-direction: column; - align-items: center; - } -} diff --git a/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.tsx b/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.tsx deleted file mode 100644 index 149be504a..000000000 --- a/src/apps/wallet-admin/src/lib/components/tax-forms-table/TaxFormTable.tsx +++ /dev/null @@ -1,123 +0,0 @@ -/* eslint-disable max-len */ -/* eslint-disable react/jsx-no-bind */ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ -import React from 'react' - -import { Button, IconOutline, Tooltip } from '~/libs/ui' - -import { TaxForm } from '../../models/TaxForm' - -import styles from './TaxFormTable.module.scss' - -interface TaxFormTableProps { - taxForms: ReadonlyArray; - currentPage: number; - numPages: number; - onNextPageClick: () => void; - onPreviousPageClick: () => void; - onPageClick: (pageNumber: number) => void; - onDownloadClick?: (form: TaxForm) => void; - onDeleteClick?: (form: TaxForm) => void; -} - -const TaxFormTable: React.FC = (props: TaxFormTableProps) => ( - <> -
- - - - - - - - - - - - {props.taxForms.map(form => ( - - - - - - - - ))} - -
HANDLEFORMDATE FILEDSTATUS
{form.handle}{form.taxForm.name}{form.dateFiled}{form.status} - -
-
- - {props.numPages > 1 && ( -
-
-
- {props.currentPage < props.numPages - 2 && ...} -
- - )} - -) - -export default TaxFormTable diff --git a/src/apps/wallet-admin/src/lib/components/tax-forms-table/index.ts b/src/apps/wallet-admin/src/lib/components/tax-forms-table/index.ts deleted file mode 100644 index f526c746a..000000000 --- a/src/apps/wallet-admin/src/lib/components/tax-forms-table/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as TaxFormTable } from './TaxFormTable' diff --git a/src/apps/wallet-admin/src/lib/services/wallet.ts b/src/apps/wallet-admin/src/lib/services/wallet.ts index 058c45824..7ba9d7a94 100644 --- a/src/apps/wallet-admin/src/lib/services/wallet.ts +++ b/src/apps/wallet-admin/src/lib/services/wallet.ts @@ -1,12 +1,12 @@ /* eslint-disable camelcase */ import { EnvironmentConfig } from '~/config' import { xhrDeleteAsync, xhrGetAsync, xhrPatchAsync, xhrPostAsync } from '~/libs/core' -import { getAsyncWithBlobHandling, postAsyncWithBlobHandling } from '~/libs/core/lib/xhr/xhr-functions/xhr.functions' +import { postAsyncWithBlobHandling } from '~/libs/core/lib/xhr/xhr-functions/xhr.functions' import { WalletDetails } from '../models/WalletDetails' -import { PaymentProvider } from '../models/PaymentProvider' -import { WinningDetail } from '../models/WinningDetail' import { TaxForm } from '../models/TaxForm' +import { WinningDetail } from '../models/WinningDetail' +import { PaymentProvider } from '../models/PaymentProvider' import { TransactionResponse } from '../models/TransactionId' import { PaginationInfo } from '../models/PaginationInfo' import { WinningsAudit } from '../models/WinningsAudit' @@ -26,25 +26,6 @@ export async function getWalletDetails(): Promise { return response.data } -export async function getUserPaymentProviders(): Promise { - const response = await xhrGetAsync>(`${baseUrl}/user/payment-methods`) - - if (response.status === 'error') { - throw new Error('Error fetching user payment providers') - } - - return response.data -} - -export async function getUserTaxFormDetails(): Promise { - const response = await xhrGetAsync>(`${baseUrl}/user/tax-forms`) - if (response.status === 'error') { - throw new Error('Error fetching user tax form details') - } - - return response.data -} - export async function fetchAuditLogs(paymentId: string): Promise { const response = await xhrGetAsync>(`${baseUrl}/admin/winnings/${paymentId}/audit`) @@ -94,61 +75,6 @@ export async function editPayment(updates: { return response.data } -export async function getTaxForms(limit: number, offset: number, userIds: string[]): Promise<{ - forms: TaxForm[], - pagination: PaginationInfo -}> { - const body = JSON.stringify({ - limit, - offset, - userIds, - }) - - const url = `${baseUrl}/admin/tax-forms` - const response = await xhrPostAsync>(url, body) - - if (response.status === 'error') { - throw new Error('Error fetching tax forms') - } - - if (response.data.forms === null || response.data.forms === undefined) { - response.data.forms = [] - } - - return response.data -} - -export async function getPaymentMethods(limit: number, offset: number, userIds: string[]): Promise<{ - paymentMethods: PaymentProvider[], - pagination: PaginationInfo -}> { - const body = JSON.stringify({ - limit, - offset, - userIds, - }) - - const url = `${baseUrl}/admin/payment-methods` - const response = await xhrPostAsync>(url, body) - - if (response.status === 'error') { - throw new Error('Error fetching payment methods') - } - - if (response.data.paymentMethods === null || response.data.paymentMethods === undefined) { - response.data.paymentMethods = [] - } - - return response.data - -} - export async function exportSearchResults(filters: Record): Promise { const url = `${baseUrl}/admin/winnings/export` @@ -181,33 +107,6 @@ export async function exportSearchResults(filters: Record): Pr } } -export async function downloadTaxForm(userId: string, taxFormId: string): Promise { - const url = `${baseUrl}/admin/tax-forms/${userId}/${taxFormId}/download` - try { - return await getAsyncWithBlobHandling(url) - } catch (err) { - throw new Error('Failed to download users tax-form.') - } -} - -export async function deleteTaxForm(userId: string, taxFormId: string): Promise { - const url = `${baseUrl}/admin/tax-forms/${userId}/${taxFormId}` - try { - return await xhrDeleteAsync(url) - } catch (err) { - throw new Error('Failed to delete users tax-form') - } -} - -export async function deletePaymentProvider(userId: string, providerId: number): Promise { - const url = `${baseUrl}/admin/payment-methods/${userId}/${providerId}` - try { - return await xhrDeleteAsync(url) - } catch (err) { - throw new Error('Failed to delete users payment provider') - } -} - // eslint-disable-next-line max-len export async function getPayments(limit: number, offset: number, filters: Record): Promise<{ winnings: WinningDetail[], @@ -310,60 +209,77 @@ export async function removePaymentProvider(type: string): Promise { - const body = JSON.stringify({ - taxForm, - userId, - }) - - const url = `${baseUrl}/user/tax-form` - const response = await xhrPostAsync>(url, body) +export async function getMemberHandle(userIds: string[]): Promise> { + const BATCH_SIZE = 50 - if (response.status === 'error') { - throw new Error('Error setting tax form') - } + const handleMap = new Map() - return response.data -} + for (let i = 0; i < userIds.length; i += BATCH_SIZE) { + const batch = userIds.slice(i, i + BATCH_SIZE) -export async function removeTaxForm(taxFormId: string): Promise { - const url = `${baseUrl}/user/tax-forms/${taxFormId}` - const response = await xhrDeleteAsync>(url) + const url = `${memberApiBaseUrl}?userIds=[${batch.join(',')}]&fields=handle,userId` + // eslint-disable-next-line no-await-in-loop + const response = await xhrGetAsync<{ handle: string, userId: number }[]>(url) - if (response.status === 'error') { - throw new Error('Error removing tax form') + response.forEach(member => { + handleMap.set(member.userId, member.handle) + }) } - return response.data + return handleMap } -export async function getRecipientViewURL(): Promise { - const url = `${baseUrl}/user/tax-form/view` - const response = await xhrGetAsync>(url) +// TODO: remove +export async function getTaxForms(limit: number, offset: number, userIds: string[]): Promise<{ + forms: TaxForm[], + pagination: PaginationInfo +}> { + const body = JSON.stringify({ + limit, + offset, + userIds, + }) + + const url = `${baseUrl}/admin/tax-forms` + const response = await xhrPostAsync>(url, body) if (response.status === 'error') { - throw new Error('Error removing tax form') + throw new Error('Error fetching tax forms') + } + + if (response.data.forms === null || response.data.forms === undefined) { + response.data.forms = [] } return response.data } -export async function getMemberHandle(userIds: string[]): Promise> { - const BATCH_SIZE = 50 - - const handleMap = new Map() +export async function getPaymentMethods(limit: number, offset: number, userIds: string[]): Promise<{ + paymentMethods: PaymentProvider[], + pagination: PaginationInfo +}> { + const body = JSON.stringify({ + limit, + offset, + userIds, + }) - for (let i = 0; i < userIds.length; i += BATCH_SIZE) { - const batch = userIds.slice(i, i + BATCH_SIZE) + const url = `${baseUrl}/admin/payment-methods` + const response = await xhrPostAsync>(url, body) - const url = `${memberApiBaseUrl}?userIds=[${batch.join(',')}]&fields=handle,userId` - // eslint-disable-next-line no-await-in-loop - const response = await xhrGetAsync<{ handle: string, userId: number }[]>(url) + if (response.status === 'error') { + throw new Error('Error fetching payment methods') + } - response.forEach(member => { - handleMap.set(member.userId, member.handle) - }) + if (response.data.paymentMethods === null || response.data.paymentMethods === undefined) { + response.data.paymentMethods = [] } - return handleMap + return response.data }