Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform tables update #264

Merged
merged 4 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stability-ui",
"type": "module",
"version": "0.12.22-alpha",
"version": "0.12.23-alpha",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand Down
14 changes: 14 additions & 0 deletions public/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { chains } from "@stabilitydao/stability";

import { TABLE_FILTERS, TABLE, CHAINS_TABLE } from "./tables";
import {
TABLE_FILTERS,
TABLE,
CHAINS_TABLE,
ASSETS_TABLE,
INTEGRATIONS_TABLE,
STRATEGIES_TABLE,
} from "./tables";

import {
USDC,
Expand Down Expand Up @@ -282,4 +289,7 @@ export {
DEFAULT_ERROR,
IL,
ZERO_BigInt,
ASSETS_TABLE,
INTEGRATIONS_TABLE,
STRATEGIES_TABLE,
};
92 changes: 84 additions & 8 deletions src/constants/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,101 @@ const CHAINS_TABLE: TTableColumn[] = [
sortType: "none",
dataType: "number",
},
// {
// name: "Treasury",
// keyName: "multisig",
// sortType: "none",
// dataType: "string",
// },
// {
// name: "Issue",
// keyName: "chainLibGithubId",
// sortType: "none",
// dataType: "number",
// },
{ name: "Status", keyName: "status", sortType: "none", dataType: "string" },
{
name: "Bridges",
keyName: "bridgesCount",
sortType: "none",
dataType: "number",
},
];

const ASSETS_TABLE: TTableColumn[] = [
{
name: "Treasury",
keyName: "multisig",
name: "Symbol",
keyName: "symbol",
sortType: "none",
dataType: "string",
},
{
name: "Issue",
keyName: "chainLibGithubId",
name: "Website",
keyName: "",
sortType: "none",
dataType: "",
unsortable: true,
},
{
name: "Addresses",
keyName: "addresses",
sortType: "none",
dataType: "number",
},
{ name: "Status", keyName: "status", sortType: "none", dataType: "string" },
];
const INTEGRATIONS_TABLE: TTableColumn[] = [
{
name: "Bridges",
keyName: "chainId", //temp
name: "Organization",
keyName: "name",
sortType: "none",
dataType: "string",
},
{
name: "Links",
keyName: "",
sortType: "none",
dataType: "",
unsortable: true,
},
{
name: "Protocols",
keyName: "protocolsLength",
sortType: "none",
dataType: "number",
},
];
const STRATEGIES_TABLE: TTableColumn[] = [
{
name: "Id",
keyName: "shortId",
sortType: "none",
dataType: "string",
},
{
name: "Name",
keyName: "id",
sortType: "none",
dataType: "string",
},
{
name: "State",
keyName: "state",
sortType: "none",
dataType: "string",
},
{
name: "Issue",
keyName: "contractGithubId",
sortType: "none",
dataType: "number",
},
];

export { TABLE_FILTERS, TABLE, CHAINS_TABLE };
export {
TABLE_FILTERS,
TABLE,
CHAINS_TABLE,
ASSETS_TABLE,
INTEGRATIONS_TABLE,
STRATEGIES_TABLE,
};
87 changes: 60 additions & 27 deletions src/modules/Platform/components/Assets.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,78 @@
import { useState, useEffect } from "react";

import { assets } from "@stabilitydao/stability";

import { Breadcrumbs } from "@ui";
import { sortTable } from "@utils";

import { Breadcrumbs, TableColumnSort } from "@ui";

import { ASSETS_TABLE } from "@constants";

import type { TTableColumn, TAssetData } from "@types";

const Assets = (): JSX.Element => {
const [tableStates, setTableStates] = useState(ASSETS_TABLE);
const [tableData, setTableData] = useState<TAssetData[]>([]);

const initTableData = async () => {
if (assets) {
const assetsData = assets.map(({ symbol, website, addresses }) => ({
symbol,
website,
addresses: Object.keys(addresses).length,
}));
setTableData(assetsData);
}
};

useEffect(() => {
initTableData();
}, []);
return (
<div className="">
<div>
<Breadcrumbs links={["Platform", "Assets"]} />

<h1>Assets</h1>

<table className="font-manrope w-full">
<thead className="bg-accent-950 text-neutral-600 h-[36px]">
<tr className="text-[12px] uppercase">
<td className="px-4 py-2">Symbol</td>
<td className="px-4 py-2">Website</td>
<td className="px-4 py-2">Addresses</td>
{tableStates.map((value: TTableColumn, index: number) => (
<TableColumnSort
key={value.name + index}
index={index}
value={value.name}
sort={sortTable}
table={tableStates}
setTable={setTableStates}
tableData={tableData}
setTableData={setTableData}
/>
))}
</tr>
</thead>
<tbody className="text-[14px]">
{assets.map(({ addresses, symbol, website }) => (
<tr className="h-[48px] hover:bg-accent-950" key={website}>
<td className="px-4 py-3">{symbol}</td>
<td className="px-4 py-3 ">
<a
className="flex items-center justify-center"
href={website}
target="_blank"
title="Go to asset website"
>
<img
src="/icons/web.svg"
alt="Website"
className="w-[20px]"
/>
</a>
</td>
<td className="px-4 py-3 text-end">
{Object.keys(addresses).length}
</td>
</tr>
))}
{!!tableData.length &&
tableData.map(({ addresses, symbol, website }) => (
<tr className="h-[48px] hover:bg-accent-950" key={symbol}>
<td className="px-4 py-3">{symbol}</td>
<td className="px-4 py-3 ">
<a
className="flex items-center justify-center"
href={website}
target="_blank"
title="Go to asset website"
>
<img
src="/icons/web.svg"
alt="Website"
className="w-[20px]"
/>
</a>
</td>
<td className="px-4 py-3 text-end">{addresses}</td>
</tr>
))}
</tbody>
</table>
</div>
Expand Down
131 changes: 0 additions & 131 deletions src/modules/Platform/components/Chain.tsx

This file was deleted.

Loading
Loading