From 8e3cee5680a10c0f618d72de9174abde0e7357d6 Mon Sep 17 00:00:00 2001 From: Ogheneochuko <7204868+amochuko@users.noreply.github.com> Date: Tue, 21 May 2024 19:44:51 +0100 Subject: [PATCH 01/46] added react-vite --- react-vite/.eslintrc.cjs | 22 + react-vite/.gitignore | 24 + react-vite/README.md | 30 + react-vite/index.html | 13 + react-vite/package-lock.json | 4493 ++++++++++++++++++++++++++++++ react-vite/package.json | 33 + react-vite/postcss.config.js | 6 + react-vite/src/App.css | 37 + react-vite/src/App.tsx | 33 + react-vite/src/constant/index.ts | 4 + react-vite/src/index.css | 58 + react-vite/src/main.tsx | 10 + react-vite/src/utils/bee-node.ts | 7 + react-vite/src/vite-env.d.ts | 1 + react-vite/tailwind.config.js | 41 + react-vite/tsconfig.json | 25 + react-vite/tsconfig.node.json | 11 + react-vite/vite.config.ts | 7 + 18 files changed, 4855 insertions(+) create mode 100644 react-vite/.eslintrc.cjs create mode 100644 react-vite/.gitignore create mode 100644 react-vite/README.md create mode 100644 react-vite/index.html create mode 100644 react-vite/package-lock.json create mode 100644 react-vite/package.json create mode 100644 react-vite/postcss.config.js create mode 100644 react-vite/src/App.css create mode 100644 react-vite/src/App.tsx create mode 100644 react-vite/src/constant/index.ts create mode 100644 react-vite/src/index.css create mode 100644 react-vite/src/main.tsx create mode 100644 react-vite/src/utils/bee-node.ts create mode 100644 react-vite/src/vite-env.d.ts create mode 100644 react-vite/tailwind.config.js create mode 100644 react-vite/tsconfig.json create mode 100644 react-vite/tsconfig.node.json create mode 100644 react-vite/vite.config.ts diff --git a/react-vite/.eslintrc.cjs b/react-vite/.eslintrc.cjs new file mode 100644 index 0000000..86f250c --- /dev/null +++ b/react-vite/.eslintrc.cjs @@ -0,0 +1,22 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react/jsx-runtime', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, + settings: { react: { version: '18.2' } }, + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + 'react/prop-types': 0, + }, +}; diff --git a/react-vite/.gitignore b/react-vite/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/react-vite/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/react-vite/README.md b/react-vite/README.md new file mode 100644 index 0000000..0d6babe --- /dev/null +++ b/react-vite/README.md @@ -0,0 +1,30 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default { + // other rules... + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json', './tsconfig.node.json'], + tsconfigRootDir: __dirname, + }, +} +``` + +- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` +- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/react-vite/index.html b/react-vite/index.html new file mode 100644 index 0000000..b0c6e48 --- /dev/null +++ b/react-vite/index.html @@ -0,0 +1,13 @@ + + +
+ + + ++ Node status:{" "} + + {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"} +
++ + {" "} + BatchID: + {" "} + {trimText(ps.batchID)} +
++ Label: {ps.label} +
++ BlockNumber:{" "} + {ps.blockNumber} +
++ Amount: {ps.amount} +
++ BucketDepth:{" "} + {ps.bucketDepth} +
++ Utilization:{" "} + {ps.utilization} +
++ Exists:{" "} + {ps.exists ? "Yes" : "No"} +
++ Depth: {ps.depth} +
++ Immutable Flag:{" "} + {ps.immutableFlag} +
++ Usable:{" "} + {ps.usable ? "Yes" : "No"} +
++ BatchTTL: {ps.batchTTL} +
++ Total number of Postage Stamps: {postageStamps?.length} +
+ )} ++ Node status:{" "} + + {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"} +
+- Node status:{" "} - - {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"} -
-- Node status:{" "} - - {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"} -
-+ Node status:{" "} + + {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"} +
++ + {" "} + BatchID: + {" "} + {format.trimText(ps.batchID)} +
++ Label: {ps.label} +
++ BlockNumber:{" "} + {ps.blockNumber} +
++ Amount: {ps.amount} +
++ BucketDepth:{" "} + {ps.bucketDepth} +
++ Utilization:{" "} + {ps.utilization} +
++ Exists:{" "} + {ps.exists ? "Yes" : "No"} +
++ Depth: {ps.depth} +
++ Immutable Flag:{" "} + {ps.immutableFlag} +
++ Usable:{" "} + {ps.usable ? "Yes" : "No"} +
++ BatchTTL: {ps.batchTTL} +
+You don't have any Postage Stamp
} + + {postageStamps && postageStamps?.length > 0 && ( +Total number of Postage Stamps: {postageStamps?.length}
+ )} +{isLoading && "Loading balance..."}
+{error && "Error loading balance..."}
+ {!isLoading && !error && ( +- Node status:{" "} {nodeHealth?.status == "ok" ? "Connected" : "Disconnected"}
- +{isLoading && "Loading balance..."}
-{error && "Error loading balance..."}
- {!isLoading && !error && ( -{isLoading && "Loading balance..."}
+{error && "Error loading balance..."}
+ + {!isLoading && !error && ( +{error}
@@ -125,6 +164,7 @@ export const UploadFile = () => {Reference: {uploadResultWithCid.reference}
-Tag Uid: {uploadResultWithCid.tagUid}
-CID: {uploadResultWithCid.cid()}
-+
+ Reference: + {uploadResultWithCid.reference} +
++ Tag UID:{" "} + {uploadResultWithCid.tagUid} +
++ CID:{" "} + {uploadResultWithCid.cid()} +
++ Link: {" "} {
+ Reference: + {props.uploadResultWithCid.reference} +
++ Tag UID:{" "} + {props.uploadResultWithCid.tagUid} +
++ CID:{" "} + {props.uploadResultWithCid.cid()} +
++ Link: {" "} + + {`${props.link}/${props.uploadResultWithCid.reference}/`} + +
+
Batch ID:
diff --git a/react-vite/src/components/PostageStamps.tsx b/react-vite/src/components/PostageStamps.tsx
index cfddf9b..725f7df 100644
--- a/react-vite/src/components/PostageStamps.tsx
+++ b/react-vite/src/components/PostageStamps.tsx
@@ -1,83 +1,12 @@
-import { usePostageBatch } from "../hooks/usePostageBatch";
-import { copyText, trimText } from "../utils/format";
-export function PostageStamps() {
- const {
- getAllPostageStamps,
- postageStamps,
- getAllStampError,
- isLoadingStamps,
- } = usePostageBatch();
+import { BuyPostageStamp } from "./BuyPostageStamp";
+import { GetPostageStamps } from "./GetPostageStamps";
+export function PostageStamps() {
return (
-
-
- {" "}
- BatchID:
- {" "}
- {trimText(ps.batchID)}
-
- Label: {ps.label}
-
- BlockNumber:{" "}
- {ps.blockNumber}
-
- Amount: {ps.amount}
-
- BucketDepth:{" "}
- {ps.bucketDepth}
-
- Utilization:{" "}
- {ps.utilization}
-
- Exists:{" "}
- {ps.exists ? "Yes" : "No"}
-
- Depth: {ps.depth}
-
- Immutable Flag:{" "}
- {ps.immutableFlag}
-
- Usable:{" "}
- {ps.usable ? "Yes" : "No"}
-
- BatchTTL: {ps.batchTTL}
-
- Total number of Postage Stamps: {postageStamps?.length}
-
- {isLoadingStamps &&
- {postageStamps && (
-
{error}
+{error}
> )} - {uploadResultWithCid && ( -- Reference: - {uploadResultWithCid.reference} -
-- Tag UID:{" "} - {uploadResultWithCid.tagUid} -
-- CID:{" "} - {uploadResultWithCid.cid()} -
-- Link: {" "} - - {`${API_URL}/bzz/${uploadResultWithCid.reference}/`} - -
-