Skip to content

Commit

Permalink
feat: Partially updated token handling in order to soon start the Poo…
Browse files Browse the repository at this point in the history
…ls and proper API handling.
  • Loading branch information
dredshep committed May 14, 2024
1 parent 2cef9e2 commit 200e7b4
Show file tree
Hide file tree
Showing 28 changed files with 796 additions and 455 deletions.
3 changes: 2 additions & 1 deletion components/app/Global/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default function Layout({ children }: LayoutProps) {
return (
<div
className={
jura.className + " bg-tubeshapes-light bg-cover min-h-screen text-white"
jura.className +
" bg-tubeshapes-light bg-cover bg-fixed min-h-screen text-white"
}
>
<Head>
Expand Down
23 changes: 19 additions & 4 deletions components/app/Shared/Tables/FinancialTable/TableHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import cn from "classnames";
interface TableHeaderProps {
headers: Array<{
title: string;
minWidth?: string; // Optional min-width for each column
minWidth?: "20px" | "40px" | "60px" | "80px" | "120px" | "160px" | "240px"; // Optional min-width for each column
align?: "start" | "center" | "end"; // Optional alignment for each column
}>;
}

Expand All @@ -11,9 +13,22 @@ const TableHeaders: React.FC<TableHeaderProps> = ({ headers }) => {
{headers.map((header, index) => (
<div
key={index}
className={`flex-1 ${
header.minWidth ? `min-w-[${header.minWidth}]` : ""
}`}
// className={`flex-1 ${
// header.minWidth ? `min-w-[${header.minWidth}]` : ""
// }`}
className={cn({
"flex-1": true,
"min-w-[240px]": header.minWidth === "240px",
"min-w-[160px]": header.minWidth === "160px",
"min-w-[120px]": header.minWidth === "120px",
"min-w-[80px]": header.minWidth === "80px",
"min-w-[60px]": header.minWidth === "60px",
"min-w-[40px]": header.minWidth === "40px",
"min-w-[20px]": header.minWidth === "20px",
"text-start": header.align === "start",
"text-center": header.align === "center",
"text-end": header.align === "end",
})}
style={{ minWidth: header.minWidth }} // Apply min-width if provided
>
{header.title}
Expand Down
42 changes: 0 additions & 42 deletions components/docs/DocumentDisplay.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions components/docs/DocumentList.tsx

This file was deleted.

106 changes: 0 additions & 106 deletions components/docs/MarkdownStyledLayout.tsx

This file was deleted.

12 changes: 7 additions & 5 deletions pages/api/getSwappableTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import { NextApiRequest, NextApiResponse } from "next";
import { AzureTokensToken } from "@/types/api/azure/tokens"; // Adjust the import path as necessary
import { fetchAndTransform } from "@/utils/apis/fetchAndTransform";

// Example transformer function (if needed)
function transformTokensData(data: any): AzureTokensToken[] {
// Transform the data as needed
return data.tokens; // Assuming the structure of the received data matches AzureTokensResponse
return data.tokens;
}

export default async function handleTransformedApiRequest(
_: NextApiRequest,
res: NextApiResponse<AzureTokensToken[] | { error: string }>
) {
const apiUrl =
"https://bridge-bsc-mainnet.azurewebsites.net/tokens/?page=0&size=1000"; // Adjust the API URL as needed
"https://bridge-bsc-mainnet.azurewebsites.net/tokens/?page=0&size=1000";

try {
// Fetch data from the transformed API endpoint and transform it
Expand All @@ -24,7 +22,11 @@ export default async function handleTransformedApiRequest(

res.status(200).json(tokens);
} catch (error: any) {
res.status(500).json({ error: error.message || "Something went wrong" });
res.status(500).json({
error:
"@/pages/api/getSwappableTokens.ts:" +
(error.message || "Something went wrong"),
});
}
}

Expand Down
6 changes: 3 additions & 3 deletions pages/api/getTableTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TableToken, Token } from "@/types";
const transformTokensToTableFormat = (tokens: Token[]): TableToken[] => {
return tokens.map((token) => ({
address: token.address,
name: token.name ?? "Unknown Token",
name: token.symbol ?? "Unknown Token",
network: token.network ?? "Unknown Network",
price: token.usdPrice ?? "N/A",
change: "0%", // Assuming you will compute this based on some other data
Expand All @@ -25,12 +25,12 @@ const getTableTokens = async (req: NextApiRequest, res: NextApiResponse) => {
res.status(200).json(tableTokens);
} catch (error) {
console.error(
"@pages/api/getTableTokens.ts: Failed to fetch tokens",
"@/pages/api/getTableTokens.ts: Failed to fetch tokens",
error
);
res
.status(500)
.json({ error: "@pages/api/getTableTokens.ts: Failed to fetch tokens" });
.json({ error: "@/pages/api/getTableTokens.ts: Failed to fetch tokens" });
}
};

Expand Down
20 changes: 20 additions & 0 deletions pages/api/pools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// rawApiEndpoint.ts

import { NextApiRequest, NextApiResponse } from "next";
import { AzureTokensToken } from "@/types/api/azure/tokens"; // Adjust the import path as necessary
import { fetchAndTransform } from "@/utils/apis/fetchAndTransform";

export default async function handleRawApiRequest(
_: NextApiRequest,
res: NextApiResponse<AzureTokensToken[] | { error: string }>
) {
const apiUrl = "https://api-bridge-mainnet.azurewebsites.net/secret_tokens";
try {
// Fetch data from the raw API endpoint
const tokens = await fetchAndTransform<AzureTokensToken[]>(apiUrl);

res.status(200).json(tokens);
} catch (error: any) {
res.status(500).json({ error: error.message || "Something went wrong" });
}
}
37 changes: 37 additions & 0 deletions pages/api/test.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// rawApiEndpoint.ts

import { NextApiRequest, NextApiResponse } from "next";
import {
AzureTokensResponse,
AzureTokensToken,
} from "@/types/api/azure/tokens";
import { fetchAndTransform } from "@/utils/apis/fetchAndTransform";
import {
SecretToken,
AzureSecretTokensResponse,
} from "@/types/api/azure/secret_tokens";

export default async function handleRawApiRequest(
_: NextApiRequest,
res: NextApiResponse<(AzureTokensToken | SecretToken)[] | { error: string }>
) {
const apiUrl1 = "https://api-bridge-mainnet.azurewebsites.net/tokens";

const apiUrl2 = "https://bridge-bsc-mainnet.azurewebsites.net/tokens/";
const apiUrl3 = "https://api-bridge-mainnet.azurewebsites.net/secret_tokens/";

try {
// Fetch data from the raw API endpoint
// const tokens = await fetchAndTransform<AzureTokensToken[]>(apiUrl);
const tokens1 = await fetchAndTransform<AzureTokensResponse>(apiUrl1);
const tokens2 = await fetchAndTransform<AzureTokensResponse>(apiUrl2);
const tokens3 = await fetchAndTransform<AzureSecretTokensResponse>(apiUrl3);

// Combine the tokens from both sources
const tokens = [...tokens1.tokens, ...tokens2.tokens, ...tokens3.tokens];

res.status(200).json(tokens);
} catch (error: any) {
res.status(500).json({ error: error.message || "Something went wrong" });
}
}
25 changes: 20 additions & 5 deletions pages/api/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
// rawApiEndpoint.ts

import { NextApiRequest, NextApiResponse } from "next";
import { AzureTokensToken } from "@/types/api/azure/tokens"; // Adjust the import path as necessary
import {
AzureTokensResponse,
AzureTokensToken,
} from "@/types/api/azure/tokens";
import { fetchAndTransform } from "@/utils/apis/fetchAndTransform";
import {
SecretToken,
AzureSecretTokensResponse,
} from "@/types/api/azure/secret_tokens";
export type LocalTokensResponse = (AzureTokensToken | SecretToken)[];

export default async function handleRawApiRequest(
_: NextApiRequest,
res: NextApiResponse<AzureTokensToken[] | { error: string }>
res: NextApiResponse<(AzureTokensToken | SecretToken)[] | { error: string }>
) {
const apiUrl = "https://api-bridge-mainnet.azurewebsites.net/tokens"; // Adjust the API URL as needed
const apiUrl1 = "https://api-bridge-mainnet.azurewebsites.net/tokens";

const apiUrl2 = "https://bridge-bsc-mainnet.azurewebsites.net/tokens/";
const apiUrl3 = "https://api-bridge-mainnet.azurewebsites.net/secret_tokens/";

try {
// Fetch data from the raw API endpoint
const tokens = await fetchAndTransform<AzureTokensToken[]>(apiUrl);
const tokens1 = await fetchAndTransform<AzureTokensResponse>(apiUrl1);
const tokens2 = await fetchAndTransform<AzureTokensResponse>(apiUrl2);
const tokens3 = await fetchAndTransform<AzureSecretTokensResponse>(apiUrl3);

// Combine the tokens from both sources
const tokens = [...tokens1.tokens, ...tokens2.tokens, ...tokens3.tokens];

res.status(200).json(tokens);
} catch (error: any) {
Expand Down
Loading

0 comments on commit 200e7b4

Please sign in to comment.