From c47703587ab168bcc78f4b7f1970f3f07dcf440e Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Thu, 9 Jan 2025 16:05:43 -0500 Subject: [PATCH] chore(client): remove dead code (#569) Signed-off-by: Chris Gianelloni --- client/src/components/Menu/cardano.tsx | 28 --- client/src/components/Menu/ergo.tsx | 24 --- client/src/components/Projects/Logo/index.tsx | 25 --- .../src/components/Projects/Project/index.tsx | 45 ----- client/src/components/Projects/URLs/index.tsx | 39 ---- client/src/entities/dto.ts | 5 - client/src/entities/project.entities.ts | 40 ---- client/src/hooks/cardano/pools/usePools.tsx | 33 ---- .../hooks/cardano/projects/useProjects.tsx | 31 --- client/src/layouts/RouterWrapper/index.tsx | 8 - client/src/pages/Cardano/Pools/index.tsx | 30 --- client/src/pages/Cardano/Projects/index.tsx | 22 --- client/src/pages/Dashboard/index.tsx | 177 ------------------ client/src/pages/Feedback/index.tsx | 50 ----- client/src/services/common.ts | 13 +- 15 files changed, 1 insertion(+), 569 deletions(-) delete mode 100644 client/src/components/Projects/Logo/index.tsx delete mode 100644 client/src/components/Projects/Project/index.tsx delete mode 100644 client/src/components/Projects/URLs/index.tsx delete mode 100644 client/src/entities/project.entities.ts delete mode 100644 client/src/hooks/cardano/pools/usePools.tsx delete mode 100644 client/src/hooks/cardano/projects/useProjects.tsx delete mode 100644 client/src/pages/Cardano/Pools/index.tsx delete mode 100644 client/src/pages/Cardano/Projects/index.tsx delete mode 100644 client/src/pages/Dashboard/index.tsx delete mode 100644 client/src/pages/Feedback/index.tsx diff --git a/client/src/components/Menu/cardano.tsx b/client/src/components/Menu/cardano.tsx index e6edbb47..1721ded3 100644 --- a/client/src/components/Menu/cardano.tsx +++ b/client/src/components/Menu/cardano.tsx @@ -9,11 +9,7 @@ import { faArrowUpRightFromSquare, faBook, faClockRotateLeft, - // faCubesStacked, - // faMessage, - // faProjectDiagram, faWallet, - // faTableColumns, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Link, useLocation } from "react-router-dom"; @@ -64,30 +60,6 @@ export const menuItems: Record = { activeRoute: [PageRoute.historyCardano], icon: faClockRotateLeft, }, - // projects: { - // text: "Projects", - // to: PageRoute.projectsCardano, - // activeRoute: [PageRoute.projectsCardano], - // icon: faProjectDiagram, - // }, - // pools: { - // text: "Stake Pools", - // to: PageRoute.poolsCardano, - // activeRoute: [PageRoute.poolsCardano], - // icon: faCubesStacked, - // }, - /// dashboard: { - /// text: "Dashboard", - /// to: PageRoute.dashboardCardano, - /// activeRoute: [PageRoute.dashboardCardano], - /// icon: faTableColumns, - /// }, - // feedback: { - // text: "Feedback", - // to: PageRoute.feedback, - // activeRoute: [PageRoute.feedback], - // icon: faMessage, - // }, }; export default function MenuCardano() { diff --git a/client/src/components/Menu/ergo.tsx b/client/src/components/Menu/ergo.tsx index a6d3205c..28f42ad2 100644 --- a/client/src/components/Menu/ergo.tsx +++ b/client/src/components/Menu/ergo.tsx @@ -47,30 +47,6 @@ export const socialMediaItems: Record = { }; export const menuItems: Record = { - // claim: { - // text: "Claim", - // to: PageRoute.claimCardano, - // activeRoute: [PageRoute.claimCardano, PageRoute.depositCardano], - // icon: faWallet, - // }, - // // history: { - // // text: "History", - // // to: PageRoute.history, - // // activeRoute: [PageRoute.history], - // // icon: faClockRotateLeft, - // // }, - // projects: { - // text: "Projects", - // to: PageRoute.projectsCardano, - // activeRoute: [PageRoute.projectsCardano], - // icon: faProjectDiagram, - // }, - // /*dashboard: { - // text: "Dashboard", - // to: PageRoute.dashboardCardano, - // activeRoute: [PageRoute.dashboardCardano], - // icon: faTableColumns, - // },*/ feedback: { text: "Feedback", to: PageRoute.feedback, diff --git a/client/src/components/Projects/Logo/index.tsx b/client/src/components/Projects/Logo/index.tsx deleted file mode 100644 index 4462dd6d..00000000 --- a/client/src/components/Projects/Logo/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useSelector } from "react-redux"; -import { Themes } from "src/entities/common.entities"; -import { ProjectLogos } from "src/entities/project.entities"; -import { RootState } from "src/store"; - -const Logo = ({ projectLogos }: { projectLogos: ProjectLogos }) => { - const theme = useSelector((state: RootState) => state.global.theme); - - let logo = projectLogos.logoDefault; - let compactLogo = projectLogos.logoCompact ?? projectLogos.logoDefault; - if (theme === Themes.dark) { - if (projectLogos.logoDark) logo = projectLogos.logoDark; - if (projectLogos.logoCompactDark) - compactLogo = projectLogos.logoCompactDark; - } - - return ( -
- logo - logo -
- ); -}; - -export default Logo; diff --git a/client/src/components/Projects/Project/index.tsx b/client/src/components/Projects/Project/index.tsx deleted file mode 100644 index 2ddaa58e..00000000 --- a/client/src/components/Projects/Project/index.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { ProjectData } from "src/entities/project.entities"; -import Logo from "../Logo"; -import URLs from "../URLs"; - -const Project = ({ projectData }: { projectData: ProjectData }) => { - return ( -
-
-
- - - -
-
-
{projectData.descs.descShort}
-
-
- -
- -
-
- Token: -
{projectData.token.token}
-
-
- Total Supply: -
- {projectData.token.totalSupply?.toLocaleString("en-US") ?? "?"} -
-
-
- -
-
-
- ); -}; - -export default Project; diff --git a/client/src/components/Projects/URLs/index.tsx b/client/src/components/Projects/URLs/index.tsx deleted file mode 100644 index c715f19b..00000000 --- a/client/src/components/Projects/URLs/index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { IconProp } from "@fortawesome/fontawesome-svg-core"; -import { - faDiscord, - faMedium, - faTelegram, - faTwitter, -} from "@fortawesome/free-brands-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { ProjectURLs } from "src/entities/project.entities"; - -const URLs = ({ projectURLs }: { projectURLs: ProjectURLs }) => { - const render = (icon: IconProp, style: string, url?: string) => { - return url ? ( - - - - ) : null; - }; - - const medium = render(faMedium, "text-medium", projectURLs.medium); - const twitter = render(faTwitter, "text-twitter", projectURLs.twitter); - const discord = render(faDiscord, "text-discord", projectURLs.discord); - const telegram = render(faTelegram, "text-telegram", projectURLs.telegram); - const cardanoScan = null; - const poolpm = null; - - return ( -
- {medium} - {twitter} - {discord} - {telegram} - {cardanoScan} - {poolpm} -
- ); -}; - -export default URLs; diff --git a/client/src/entities/dto.ts b/client/src/entities/dto.ts index d048f50c..ad126053 100644 --- a/client/src/entities/dto.ts +++ b/client/src/entities/dto.ts @@ -27,11 +27,6 @@ export interface GetQueueDto { pending_tx: number; } -export interface GetPoolsDto { - whitelistedPools: PoolInfo[]; - regularPools: PoolInfo[]; -} - export interface GetDeliveredRewardsDto { deliveredRewards: DeliveredReward[]; } diff --git a/client/src/entities/project.entities.ts b/client/src/entities/project.entities.ts deleted file mode 100644 index eb07e975..00000000 --- a/client/src/entities/project.entities.ts +++ /dev/null @@ -1,40 +0,0 @@ -export interface ProjectURLs { - website?: string; - medium?: string; - twitter?: string; - discord?: string; - telegram?: string; - paper?: string; - docs?: string; - github?: string; - cardanoScan?: string; - poolpm?: string; -} - -export interface ProjectLogos { - logoDefault: string; - logoDark?: string; - logoCompact?: string; - logoCompactDark?: string; -} - -export interface ProjectDescs { - descShort: string; - descLong?: string; - claimDesc?: string; -} - -export interface ProjectTokenInfo { - token: string; - totalSupply?: number; - policyID: string; - //marketCap: number; //Need to pull this info dynamically, will likely be a method instead of an member - //fdMarketCap: number; //Need to pull this info dynamically, will likely be a method instead of an member -} - -export interface ProjectData { - logos: ProjectLogos; - descs: ProjectDescs; - token: ProjectTokenInfo; - urls: ProjectURLs; -} diff --git a/client/src/hooks/cardano/pools/usePools.tsx b/client/src/hooks/cardano/pools/usePools.tsx deleted file mode 100644 index 5bd0607b..00000000 --- a/client/src/hooks/cardano/pools/usePools.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useEffect, useState } from "react"; -import { GetPoolsDto } from "src/entities/dto"; -import useErrorHandler from "src/hooks/useErrorHandler"; -import { getPools } from "src/services/common"; - -export default function usePools() { - const [loading, setLoading] = useState(true); - const [pools, setPools] = useState({ - whitelistedPools: [], - regularPools: [], - }); - const { handleError } = useErrorHandler(); - - useEffect(() => { - const fetchPools = async () => { - try { - const getPoolsData = await getPools(); - setPools(getPoolsData); - } catch (error) { - handleError(error); - } finally { - setLoading(false); - } - }; - fetchPools(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return { - pools, - loading, - }; -} diff --git a/client/src/hooks/cardano/projects/useProjects.tsx b/client/src/hooks/cardano/projects/useProjects.tsx deleted file mode 100644 index 44b8f0e9..00000000 --- a/client/src/hooks/cardano/projects/useProjects.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useEffect, useState } from "react"; -import { ProjectData } from "src/entities/project.entities"; -import useErrorHandler from "src/hooks/useErrorHandler"; -import { getProjects } from "src/services/common"; - -export default function useProjects() { - const [loading, setLoading] = useState(true); - const [projects, setProjects] = useState([]); - const { handleError } = useErrorHandler(); - - const getProjectsFromAPI = async () => { - try { - const projects = await getProjects(); - setProjects(projects); - } catch (error) { - handleError(error); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - getProjectsFromAPI(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return { - projects, - loading, - }; -} diff --git a/client/src/layouts/RouterWrapper/index.tsx b/client/src/layouts/RouterWrapper/index.tsx index b5a8a3dc..e9faa5c7 100644 --- a/client/src/layouts/RouterWrapper/index.tsx +++ b/client/src/layouts/RouterWrapper/index.tsx @@ -4,11 +4,7 @@ import { PageRoute } from "src/entities/common.entities"; import Claim from "src/pages/Cardano/Claim"; import ClaimHistory from "src/pages/Cardano/ClaimHistory"; import DepositInfoPage from "src/pages/Cardano/Deposit"; -// import Pools from "src/pages/Cardano/Pools"; -// import Projects from "src/pages/Cardano/Projects"; import ComingSoonPage from "src/pages/ComingSoon"; -// import Dashboard from "src/pages/Dashboard"; -// import Feedback from "src/pages/Feedback"; import { RootState } from "src/store"; export default function RouterWrapper() { @@ -20,10 +16,6 @@ export default function RouterWrapper() { } /> } /> } /> - {/* Disabled routes } /> - } /> - } /> - } /> */} {ergoEnabled ? ( } /> diff --git a/client/src/pages/Cardano/Pools/index.tsx b/client/src/pages/Cardano/Pools/index.tsx deleted file mode 100644 index 926ff069..00000000 --- a/client/src/pages/Cardano/Pools/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import Pool from "src/components/Pool"; -import usePools from "src/hooks/cardano/pools/usePools"; -import Loading from "src/pages/Loading"; - -const Pools = () => { - const { pools, loading } = usePools(); - - return loading ? ( - - ) : ( - <> -

Participating Pools

-
-

- Stake to TosiDrop team pools to support the devs and pay no TosiFee on - claims -

- {pools.whitelistedPools.map((pool) => ( - - ))} -

CSPA pools registered with VM

- {pools.regularPools.map((pool) => ( - - ))} -
- - ); -}; - -export default Pools; diff --git a/client/src/pages/Cardano/Projects/index.tsx b/client/src/pages/Cardano/Projects/index.tsx deleted file mode 100644 index 5572c1fd..00000000 --- a/client/src/pages/Cardano/Projects/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import Project from "src/components/Projects/Project"; -import useProjects from "src/hooks/cardano/projects/useProjects"; -import Loading from "src/pages/Loading"; - -const Projects = () => { - const { projects, loading } = useProjects(); - - return loading ? ( - - ) : ( - <> -

Explore TosiDrop Projects

-
- {projects.map((project, i) => { - return ; - })} -
- - ); -}; - -export default Projects; diff --git a/client/src/pages/Dashboard/index.tsx b/client/src/pages/Dashboard/index.tsx deleted file mode 100644 index dabd0aac..00000000 --- a/client/src/pages/Dashboard/index.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import React, { useState, useEffect } from "react"; -import Spinner from "../../components/Spinner"; - -type Countdown = { - days: number | null; - hours: number | null; - minutes: number | null; -}; - -function Dashboard() { - const [assetData, setAssetData] = useState(null); - const [priceData, setPriceData] = useState(null); - const [isLoading, setIsLoading] = useState(true); - const [countdown, setCountdown] = useState({ - days: null, - hours: null, - minutes: null, - }); - - useEffect(() => { - const calculateCountdown = () => { - const today = new Date(); - - function getNextFiveDayInterval() { - const baseDate = new Date(Date.UTC(2024, 1, 14, 21, 45)); - const difference = today.getTime() - baseDate.getTime(); - const intervalsSinceBase = Math.floor( - difference / (5 * 24 * 60 * 60 * 1000), - ); - - const nextInterval = - baseDate.getTime() + intervalsSinceBase * (5 * 24 * 60 * 60 * 1000); - const soonestDate = new Date(nextInterval + 5 * 24 * 60 * 60 * 1000); - - return soonestDate; - } - - // Get the soonest upcoming date in the 5-day interval based on today's date - const nextFiveDayInterval = getNextFiveDayInterval(); - const timeDifference = nextFiveDayInterval.getTime() - today.getTime(); - const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); - const hoursDifference = Math.floor( - (timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60), - ); - const minutesDifference = Math.floor( - (timeDifference % (1000 * 60 * 60)) / (1000 * 60), - ); - - setCountdown({ - days: daysDifference, - hours: hoursDifference, - minutes: minutesDifference, - }); - }; - - calculateCountdown(); - - const interval = setInterval(calculateCountdown, 60000); - - return () => clearInterval(interval); - }, []); - - useEffect(() => { - const fetchPriceData = async () => { - try { - const response = await fetch( - "https://dexhunter.sbase.ch/swap/averagePrice/ADA/a8a1dccea2e378081f2d500d98d022dd3c0bd77afd9dbc7b55a9d21b63544f5349", - { - headers: { - accept: "application/json", - "X-Partner-Id": - "tosidrop616464723171396b347435723668783279366577636b65746a6b6167376e736e79643539747278326e72376d7435396c34737138386568717166666e70616c6d74666d736c6d6e707a6764776b643979717132663464653566326371716e733373676d6d74766cda39a3ee5e6b4b0d3255bfef95601890afd80709", - }, - }, - ); - const jsonData = await response.json(); - setPriceData(jsonData.price_ba * 1000000000); - } catch (error) { - console.error("Error fetching price data:", error); - } - }; - - const fetchData = async () => { - try { - setIsLoading(true); - await fetchPriceData(); - await setIsLoading(false); - } catch (error) { - console.error("Error fetching data:", error); - setIsLoading(false); - } - }; - - fetchData(); - }, []); - - const analyticsFields = [ - { - header: "cTOSI Holders", - value: "-", - }, - { - header: "Community Revenue", - value: null, - }, - { - header: "Your cTOSI Staked", - value: null, - }, - { - header: "Total Claims", - value: "-", - }, - { - header: "Market Cap", - value: priceData ? `${Math.round(priceData).toLocaleString()} ADA` : "-", - }, - { - header: "Total cTOSI Staked", - value: null, - }, - ]; - - return isLoading ? ( - - ) : ( - <> -

Dashboard

-
- {countdown.days != null && ( -

- Time to next epoch (360): {countdown.days}d {countdown.hours}h{" "} - {countdown.minutes}m -

- )} -
- -
-
-
-
-

Analytics

-
-
- {priceData && ( -
- {analyticsFields.map((field, index) => ( -
- - {field.header} - - {field.value !== null ? ( - - {field.value} - - ) : ( - - Coming Soon - - )} -
- ))} -
- )} -
- - ); -} - -export default Dashboard; diff --git a/client/src/pages/Feedback/index.tsx b/client/src/pages/Feedback/index.tsx deleted file mode 100644 index efcc2df3..00000000 --- a/client/src/pages/Feedback/index.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { faDiscord, faTelegram } from "@fortawesome/free-brands-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; - -function Feedback() { - return ( - - ); -} - -export default Feedback; diff --git a/client/src/services/common.ts b/client/src/services/common.ts index 85b2fd7b..a2c57dd4 100644 --- a/client/src/services/common.ts +++ b/client/src/services/common.ts @@ -1,9 +1,8 @@ import axios from "axios"; import { CardanoTypes } from "src/entities/cardano"; import { PopUpInfo } from "src/entities/common.entities"; -import { Dto, GetPoolsDto, GetQueueDto } from "src/entities/dto"; +import { Dto, GetQueueDto } from "src/entities/dto"; import { EpochParams, Tip } from "src/entities/koios.entities"; -import { ProjectData } from "src/entities/project.entities"; const API_URL = process.env.REACT_APP_CLAIM_API || "http://localhost:3000" @@ -50,21 +49,11 @@ export async function getNetworkId(): Promise { return CardanoTypes.NetworkId.undefined; } -export async function getProjects(): Promise { - const response = await axios.get(`${API_URL}/api/getprojects`); - return response.data; -} - export async function getPopUpInfo(): Promise { const response = await axios.get(`${API_URL}/api/getpopupinfo`); return response.data; } -export async function getPools(): Promise { - const response = await axios.get(`${API_URL}/api/getpools`); - return response.data; -} - export async function getTip(): Promise { const response = await axios.get(`${API_URL}/api/gettip`); return response.data;