-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from napse-invest/feature/bot
Feature/bot
- Loading branch information
Showing
9 changed files
with
97 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
export default function Todo(): JSX.Element { | ||
// TODO: implement or move this file | ||
return <></> | ||
import ContextHeader from '@/components/layout/contextHeader' | ||
import DefaultPageLayout from '@/components/layout/defaultPageLayout' | ||
|
||
export default function Bot(): JSX.Element { | ||
return ( | ||
<ContextHeader isBot> | ||
<DefaultPageLayout | ||
header={'Your Bots'} | ||
description={ | ||
'Bots look to make your money grow while you do something else.' | ||
} | ||
> | ||
<></> | ||
</DefaultPageLayout> | ||
</ContextHeader> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,77 @@ | ||
import { Bot, listBot } from '@/api/bots/bots' | ||
import { Key, getCurrentKey } from '@/api/key/key' | ||
import ValuePanelCard from '@/components/custom/panel/valuePanelCard' | ||
import ContextHeader from '@/components/layout/contextHeader' | ||
import DefaultPageLayout from '@/components/layout/defaultPageLayout' | ||
import { standardUrlPartial } from '@/lib/queryParams' | ||
import { useRouter, useSearchParams } from 'next/navigation' | ||
import { useEffect, useState } from 'react' | ||
|
||
import { Card, Metric, Text, Flex, BadgeDelta, Grid } from '@tremor/react' | ||
import type { DeltaType } from '@tremor/react' | ||
export default function Bots(): JSX.Element { | ||
const searchParams = useSearchParams() | ||
const router = useRouter() | ||
const [bots, setBots] = useState<Bot[]>([]) | ||
const [currentKey, setCurrentKey] = useState<Key>() | ||
|
||
interface Category { | ||
title: string | ||
metric: string | ||
metricPrev: string | ||
delta: string | ||
deltaType: DeltaType | ||
} | ||
useEffect(() => { | ||
async function fetchBots() { | ||
try { | ||
const response = await listBot(searchParams) | ||
setBots(response.data) | ||
} catch (error) { | ||
console.error(error) | ||
setBots([]) | ||
} | ||
} | ||
const fetchCurrentKey = async () => { | ||
try { | ||
const response = await getCurrentKey(searchParams) | ||
setCurrentKey(response) | ||
} catch (error) { | ||
console.error(error) | ||
setCurrentKey(undefined) | ||
} | ||
} | ||
if (searchParams.get('server')) { | ||
fetchBots() | ||
fetchCurrentKey() | ||
} | ||
}, [searchParams]) | ||
|
||
const categories: Category[] = [ | ||
{ | ||
title: 'Sales', | ||
metric: '$ 12,699', | ||
metricPrev: '$ 9,456', | ||
delta: '34.3%', | ||
deltaType: 'moderateIncrease' | ||
}, | ||
{ | ||
title: 'Profit', | ||
metric: '$ 40,598', | ||
metricPrev: '$ 45,564', | ||
delta: '10.9%', | ||
deltaType: 'moderateDecrease' | ||
}, | ||
{ | ||
title: 'Customers', | ||
metric: '1,072', | ||
metricPrev: '856', | ||
delta: '25.3%', | ||
deltaType: 'moderateIncrease' | ||
} | ||
] | ||
export default function Bots(): JSX.Element { | ||
return ( | ||
<ContextHeader isBot> | ||
<Grid numItemsSm={2} numItemsLg={3} className="gap-6"> | ||
{categories.map((item) => ( | ||
<Card key={item.title}> | ||
<Flex alignItems="start"> | ||
<Text>{item.title}</Text> | ||
<BadgeDelta | ||
className=" rounded-tremor-small" | ||
deltaType={item.deltaType} | ||
> | ||
{item.delta} | ||
</BadgeDelta> | ||
</Flex> | ||
<Flex | ||
justifyContent="start" | ||
alignItems="baseline" | ||
className="space-x-3 truncate" | ||
> | ||
<Metric>{item.metric}</Metric> | ||
<Text className="truncate">from {item.metricPrev}</Text> | ||
</Flex> | ||
</Card> | ||
))} | ||
</Grid> | ||
<DefaultPageLayout | ||
header={'Your Bots'} | ||
description={ | ||
'Bots look to make your money grow while you do something else.' | ||
} | ||
> | ||
<div className="my-10 grid max-w-screen-xl grid-cols-3 gap-6"> | ||
{bots.map((bot, index) => ( | ||
<ValuePanelCard | ||
key={index} | ||
title={bot.name} | ||
value={bot.value} | ||
delta={bot.delta} | ||
onClick={() => { | ||
router.push( | ||
standardUrlPartial( | ||
'/bots/', | ||
bot.uuid, | ||
{ | ||
exchangeAccount: bot.exchangeAccount, | ||
space: bot.space, | ||
fleet: bot.fleet, | ||
bot: bot.uuid | ||
}, | ||
searchParams | ||
) | ||
) | ||
}} | ||
/> | ||
))} | ||
</div> | ||
</DefaultPageLayout> | ||
</ContextHeader> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters