From 8f26aa870e12b6fc1cb0ccc387eaeca60fc91ce2 Mon Sep 17 00:00:00 2001 From: luxumbra Date: Mon, 17 Jul 2023 19:53:20 +0100 Subject: [PATCH] Added types for Dework item wrapper & heading --- .../Player/Section/PlayerDework.tsx | 233 +++++++++++------- 1 file changed, 150 insertions(+), 83 deletions(-) diff --git a/packages/web/components/Player/Section/PlayerDework.tsx b/packages/web/components/Player/Section/PlayerDework.tsx index 7199ed8c..06b0a6d7 100644 --- a/packages/web/components/Player/Section/PlayerDework.tsx +++ b/packages/web/components/Player/Section/PlayerDework.tsx @@ -1,5 +1,14 @@ -import { Box, ExternalLinkIcon, Image, Spinner, Text, VStack, Wrap, WrapItem } from '@metafam/ds'; -import {generateUUID} from '@metafam/utils'; +import { + Box, + ExternalLinkIcon, + Image, + Spinner, + Text, + VStack, + Wrap, + WrapItem, +} from '@metafam/ds'; +import { generateUUID } from '@metafam/utils'; import DeworkLogo from 'assets/integrationLogos/deworkLogo.png'; import { MetaLink } from 'components/Link'; import { ProfileSection } from 'components/Section/ProfileSection'; @@ -7,20 +16,42 @@ import { Player } from 'graphql/autogen/types'; import React, { useEffect, useMemo, useState } from 'react'; import { getDeworkData, processDeworkData } from 'utils/dework'; - type Props = { player: Player; isOwnProfile?: boolean; editing?: boolean; }; -export const DeworkSectionWrapper: React.FC = ({ children }: { children: React.ReactNode }) => ( - +type DeworkSectionWrapperProps = { + children: React.ReactNode; +}; + +type DeworkSectionHeadingProps = { + text: string; +}; + +export const DeworkSectionWrapper: React.FC = ({ + children, +}: { + children: React.ReactNode; +}) => ( + {children} ); -export const DeworkSectionHeading: React.FC = ({ text }: { text: string }) => ( +export const DeworkSectionHeading: React.FC = ({ + text, +}: { + text: string; +}) => ( {`${text}`} @@ -37,9 +68,9 @@ export const PlayerDework: React.FC = ({ useEffect(() => { const getData = async () => { setLoading(true); - await getDeworkData(player?.ethereumAddress).then((res: any) => - setDeworkData(res), - setLoading(false) + await getDeworkData(player?.ethereumAddress).then( + (res: any) => setDeworkData(res), + setLoading(false), ); }; getData(); @@ -53,87 +84,123 @@ export const PlayerDework: React.FC = ({ return ( - + {deworkData && processedData && !loading ? ( <> - - - {deworkData?.tasks.length} - - - - - ${(processedData.totalEarnedInUSDC / 10 ** 18).toFixed(2)} - - - - - {processedData?.tagGrouping.length > 0 ? ( - processedData?.tagGrouping.map((tag: Record, i: number) => { - const total: number = processedData?.tagGrouping.length; - if (i < 3) { - return ( - <> - - {tag.name} ({tag.count}) - - {i === 2 && {`+${total - 3} other`}} - - ); - } - return undefined; - }) - - ) : ( - No tasks - )} - - - - {processedData?.uniqueOrganisations.length > 0 ? ( - processedData?.uniqueOrganisations.map((org: Record, i: number) => { - const total: number = processedData?.uniqueOrganisations.length; - if (i < 3) { - return ( - <> - - {org.name} - - {i === 2 && {`+${total - 3} other`}} - - ); - } - return undefined; - }) - ) : ( - No organizations - )} + + + {deworkData?.tasks.length} - - ) : ( - + + + + ${(processedData.totalEarnedInUSDC / 10 ** 18).toFixed(2)} + + + + + {processedData?.tagGrouping.length > 0 ? ( + processedData?.tagGrouping.map( + (tag: Record, i: number) => { + const total: number = processedData?.tagGrouping.length; + if (i < 3) { + return ( + <> + + + {tag.name} + {' '} + ({tag.count}) + + {i === 2 && ( + {`+${ + total - 3 + } other`} + )} + + ); + } + return undefined; + }, + ) + ) : ( + No tasks + )} + + + + {processedData?.uniqueOrganisations.length > 0 ? ( + processedData?.uniqueOrganisations.map( + (org: Record, i: number) => { + const total: number = + processedData?.uniqueOrganisations.length; + if (i < 3) { + return ( + <> + + {org.name} + + {i === 2 && ( + {`+${total - 3} other`} + )} + + ); + } + return undefined; + }, + ) + ) : ( + No organizations + )} + + + ) : ( + - ) - } - Dework logo - {deworkData && ( - See complete profile on Dework - )} + )} + Dework logo + {deworkData && ( + + See complete profile on Dework + + )} ); }; - - -