diff --git a/src/components/Orders/Modals/OrderProcessor/index.tsx b/src/components/Orders/Modals/OrderProcessor/index.tsx index f6e91cca..8094b4a5 100644 --- a/src/components/Orders/Modals/OrderProcessor/index.tsx +++ b/src/components/Orders/Modals/OrderProcessor/index.tsx @@ -18,7 +18,7 @@ import { useState } from 'react'; import { useSubmitExtrinsic } from '@/hooks/submitExtrinsic'; import { getBalanceString } from '@/utils/functions'; -import { ActionButton } from '@/components/Elements'; +import { ProgressButton } from '@/components/Elements'; import { useAccounts } from '@/contexts/account'; import { useRegionXApi, useRelayApi } from '@/contexts/apis'; @@ -198,24 +198,29 @@ export const OrderProcessorModal = ({ - + - - + ); diff --git a/src/contexts/orders/index.tsx b/src/contexts/orders/index.tsx index 6309379a..5900c5d9 100644 --- a/src/contexts/orders/index.tsx +++ b/src/contexts/orders/index.tsx @@ -112,7 +112,7 @@ const OrderProvider = ({ children }: Props) => { ...item, totalContribution: parseInt(item.contribution), contribution: await getContribution(item.orderId), - } as Order) + }) as Order ) ) ); diff --git a/src/hooks/order/processed.ts b/src/hooks/order/processed.ts index 677b1864..80f05f81 100644 --- a/src/hooks/order/processed.ts +++ b/src/hooks/order/processed.ts @@ -58,7 +58,7 @@ export const useProcessedOrders = () => { mask, account: seller, reward, - } as OrderItem) + }) as OrderItem ) ); } diff --git a/src/hooks/order/regions.ts b/src/hooks/order/regions.ts deleted file mode 100644 index 05e3a6e6..00000000 --- a/src/hooks/order/regions.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { useEffect, useState } from 'react'; - -import { fetchCocosRegions } from '@/apis'; -import { useAccounts } from '@/contexts/account'; -import { ApiResponse, Region } from '@/models'; - -export const useRegions = () => { - const [loading, setLoading] = useState(false); - const [data, setData] = useState([]); - const [isError, setError] = useState(false); - - const { - state: { activeAccount }, - } = useAccounts(); - - useEffect(() => { - const asyncFetchData = async () => { - setData([]); - setError(false); - setLoading(false); - - if (!activeAccount) return; - - try { - setLoading(true); - let finished = false; - let after: string | null = null; - - const result = []; - while (!finished) { - const res: ApiResponse = await fetchCocosRegions(after, { - status: { equalTo: 'unavailable' }, - account: { equalTo: activeAccount.address }, - }); - - const { - status, - data: { - regions: { nodes, pageInfo }, - }, - } = res; - if (status !== 200) break; - - if (nodes !== null) result.push(...nodes); - - finished = !pageInfo.hasNextPage; - after = pageInfo.endCursor; - } - if (!finished) { - setError(true); - } else { - setData( - result.map( - ({ begin, end, core, mask }) => - ({ - begin, - end, - core, - mask, - } as Region) - ) - ); - } - } catch { - setError(true); - } finally { - setLoading(false); - } - }; - asyncFetchData(); - }, [activeAccount]); - - return { - loading, - data, - isError, - }; -}; diff --git a/src/pages/orders/index.tsx b/src/pages/orders/index.tsx index b4987428..36fd1de7 100644 --- a/src/pages/orders/index.tsx +++ b/src/pages/orders/index.tsx @@ -5,7 +5,6 @@ import { CircularProgress, FormControlLabel, Paper, - Stack, Switch, Typography, useTheme, @@ -127,21 +126,7 @@ const OrderDashboard = () => { {ordersToShow.map((order: Order, index: number) => ( - - + - + + ))}