Skip to content

Commit

Permalink
Merge pull request #129 from HoomanHQ/main
Browse files Browse the repository at this point in the history
update: gpu-pricing and token page
  • Loading branch information
HoomanHQ authored Apr 12, 2024
2 parents 32d34f6 + 36aeab3 commit c0e6619
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 78 deletions.
43 changes: 2 additions & 41 deletions src/components/gpu-table/gpu-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ const Table = ({
};
subCom?: boolean;
}) => {
const token = useStorage((state: any) => state?.gpu);
const [enabled, setEnabled] = useState(false);
const setToken = useStorage((state: any) => state?.setGpu);
console.log(token);

const fetchInterval = 1000 * 60 * 15;

const [currentTime, setCurrentTime] = useState(new Date().getTime());
const fetchInterval = 1000 * 60;

const { data: result } = useQuery<
{
Expand All @@ -86,50 +79,18 @@ const Table = ({
>({
queryKey: ["GPU_TABLE"],
queryFn: () => axios.get(gpus),

refetchIntervalInBackground: true,
initialData: token || {
initialData: initialData || {
data: {
availability: { total: 0, available: 0 },
models: [],
},
},
refetchInterval: fetchInterval,
keepPreviousData: true,
retry: true,
enabled: enabled,
});

const data = result?.data;

console.log(data?.time !== token?.time, data);

useEffect(() => {
if (data?.time !== token?.time && data) {
setToken({
...data,
time: new Date().getTime(),
});
}
}, [data]);

useEffect(() => {
const timer = setInterval(() => {
setCurrentTime(new Date().getTime());
}, 1000);
return () => clearInterval(timer);
}, []);

useEffect(() => {
if (!token || currentTime - token?.time > fetchInterval) {
setEnabled(true);
} else {
setEnabled(false);
}
}, [currentTime, token]);

console.log(data);

return <Tables data={data} subCom={subCom} />;
};

Expand Down
22 changes: 11 additions & 11 deletions src/components/token-page/faq-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ const FaqSection = ({
{
title: "What is the maximum and circulating supply of AKT?",
description: `Akash has a maximum supply of ${
data?.market_data.max_supply
? data?.market_data.max_supply
.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
data?.market_data?.max_supply
? data?.market_data?.max_supply
?.toString()
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
: "388,539,008"
}, with ${
data?.market_data.circulating_supply
? data?.market_data.circulating_supply
.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
data?.market_data?.circulating_supply
? data?.market_data?.circulating_supply
?.toString()
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
: "214,430,074"
} AKT in circulation as of ${
data
? new Date(data?.market_data.last_updated).toUTCString()
? new Date(data?.market_data?.last_updated)?.toUTCString()
: "Sat Jan 7 07:57:36 UTC"
}
`,
Expand Down
13 changes: 9 additions & 4 deletions src/components/token-page/sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ const Query = ({
time: new Date().getTime(),
});
}
if (token === null) {
setToken({
time: 0,
});
}
}, [data]);

useEffect(() => {
Expand Down Expand Up @@ -142,7 +147,7 @@ const Query = ({

<ul className="ml-8 list-disc space-y-2 text-sm font-normal text-[#7F7F7F] md:text-[18px]">
<li>
Take and Make Fees
Take and Make Fees{" "}
<a
target="_blank"
className="font-medium text-primary"
Expand All @@ -152,7 +157,7 @@ const Query = ({
</a>
</li>
<li>
Stable Payment and Settlement
Stable Payment and Settlement{" "}
<a
target="_blank"
className="font-medium text-primary"
Expand Down Expand Up @@ -183,8 +188,8 @@ const Query = ({
"
>
sig-economics
</a>
and
</a>{" "}
and{" "}
<a
target="_blank"
className="font-medium text-primary"
Expand Down
44 changes: 22 additions & 22 deletions src/components/token-page/token-metrics-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TokenMetricsSection = ({
<p className="mt-4 text-sm leading-[20px] md:text-base lg:text-lg lg:leading-[32px]">
As of{" "}
{data
? new Date(data?.market_data.last_updated).toUTCString()
? new Date(data?.market_data?.last_updated).toUTCString()
: "Sat Jan 7 07:57:36 UTC"}
{", "}
the following are the AKT metrics, as reported by Coingecko.
Expand All @@ -33,10 +33,10 @@ const TokenMetricsSection = ({
isError={isError}
number={
data &&
data?.market_data.circulating_supply
.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
data?.market_data?.circulating_supply
?.toString()
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
}
isLoading={isLoading}
/>
Expand All @@ -51,10 +51,10 @@ const TokenMetricsSection = ({
isError={isError}
number={
data &&
data?.market_data.total_supply
.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
data?.market_data?.total_supply
?.toString()
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
}
isLoading={isLoading}
/>
Expand All @@ -68,10 +68,10 @@ const TokenMetricsSection = ({
isError={isError}
number={
data &&
data?.market_data.max_supply
.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
data?.market_data?.max_supply
?.toString()
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
}
isLoading={isLoading}
/>
Expand All @@ -86,9 +86,9 @@ const TokenMetricsSection = ({
isError={isError}
number={
data &&
`$${data?.market_data.current_price.usd
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
`$${data?.market_data?.current_price.usd
?.toString()
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
}
isLoading={isLoading}
/>
Expand All @@ -103,10 +103,10 @@ const TokenMetricsSection = ({
isLoading={isLoading}
number={
data &&
`$${data?.market_data.market_cap.usd
`$${data?.market_data?.market_cap.usd
?.toString()
.split(".")[0]
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
?.split(".")[0]
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
}
/>
</div>
Expand All @@ -120,9 +120,9 @@ const TokenMetricsSection = ({
isError={isError}
number={
data &&
`$${data?.market_data.total_volume.usd
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
`$${data?.market_data?.total_volume.usd
?.toString()
?.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
}
isLoading={isLoading}
/>
Expand Down

0 comments on commit c0e6619

Please sign in to comment.