Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
manishiwa committed Jan 11, 2024
2 parents f2abf94 + dbbf4b3 commit 59763bf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
7 changes: 6 additions & 1 deletion app/api/optimism-retropgf-3/projects/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const pool = new Pool({
});

export async function GET() {
// get OP token price from coingecko
const tokenPrice = await fetch(
"https://api.coingecko.com/api/v3/simple/price?ids=optimism&vs_currencies=usd",
).then((res) => res.json());

try {
const result = await pool.query(
`SELECT
Expand Down Expand Up @@ -39,7 +44,7 @@ export async function GET() {
}
});

return Response.json({ projects: data });
return Response.json({ projects: data, prices: tokenPrice });
} catch (error) {
return Response.json({ error });
}
Expand Down
20 changes: 15 additions & 5 deletions app/optimism-retropgf-3/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,22 @@ export default function Page() {
</div>
</TooltipTrigger>
<TooltipContent className="z-50 flex items-center justify-center">
<div className="px-3 py-1.5 text-sm font-medium bg-forest-100 dark:bg-[#4B5553] text-forest-900 dark:text-forest-100 rounded-xl shadow-lg z-50 flex items-center">
<div className="text-xs space-x-1">

{info.row.original.awarded.toLocaleString()} OP <span className="font-light">Awarded</span>

<div className="ml-2 px-3 py-1.5 text-sm bg-forest-100 dark:bg-[#4B5553] text-forest-900 dark:text-forest-100 rounded-xl shadow-lg z-50 flex flex-col space-y-1">
<div className="text-xs text-center">Award Amount</div>
<div className="flex justify-between space-x-1 font-bold items-end leading-snug">
<div className="flex-1 text-right">{info.row.original.awarded.toLocaleString()}</div><div className="text-left opacity-60 text-xs font-normal">OP</div>
</div>
{projectsResponse?.prices.optimism.usd &&
(
<>
<div className="flex justify-between space-x-1 items-end">
<div className="flex-1 text-right"><span className="opacity-60 text-[0.65rem]">$</span>{Math.round(projectsResponse.prices.optimism.usd * info.row.original.awarded).toLocaleString()}</div><div className="text-left opacity-60 text-[0.65rem]">USD</div>
</div>
{/* <div className="text-[0.6rem] text-center opacity-60">@ ${projectsResponse.prices.optimism.usd} / OP</div> */}
</>
)
}

</div>
</TooltipContent>
</Tooltip>
Expand Down
5 changes: 5 additions & 0 deletions types/api/RetroPGF3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export type Project = {

export type ProjectsResponse = {
projects: Project[];
prices: {
optimism: {
usd: number;
};
};
};

export type List = {
Expand Down

1 comment on commit 59763bf

@vercel
Copy link

@vercel vercel bot commented on 59763bf Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.