diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..487a28b --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +NEXT_PUBLIC_BASE_API_URL='https://api-dev.testudo.xyz' diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} diff --git a/api/auth/authApi.ts b/api/auth/authApi.ts new file mode 100644 index 0000000..28ac749 --- /dev/null +++ b/api/auth/authApi.ts @@ -0,0 +1,28 @@ +import { + GoogleCallbackResponse, + NautilusBodyRequest, + NautilusResponse, + ErgoPayResponse, + ErgoPayRequestParameter, + GoogleCallbackRequestParameter, + UserInfoResponse, +} from '@/api/auth/authApi.types'; +import { httpClient } from '@/utils/http-client'; + +export const authApi = { + googleCallback: async ( + parameter: GoogleCallbackRequestParameter, + ): Promise => + httpClient.get(`/auth/google/callback?code=${parameter.code}`), + + nautilus: async (body: NautilusBodyRequest): Promise => + httpClient.post(`/auth/nautilus`, body), + + ergoPay: async ({ + address, + }: ErgoPayRequestParameter): Promise => + httpClient.get(`/ergopay/${address}`), // should be ergoauth://localhost/auth/ergopay/:address + + userInfo: async (token: string | null): Promise => + httpClient.get(`/auth/getUserInfo`, undefined, token), +}; diff --git a/api/auth/authApi.types.ts b/api/auth/authApi.types.ts new file mode 100644 index 0000000..990a3ab --- /dev/null +++ b/api/auth/authApi.types.ts @@ -0,0 +1,47 @@ +import { ApiResponse, ApiError } from '@/utils/types'; + +export interface GoogleCallbackRequestParameter { + code?: string; +} + +export type SignInSuccessResponse = { + token: string; +}; + +export type GoogleCallbackResponse = SignInSuccessResponse | ApiError; + +export interface NautilusBodyRequest { + proof?: string; + message?: string; + address?: string; +} + +export type NautilusResponse = SignInSuccessResponse | ApiError; + +export interface ErgoPayRequestParameter { + address: string; +} + +export type ErgoPaySuccessResponse = ApiResponse<{ + status: number; +}>; + +export type ErgoPayResponse = ErgoPaySuccessResponse | ApiError; + +export type UserInfoSuccessResponse = { + user: { + id: string; + email: string; + firstName: string; + lastName: string; + picture: string; + } | null; + addresses: + | { + id: string; + sign_message: string; + }[] + | undefined; +}; + +export type UserInfoResponse = UserInfoSuccessResponse | ApiError; diff --git a/api/auth/index.ts b/api/auth/index.ts new file mode 100644 index 0000000..bd3c620 --- /dev/null +++ b/api/auth/index.ts @@ -0,0 +1,49 @@ +import { useQuery } from '@tanstack/react-query'; + +import { authApi } from '@/api/auth/authApi'; +import { + SignInSuccessResponse, + GoogleCallbackResponse, + NautilusBodyRequest, + NautilusResponse, + ErgoPaySuccessResponse, + ErgoPayResponse, + ErgoPayRequestParameter, + GoogleCallbackRequestParameter, + UserInfoSuccessResponse, + UserInfoResponse, +} from '@/api/auth/authApi.types'; +import { queryKeys } from '@/utils/react-query-keys'; +import { ApiError } from '@/utils/types'; + +export const authApiGateway = { + useGoogleCallback: (parameter: GoogleCallbackRequestParameter) => + useQuery( + queryKeys.authKeys.useGoogleCallback(parameter), + () => authApi.googleCallback(parameter), + { enabled: !!parameter.code }, + ), + + useNautilus: (body: NautilusBodyRequest) => + useQuery( + queryKeys.authKeys.useNautilus(body), + () => authApi.nautilus(body), + { enabled: !!(body.address && body.message && body.proof) }, + ), + useErgoPay: (parameter: ErgoPayRequestParameter) => + useQuery( + queryKeys.authKeys.useErgoPay(parameter), + { + queryFn: () => authApi.ergoPay(parameter), + }, + ), + + useUserInfo: (token: string | null) => + useQuery( + queryKeys.authKeys.useUserInfo(token), + () => authApi.userInfo(token), + { + enabled: !!token, // Only enable the query when the token is present + }, + ), +}; diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index abdebe1..bce5f42 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -1,5 +1,10 @@ +import { AssetManagement } from '@/scenes/dashboard/assetManagement/AssetManagement'; import { Layout } from '@/scenes/dashboard/layout/Layout'; export default function dashboard() { - return ; + return ( + + + + ); } diff --git a/app/globals.css b/app/globals.css index 357b3eb..cbe0f88 100644 --- a/app/globals.css +++ b/app/globals.css @@ -9,4 +9,5 @@ html { html, body { height: 100%; + overflow: hidden; } diff --git a/app/layout.tsx b/app/layout.tsx index 514389a..39b9403 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -2,7 +2,7 @@ import type { Metadata } from 'next'; import { Inter } from 'next/font/google'; import { Header } from '@/components/header/Header'; -import { AppProviders } from '@/components/providers'; +import { AppProviders } from '@/components/Providers'; import './globals.css'; diff --git a/app/page.tsx b/app/page.tsx index 6184b80..e5565e3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,22 +1,24 @@ import React from 'react'; - import { Box } from '@mui/material'; +import { Banner, Reward, Statistics, JoinUs, Footer, DataBox } from '@/scenes/landing'; -import { Banner, Reward, Statistics, JoinUs, Footer } from '@/scenes/landing'; -const Landing = () => ( - <> - - - - - +const Landing = () => { + return ( + + + + + + + + +