diff --git a/src/app/dashboard/admin/page.tsx b/src/app/dashboard/admin/page.tsx new file mode 100644 index 0000000..dfd8565 --- /dev/null +++ b/src/app/dashboard/admin/page.tsx @@ -0,0 +1,7 @@ +export default function AdminPage() { + return (<> +
+

Welcome to the Dashboard

+
+ ) +} \ No newline at end of file diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx new file mode 100644 index 0000000..53e2284 --- /dev/null +++ b/src/app/dashboard/page.tsx @@ -0,0 +1,44 @@ +"use client" + +import type {ICryptoInWalletInfo} from "@/interfaces/crypto.interface"; +import {CryptosTable} from "@/components/data-tables/cryptos-table"; +import {useEffect, useState} from "react"; +import {Skeleton} from "@/components/ui/skeleton"; +import ApiRequest from "@/services/apiRequest"; +import type {IApiAllOffersRes} from "@/interfaces/api.interface"; + + +export default function DashboardPage() { + const [isLoading, setIsLoading] = useState(true) + const [cryptosList, setCryptosList] = useState([]) + //FIX the loop + + useEffect(() => { + ApiRequest.authenticated.get.json( + "crypto/all" + ).then((response)=>{ + if (response.data.length <= 0) { + setCryptosList([]) + setIsLoading(false) + return + } + const resp = response.data + setCryptosList(resp) + setIsLoading(false) + }) + }, []); + + if (isLoading) { + return (
+

Available cryptos

+ +
) + } + + return (<> +
+

Available cryptos

+ +
+ ) +} \ No newline at end of file diff --git a/src/app/wallet/page.tsx b/src/app/wallet/page.tsx new file mode 100644 index 0000000..e3eb508 --- /dev/null +++ b/src/app/wallet/page.tsx @@ -0,0 +1,40 @@ +"use client" + +import type {ICryptoInWalletInfo} from "@/interfaces/crypto.interface"; +import {CryptosTable} from "@/components/data-tables/cryptos-table"; +import {useContext, useEffect, useState} from "react"; +import {Skeleton} from "@/components/ui/skeleton"; +import ApiRequest from "@/services/apiRequest"; +import type {IApiAllOffersRes} from "@/interfaces/api.interface"; +import {WalletTable} from "@/components/data-tables/wallet-table"; +import {UserDataContext} from "@/components/providers/userdata-provider"; +import {IUserWallet} from "@/interfaces/userdata.interface"; + + +export default function WalletPage() { + const [isLoading, setIsLoading] = useState(true) + const [cryptosList, setCryptosList] = useState([]) + const userContext = useContext(UserDataContext); + //FIX the loop + + useEffect(() => { + console.log(userContext?.userData) + if (userContext?.userData) { + setIsLoading(false) + } + }, [userContext]); + + if (isLoading || !userContext?.userData) { + return (
+

Cryptos in your wallet

+ +
) + } + + return (<> +
+

Cryptos in your wallet

+ +
+ ) +} \ No newline at end of file