Skip to content

Commit

Permalink
update dependencies and import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennievon committed Oct 8, 2024
1 parent 2a789be commit 4991b86
Show file tree
Hide file tree
Showing 117 changed files with 876 additions and 4,015 deletions.
17 changes: 11 additions & 6 deletions tools/tenscan/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM node:18-buster as runner
# Install pnpm

RUN npm install -g pnpm
# setup container data structure
RUN mkdir -p /home/obscuro/go-obscuro/tools/tenscan/
COPY ./tools/tenscan/frontend /home/obscuro/go-obscuro/tools/tenscan/frontend

WORKDIR /home/obscuro/go-obscuro/tools/tenscan/frontend
COPY . /home/obscuro/go-obscuro/

WORKDIR /home/obscuro/go-obscuro/

RUN pnpm install

EXPOSE 80
WORKDIR /home/obscuro/go-obscuro/tools/tenscan/frontend

RUN pnpm install --filter ./tools/tenscan/frontend...

EXPOSE 80

CMD ["pnpm", "run", "start"]
2 changes: 1 addition & 1 deletion tools/tenscan/frontend/api/batches.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { httpRequest } from ".";
import { apiRoutes } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface } from "@/src/types/interfaces";
import {
Batch,
BatchDetails,
BatchResponse,
LatestBatch,
} from "@/src/types/interfaces/BatchInterfaces";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";

export const fetchBatches = async (
payload?: Record<string, any>
Expand Down
7 changes: 4 additions & 3 deletions tools/tenscan/frontend/api/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { httpRequest } from ".";
import { apiRoutes } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface } from "@/src/types/interfaces";
import { BlockResponse } from "@/src/types/interfaces/BlockInterfaces";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";

