diff --git a/desktop-app/renderer/api/fleets/fleets.ts b/desktop-app/renderer/api/fleets/fleets.ts new file mode 100644 index 00000000..c3ea0a32 --- /dev/null +++ b/desktop-app/renderer/api/fleets/fleets.ts @@ -0,0 +1,6 @@ +export interface Fleet{ + name: string + uuid: string + value: number + bot_count: number +} \ No newline at end of file diff --git a/desktop-app/renderer/api/spaces/spaces.ts b/desktop-app/renderer/api/spaces/spaces.ts index ac4062b6..9060a108 100644 --- a/desktop-app/renderer/api/spaces/spaces.ts +++ b/desktop-app/renderer/api/spaces/spaces.ts @@ -1,16 +1,43 @@ +import { Fleet } from 'api/fleets/fleets' import { request } from 'api/request' +import { Wallet } from 'api/wallets/wallets' import { AxiosResponse } from 'axios' import { useSearchParams } from 'next/navigation' -export interface NapseSpace { +export interface BaseNapseSpace{ name: string + description: string + exchange_account: string +} + +export interface NapseSpace extends BaseNapseSpace{ uuid: string value: number fleet_count: number +} + +interface Statistics { + [Key: string]: number +} + +interface History{ + // TODO: Improve this + [Key: string]: number +} + +export interface RetrievedNapseSpace extends BaseNapseSpace { + uuid: string exchange_account: string - delta?: number + created_at: string + statistics: Statistics + wallet: Wallet + // history: + fleets: Fleet[] } + + + export async function listSpace( searchParams: ReturnType ): Promise> { @@ -18,10 +45,10 @@ export async function listSpace( return response as AxiosResponse } -export async function getSpace( +export async function retrieveSpace( searchParams: ReturnType, id: string -): Promise> { +): Promise> { const response = await request(searchParams, 'GET', `/api/space/${id}/`) - return response as AxiosResponse + return response as AxiosResponse } diff --git a/desktop-app/renderer/api/wallets/wallets.ts b/desktop-app/renderer/api/wallets/wallets.ts new file mode 100644 index 00000000..89b9c281 --- /dev/null +++ b/desktop-app/renderer/api/wallets/wallets.ts @@ -0,0 +1,20 @@ +export interface Currency{ + ticker: string + mbp: number + amount: number +} + +export interface Operation{ +amount: number +ticker: string +operation_type: string +created_at: string +} + +export interface Wallet{ +title: string +value: string +created_at: string +currencies: Currency[] +operations: Operation[] +} diff --git a/desktop-app/renderer/pages/spaces/[name]/assetsTable/columns.tsx b/desktop-app/renderer/pages/spaces/[slug]/assetsTable/columns.tsx similarity index 100% rename from desktop-app/renderer/pages/spaces/[name]/assetsTable/columns.tsx rename to desktop-app/renderer/pages/spaces/[slug]/assetsTable/columns.tsx diff --git a/desktop-app/renderer/pages/spaces/[name]/index.tsx b/desktop-app/renderer/pages/spaces/[slug]/index.tsx similarity index 100% rename from desktop-app/renderer/pages/spaces/[name]/index.tsx rename to desktop-app/renderer/pages/spaces/[slug]/index.tsx diff --git a/desktop-app/renderer/pages/spaces/[name]/transactionHistTable/columns.tsx b/desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/columns.tsx similarity index 100% rename from desktop-app/renderer/pages/spaces/[name]/transactionHistTable/columns.tsx rename to desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/columns.tsx diff --git a/desktop-app/renderer/pages/spaces/[name]/transactionHistTable/data-table.tsx b/desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/data-table.tsx similarity index 100% rename from desktop-app/renderer/pages/spaces/[name]/transactionHistTable/data-table.tsx rename to desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/data-table.tsx diff --git a/desktop-app/renderer/pages/spaces/[name]/transactionHistTable/dataTablePagination.tsx b/desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/dataTablePagination.tsx similarity index 100% rename from desktop-app/renderer/pages/spaces/[name]/transactionHistTable/dataTablePagination.tsx rename to desktop-app/renderer/pages/spaces/[slug]/transactionHistTable/dataTablePagination.tsx diff --git a/desktop-app/renderer/pages/spaces/index.tsx b/desktop-app/renderer/pages/spaces/index.tsx index 9e18709c..ea8ca190 100644 --- a/desktop-app/renderer/pages/spaces/index.tsx +++ b/desktop-app/renderer/pages/spaces/index.tsx @@ -1,64 +1,23 @@ -import ValuePanelCard from '@/components/custom/panel/valuePanelCard' import ContextHeader from '@/components/layout/contextHeader' - -import { NapseSpace, listSpace } from '@/api/spaces/spaces' -import { standardUrlPartial } from '@/lib/queryParams' -import { AxiosResponse } from 'axios' +import DefaultPageLayout from '@/components/layout/defaultPageLayout' import { useSearchParams } from 'next/navigation' import { useRouter } from 'next/router' -import { useEffect, useState } from 'react' export default function Spaces(): JSX.Element { - const [spaces, setSpaces] = useState([]) const searchParams = useSearchParams() - useEffect(() => { - const fetchServers = async () => { - try { - const response: AxiosResponse = - await listSpace(searchParams) - setSpaces(response.data) - } catch (error) { - console.error(error) - setSpaces([]) - } - } - if (searchParams.get('server')) { - fetchServers() - } - }, [searchParams]) - const router = useRouter() + // const [Spaces, setSpaces] = useState<> + return ( -
- {spaces.map((space, index) => ( - { - router - .push( - standardUrlPartial( - '/spaces/', - space.uuid, - { - exchangeAccount: space.exchange_account, - space: space.uuid - }, - searchParams - ) - ) - .catch((err) => { - console.error(err) - }) - }} - badge={String(space.fleet_count) + ' fleets'} - /> - ))} -
+ + <> +
) } diff --git a/desktop-app/renderer/pages/spaces/index_backup.tsx b/desktop-app/renderer/pages/spaces/index_backup.tsx new file mode 100644 index 00000000..9e18709c --- /dev/null +++ b/desktop-app/renderer/pages/spaces/index_backup.tsx @@ -0,0 +1,64 @@ +import ValuePanelCard from '@/components/custom/panel/valuePanelCard' +import ContextHeader from '@/components/layout/contextHeader' + +import { NapseSpace, listSpace } from '@/api/spaces/spaces' +import { standardUrlPartial } from '@/lib/queryParams' +import { AxiosResponse } from 'axios' +import { useSearchParams } from 'next/navigation' +import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' + +export default function Spaces(): JSX.Element { + const [spaces, setSpaces] = useState([]) + const searchParams = useSearchParams() + useEffect(() => { + const fetchServers = async () => { + try { + const response: AxiosResponse = + await listSpace(searchParams) + setSpaces(response.data) + } catch (error) { + console.error(error) + setSpaces([]) + } + } + if (searchParams.get('server')) { + fetchServers() + } + }, [searchParams]) + + const router = useRouter() + return ( + +
+ {spaces.map((space, index) => ( + { + router + .push( + standardUrlPartial( + '/spaces/', + space.uuid, + { + exchangeAccount: space.exchange_account, + space: space.uuid + }, + searchParams + ) + ) + .catch((err) => { + console.error(err) + }) + }} + badge={String(space.fleet_count) + ' fleets'} + /> + ))} +
+
+ ) +}