diff --git a/package.json b/package.json index fd93c34e..80385274 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adex-interface", - "version": "0.69.49", + "version": "0.69.61", "private": true, "dependencies": { "@ambire/login-sdk-core": "^0.0.21", diff --git a/public/robots.txt b/public/robots.txt index b21f0887..349360ba 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,3 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * -Disallow: / +Allow: / diff --git a/src/App.tsx b/src/App.tsx index 7bef28f3..f34dd163 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,11 +29,8 @@ function GlobalStyles() { ({ [theme.other.media.print]: { - body: { - visibility: 'hidden' - }, - 'body #printable': { - visibility: 'visible' + '#root': { + display: 'none' } } })} diff --git a/src/Router.tsx b/src/Router.tsx index 2fefde81..fa7aea58 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -6,7 +6,7 @@ import Billing from 'components/Billing' import GetStarted from 'components/GetStarted' import CampaignAnalytics from 'components/CampaignAnalytics' import { createBrowserRouter, Navigate, useLocation, useRouteError, Link } from 'react-router-dom' -import { Button } from '@mantine/core' +import { Button, Loader, Center } from '@mantine/core' import useAccount from 'hooks/useAccount' import Deposit from 'components/Deposit' @@ -33,14 +33,27 @@ function ErrorBoundary() { } function RequireAuth({ children, admin }: { children: JSX.Element; admin?: boolean }) { - const { authenticated, isAdmin } = useAccount() + const { + authenticated, + isAdmin, + adexAccount: { loaded } + } = useAccount() + const location = useLocation() + if (!loaded) { + return ( +
+ +
+ ) + } + if (!authenticated) { return } - if (admin && isAdmin) { + if (admin && !isAdmin) { return } @@ -107,7 +120,7 @@ export const router = createBrowserRouter( { path: 'admin/:tabValue', element: ( - + diff --git a/src/components/AdminPanel/AccountDetails.tsx b/src/components/AdminPanel/AccountDetails.tsx index 7bbc9a0e..6544f242 100644 --- a/src/components/AdminPanel/AccountDetails.tsx +++ b/src/components/AdminPanel/AccountDetails.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo } from 'react' -import { SimpleGrid, Box, Title, Paper, Loader, Center } from '@mantine/core' +import { SimpleGrid, Box, Loader, Center, Fieldset } from '@mantine/core' import useAdmin from 'hooks/useAdmin' import { useParams } from 'react-router-dom' import Dashboard from 'components/Dashboard' @@ -39,34 +39,22 @@ function AccountDetails() { // { maxWidth: 'md', cols: 1, spacing: 'xl' } // ]} > - - - Account info form - +
- - - - Deposit form - +
+
- +
- - - Activity - +
- +
- - - Campaigns - +
- +
) diff --git a/src/components/AdminPanel/AccountDetailsElements.tsx b/src/components/AdminPanel/AccountDetailsElements.tsx index f9a3af93..af1d0e7f 100644 --- a/src/components/AdminPanel/AccountDetailsElements.tsx +++ b/src/components/AdminPanel/AccountDetailsElements.tsx @@ -2,12 +2,12 @@ import { useMemo } from 'react' import { Account } from 'types' import { Box, Text, MantineColor } from '@mantine/core' -import CustomTable, { TableElement } from 'components/common/CustomTable' +import CustomTable, { DataElement } from 'components/common/CustomTable' import { parseBigNumTokenAmountToDecimal, toOperationEntry } from 'helpers' export const FundsActivity = ({ accountData }: { accountData: Account }) => { const elements = useMemo(() => { - const data: TableElement['elements'] = [ + const data: DataElement[] = [ ...accountData.fundsDeposited.deposits.map((x) => toOperationEntry('deposit', x)), ...accountData.fundsOnCampaigns.perCampaign.map((x) => toOperationEntry('campaignOpen', x)), ...accountData.refundsFromCampaigns.perCampaign.map((x) => @@ -16,21 +16,32 @@ export const FundsActivity = ({ accountData }: { accountData: Account }) => { ] .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) - .map((x) => { + .map((x, i) => { const sign = x.type === 'campaignOpen' ? '-' : '+' const color: MantineColor = sign === '-' ? 'darkred' : 'darkgreen' return { - name: {`${sign} ${x.name}`}, - date: x.date?.toLocaleDateString() || '', - amount: ( - {`${sign} ${parseBigNumTokenAmountToDecimal( - x.amount, - x.token.decimals - )}`} - ), + id: x.id + i, + columns: [ + { + value: x.type, + element: {`${sign} ${x.name}`} + }, + { value: x.date.getTime(), element: x.date?.toLocaleDateString() || '' }, + { + value: Number(x.amount), + element: ( + {`${sign} ${parseBigNumTokenAmountToDecimal(x.amount, x.token.decimals)}`} + ) + }, - token: x.token.name, - actionId: x.id + { value: x.token.name }, + { value: x.id } + ] } }) @@ -43,7 +54,8 @@ export const FundsActivity = ({ accountData }: { accountData: Account }) => { diff --git a/src/components/AdminPanel/Accounts.tsx b/src/components/AdminPanel/Accounts.tsx index 6a214f45..f48cf231 100644 --- a/src/components/AdminPanel/Accounts.tsx +++ b/src/components/AdminPanel/Accounts.tsx @@ -1,8 +1,8 @@ import { useEffect, useMemo, useCallback, useState } from 'react' import { useNavigate } from 'react-router-dom' -import { Loader, Box, Badge, TextInput, Stack, Group } from '@mantine/core' +import { Box, Badge, TextInput, Stack, Group, LoadingOverlay } from '@mantine/core' -import CustomTable from 'components/common/CustomTable' +import CustomTable, { DataElement } from 'components/common/CustomTable' import useAdmin from 'hooks/useAdmin' import VisibilityIcon from 'resources/icons/Visibility' @@ -49,7 +49,7 @@ const AdminAnalytics = () => { ).toLocaleString() const totalAccounts = accArr.length - const elements = accArr + const elements: DataElement[] = accArr .filter((x) => ( x.name + @@ -80,19 +80,33 @@ const AdminAnalytics = () => { .map((a) => { return { id: a.id, - accountId: a.name || a.id, - verified: a?.billingDetails?.verified ? '✅' : '❌', - email: a.info?.email, - balance: parseBigNumTokenAmountToDecimal( - a.availableBalance, - a.balanceToken.decimals - ).toFixed(2), - campaigns: a.fundsOnCampaigns.perCampaign.length, - fudsOnCampaigns: parseBigNumTokenAmountToDecimal( - a.fundsOnCampaigns.total - a.refundsFromCampaigns.total, - a.balanceToken.decimals - ).toFixed(2), - created: new Date(a.created).toLocaleDateString() + columns: [ + { value: a.name || a.id }, + { + value: a?.billingDetails?.verified ? 1 : 0, + element: a?.billingDetails?.verified ? '✅' : '❌' + }, + { value: a.info?.email || '' }, + { + value: a.availableBalance, + element: parseBigNumTokenAmountToDecimal( + a.availableBalance, + a.balanceToken.decimals + ).toFixed(2) + }, + { value: a.fundsOnCampaigns.perCampaign.length }, + { + value: a.fundsOnCampaigns.total - a.refundsFromCampaigns.total, + element: parseBigNumTokenAmountToDecimal( + a.fundsOnCampaigns.total - a.refundsFromCampaigns.total, + a.balanceToken.decimals + ).toFixed(2) + }, + { + value: new Date(a.created).getTime(), + element: new Date(a.created).toLocaleDateString() + } + ] } }) @@ -125,11 +139,10 @@ const AdminAnalytics = () => { ] }, [handlePreview]) - return initialDataLoading ? ( - - ) : ( + return ( - + + Totals: ({data.totalAccounts}) @@ -148,7 +161,13 @@ const AdminAnalytics = () => { miw={420} /> - + ) } diff --git a/src/components/AdminPanel/AccoutInfo.tsx b/src/components/AdminPanel/AccoutInfo.tsx index 9c0bea9b..bbcd3f67 100644 --- a/src/components/AdminPanel/AccoutInfo.tsx +++ b/src/components/AdminPanel/AccoutInfo.tsx @@ -1,7 +1,17 @@ import { useMemo, useCallback, useState } from 'react' import { hasLength, matches, useForm, isEmail } from '@mantine/form' -import { Button, Group, TextInput, Box, NumberInput, Text, Textarea, Switch } from '@mantine/core' +import { + Button, + Group, + TextInput, + Box, + NumberInput, + Text, + Textarea, + Switch, + Stack +} from '@mantine/core' import throttle from 'lodash.throttle' import { Account } from 'types' @@ -43,7 +53,7 @@ function AccountInfo({ accountData }: { accountData: Account }) { showNotification('info', 'Account data updated!') }, (err) => { - showNotification('error', err, 'Error on account Account data updated!') + showNotification('error', err.toString(), 'Error on account Account data updated!') } ) @@ -74,76 +84,93 @@ function AccountInfo({ accountData }: { accountData: Account }) { disabled {...form.getInputProps('availableBalance')} /> - - Billing details - - * Just for info, users can edit, admins can verify only - - - - - - - + + + Billing details + + * Just for info, users can edit, admins can verify only - + + + + + + + + + + + + + + + + - - - - Additional info - - * can be seen and edited only by admins - - - - + + + + Additional info + + * can be seen and edited only by admins + + + +