export const fetchBlocks = async (
payload?: Record<string, any>
): Promise<ResponseDataInterface<any>> => {
return await httpRequest<ResponseDataInterface<any>>({
): Promise<ResponseDataInterface<BlockResponse>> => {
return await httpRequest<ResponseDataInterface<BlockResponse>>({
method: "get",
url: pathToUrl(apiRoutes.getBlocks),
searchParams: payload,
Expand Down
2 changes: 1 addition & 1 deletion tools/tenscan/frontend/api/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { httpRequest } from ".";
import { apiRoutes } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface } from "@/src/types/interfaces";
import { ContractCount } from "@/src/types/interfaces/ContractInterface";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";

export const fetchContractCount = async (
payload?: Record<string, any>
Expand Down
2 changes: 1 addition & 1 deletion tools/tenscan/frontend/api/general.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResponseDataInterface } from "@/src/types/interfaces";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";
import { httpRequest } from ".";
import { pathToUrl } from "@/src/routes/router";
import { apiRoutes } from "@/src/routes";
Expand Down
4 changes: 2 additions & 2 deletions tools/tenscan/frontend/api/rollups.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { httpRequest } from ".";
import { apiRoutes } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface } from "@/src/types/interfaces";
import { Batch, BatchResponse } from "@/src/types/interfaces/BatchInterfaces";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";
import { BatchResponse } from "@/src/types/interfaces/BatchInterfaces";
import {
Rollup,
RollupsResponse,
Expand Down
7 changes: 4 additions & 3 deletions tools/tenscan/frontend/api/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { jsonHexToObj } from "@/src/lib/utils";
import { jsonHexToObj } from "@repo/ui/lib/utils";
import { httpRequest } from ".";
import { apiRoutes, ethMethods, tenCustomQueryMethods } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface, ToastType } from "@/src/types/interfaces";
import {
TransactionCount,
Price,
TransactionResponse,
Transaction,
} from "@/src/types/interfaces/TransactionInterfaces";
import { showToast } from "@/src/components/ui/use-toast";
import { showToast } from "@repo/ui/components/shared/use-toast";
import { ResponseDataInterface } from "@repo/ui/lib/types/common";
import { ToastType } from "@repo/ui/lib/enums/toast";

export const fetchTransactions = async (
payload?: Record<string, any>
Expand Down
1 change: 1 addition & 0 deletions tools/tenscan/frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ["@repo/ui"],
images: {
unoptimized: true,
},
Expand Down
27 changes: 6 additions & 21 deletions tools/tenscan/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-query": "^5.8.1",
"@tanstack/react-query-devtools": "^5.8.1",
"@tanstack/react-table": "^8.10.7",
Expand All @@ -33,7 +19,6 @@
"cmdk": "^0.2.0",
"date-fns": "^2.30.0",
"ethers": "^5.7.2",
"lucide-react": "^0.292.0",
"next": "14.0.1",
"next-themes": "^0.2.1",
"path-to-regexp": "^6.2.1",
Expand All @@ -43,18 +28,18 @@
"react-json-pretty": "^2.2.0",
"recharts": "^2.9.3",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
"zustand": "^4.4.6"
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@repo/ui": "workspace:*",
"@types/node": "^20.12.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
}
}
41 changes: 5 additions & 36 deletions tools/tenscan/frontend/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
import { ErrorType } from "@/src/types/interfaces";
import Error from "./_error";
import Custom404Error from "@repo/ui/components/common/404";

export function Custom404Error({
customPageTitle,
showRedirectText,
redirectText,
isFullWidth,
message,
showMessage = true,
redirectLink,
children,
}: ErrorType) {
return (
<Error
heading={` ${customPageTitle || "Oops! Page"} Not Found`}
statusText={`We can't seem to find the ${
customPageTitle || "page"
} you're looking for.`}
statusCode={404}
showRedirectText={showRedirectText}
redirectText={redirectText || "Home Page"}
message={
message ||
`The ${
customPageTitle || "page"
} you are looking for might have been removed, had its name changed, or is temporarily unavailable.`
}
isFullWidth={isFullWidth}
showMessage={showMessage}
redirectLink={redirectLink}
>
{children}
</Error>
);
}
const Custom404 = () => {
return <Custom404Error />;
};

export default Custom404Error;
export default Custom404;
35 changes: 5 additions & 30 deletions tools/tenscan/frontend/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
import { ErrorType } from "@/src/types/interfaces";
import Error from "./_error";
import Custom500Error from "@repo/ui/components/common/500";

function Custom500Error({
customPageTitle,
message,
showRedirectText,
redirectText,
err,
redirectLink,
children,
}: ErrorType) {
return (
<Error
heading={"Oops! Something went wrong."}
message={
message ||
"We're experiencing technical difficulties. Please try again later."
}
statusText={customPageTitle || `An Error occured`}
statusCode={500}
showRedirectText={showRedirectText || true}
redirectText={redirectText || "Home Page"}
err={err}
redirectLink={redirectLink}
>
{children}
</Error>
);
}
const Custom404 = () => {
return <Custom500Error />;
};

export default Custom500Error;
export default Custom404;
19 changes: 8 additions & 11 deletions tools/tenscan/frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import {
} from "@tanstack/react-query";
import "@/styles/globals.css";
import type { AppProps } from "next/app";
import { Toaster } from "@/src/components/ui/toaster";
import { WalletConnectionProvider } from "@/src/components/providers/wallet-provider";
import { NetworkStatus } from "@/src/components/modules/common/network-status";
import { Toaster } from "@repo/ui/components/shared/toaster";
import { NetworkStatus } from "@repo/ui/components/common/network-status";
import HeadSeo from "@/src/components/head-seo";
import { siteMetadata } from "@/src/lib/siteMetadata";
import Script from "next/script";
import { GOOGLE_ANALYTICS_ID } from "@/src/lib/constants";
import { showToast } from "@/src/components/ui/use-toast";
import { ToastType } from "@/src/types/interfaces";
import { showToast } from "@repo/ui/components/shared/use-toast";
import { ToastType } from "@repo/ui/lib/enums/toast";

export default function App({ Component, pageProps }: AppProps) {
const mutationCache = new MutationCache({
Expand Down Expand Up @@ -76,12 +75,10 @@ export default function App({ Component, pageProps }: AppProps) {
enableSystem
disableTransitionOnChange
>
<WalletConnectionProvider>
<Component {...pageProps} />
<Toaster />
<NetworkStatus />
<ReactQueryDevtools initialIsOpen={false} />
</WalletConnectionProvider>
<Component {...pageProps} />
<Toaster />
<NetworkStatus />
<ReactQueryDevtools initialIsOpen={false} />
</ThemeProvider>
</QueryClientProvider>
</>
Expand Down
102 changes: 19 additions & 83 deletions tools/tenscan/frontend/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -1,91 +1,27 @@
import CustomError from "@repo/ui/components/common/error";
import React from "react";
import NextErrorComponent from "next/error";
import Link from "next/link";
import Image from "next/image";
import { ErrorType } from "@/src/types/interfaces";

function ErrorMessage({
statusText,
message,
showMessage,
showStatusText,
}: any) {
export default function CustomErrorPage({ statusCode, err }: any) {
return (
<div className="error-message">
{showStatusText && <h3>{statusText}</h3>}
{message && showMessage && (
<p className="text-muted-foreground">{message}</p>
)}
</div>
<CustomError
statusCode={statusCode}
err={err}
heading={
statusCode === 404 ? "Page Not Found" : "Oops! Something went wrong."
}
message={
statusCode === 404
? "Sorry, the page you're looking for doesn't exist."
: "We're experiencing technical difficulties. Please try again later."
}
redirectLink="/"
redirectText="Back to Home"
/>
);
}

export function CustomError({
showRedirectText = true,
heading = "Oops! Something went wrong.",
statusText = "500",
message = "We're experiencing technical difficulties. Please try again later.",
redirectText = "Home Page",
isFullWidth,
err,
showMessage = true,
showStatusText,
statusCode,
isModal,
redirectLink = "/",
children,
...props
}: ErrorType) {
return (
<section
className="h-full flex flex-col justify-center items-center"
{...props}
>
<main className={isFullWidth ? "max-w-full" : ""}>
<div className="text-center">
<h1 className="text-4xl font-extrabold mb-6">{heading}</h1>
<div className={isFullWidth ? "w-full" : ""}>
<ErrorMessage
showStatusText={showStatusText}
showMessage={showMessage}
message={message}
statusText={statusText}
/>
</div>
{showRedirectText && (
<div>
Go to{" "}
<Link
href={redirectLink}
passHref
className="text-primary pointer underline"
>
{redirectText}
</Link>{" "}
{/* <div>
Looks like you&apos;re on the wrong side of town, buddy.
Let&apos;s get you back on the <Link href="/">right side</Link>.
</div> */}
</div>
)}
{children}
</div>
</main>
</section>
);
}

CustomError.getInitialProps = async ({ res, err }: any) => {
// custom server-side props
CustomErrorPage.getInitialProps = async ({ res, err }: any) => {
const statusCode = res ? res.statusCode : err?.statusCode || 404;
const errorInitialProps = await NextErrorComponent.getInitialProps({
res,
err,
} as any);
errorInitialProps.statusCode = statusCode;

return statusCode < 500
? errorInitialProps
: { ...errorInitialProps, statusCode };
return { statusCode, err };
};

export default CustomError;
Loading

0 comments on commit 4991b86

Please sign in to comment.