From d73286d54e673e2a60a2f1565ae941c379361cc6 Mon Sep 17 00:00:00 2001 From: Joshua Ogbonna <58758038+Joshua-Ogbonna@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:06:59 +0000 Subject: [PATCH] chore: profile fix --- package.json | 5 +- pnpm-lock.yaml | 58 +- src/app/brand/[id]/page.js | 524 +++++--- src/app/profile-setting/page.js | 2113 ++++++++++++++++++------------- src/components/BrandEdit.js | 621 +++++++++ src/components/BrandView.js | 328 +++++ 6 files changed, 2561 insertions(+), 1088 deletions(-) create mode 100644 src/components/BrandEdit.js create mode 100644 src/components/BrandView.js diff --git a/package.json b/package.json index c65cff4..42b7cb0 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@coinbase/onchainkit": "^0.35.0", + "@hookform/resolvers": "^3.9.1", "@moralisweb3/next": "^2.26.7", "@react-three/drei": "^9.109.2", "@react-three/fiber": "^8.16.8", @@ -31,6 +32,7 @@ "pino": "^9.2.0", "react": "^18", "react-dom": "^18", + "react-hook-form": "^7.53.1", "react-moralis": "^1.4.2", "react-toastify": "^10.0.5", "tailwind-merge": "^2.3.0", @@ -38,7 +40,8 @@ "three": "^0.167.0", "uuid": "^10.0.0", "viem": "^2.21.22", - "wagmi": "^2.12.17" + "wagmi": "^2.12.17", + "zod": "^3.22.4" }, "devDependencies": { "@types/node": "^20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ca3b07..d1ff6c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@coinbase/onchainkit': specifier: ^0.35.0 version: 0.35.0(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(@xmtp/frames-validator@0.6.2(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(bufferutil@4.0.8)(encoding@0.1.13)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4) + '@hookform/resolvers': + specifier: ^3.9.1 + version: 3.9.1(react-hook-form@7.53.1(react@18.3.1)) '@moralisweb3/next': specifier: ^2.26.7 version: 2.27.2(next-auth@4.24.8(next@14.2.4(@babel/core@7.25.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(next@14.2.4(@babel/core@7.25.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -25,7 +28,7 @@ importers: version: 2.16.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/three@0.163.0)(react@18.3.1)(three@0.167.1) '@readyplayerme/visage': specifier: ^5.2.1 - version: 5.2.2(@react-three/drei@9.114.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/react@18.3.11)(@types/three@0.163.0)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1))(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@react-three/postprocessing@2.16.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/three@0.163.0)(react@18.3.1)(three@0.167.1))(@types/react@18.3.11)(postprocessing@6.36.3(three@0.167.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(suspend-react@0.1.3(react@18.3.1))(three-stdlib@2.33.0(three@0.167.1))(three@0.167.1) + version: 5.2.2(77y7j6k2wh36lq4o7jpmcdawda) '@supabase/ssr': specifier: 0.3.0 version: 0.3.0(@supabase/supabase-js@2.45.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -37,7 +40,7 @@ importers: version: 5.59.13(react@18.3.1) '@web3modal/wagmi': specifier: ^5.1.11 - version: 5.1.11(@types/react@18.3.11)(@wagmi/connectors@5.1.15(@types/react@18.3.11)(@wagmi/core@2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)))(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4))(@wagmi/core@2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)))(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(wagmi@2.12.17(@tanstack/query-core@5.59.13)(@tanstack/react-query@5.59.13(react@18.3.1))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4)) + version: 5.1.11(4bgwviibhtp5ogz6m55z7sujoy) axios: specifier: ^1.7.5 version: 1.7.7 @@ -74,6 +77,9 @@ importers: react-dom: specifier: ^18 version: 18.3.1(react@18.3.1) + react-hook-form: + specifier: ^7.53.1 + version: 7.53.1(react@18.3.1) react-moralis: specifier: ^1.4.2 version: 1.4.2(moralis-v1@1.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -98,6 +104,9 @@ importers: wagmi: specifier: ^2.12.17 version: 2.12.17(@tanstack/query-core@5.59.13)(@tanstack/react-query@5.59.13(react@18.3.1))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4) + zod: + specifier: ^3.22.4 + version: 3.22.4 devDependencies: '@types/node': specifier: ^20 @@ -1013,6 +1022,11 @@ packages: '@hapi/topo@5.1.0': resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==} + '@hookform/resolvers@3.9.1': + resolution: {integrity: sha512-ud2HqmGBM0P0IABqoskKWI6PEf6ZDDBZkFqe2Vnl+mTHCEHzr3ISjjZyCwTjC/qpL25JC9aIDkloQejvMeq0ug==} + peerDependencies: + react-hook-form: ^7.0.0 + '@humanwhocodes/config-array@0.13.0': resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} engines: {node: '>=10.10.0'} @@ -4837,6 +4851,12 @@ packages: peerDependencies: react: ^18.3.1 + react-hook-form@7.53.1: + resolution: {integrity: sha512-6aiQeBda4zjcuaugWvim9WsGqisoUk+etmFEsSUMm451/Ic8L/UAb7sRtMj3V+Hdzm6mMjU1VhiSzYUZeBm0Vg==} + engines: {node: '>=18.0.0'} + peerDependencies: + react: ^16.8.0 || ^17 || ^18 || ^19 + react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} @@ -7456,6 +7476,10 @@ snapshots: dependencies: '@hapi/hoek': 9.3.0 + '@hookform/resolvers@3.9.1(react-hook-form@7.53.1(react@18.3.1))': + dependencies: + react-hook-form: 7.53.1(react@18.3.1) + '@humanwhocodes/config-array@0.13.0': dependencies: '@humanwhocodes/object-schema': 2.0.3 @@ -8441,8 +8465,8 @@ snapshots: transitivePeerDependencies: - '@types/three' - ? '@readyplayerme/visage@5.2.2(@react-three/drei@9.114.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/react@18.3.11)(@types/three@0.163.0)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1))(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@react-three/postprocessing@2.16.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/three@0.163.0)(react@18.3.1)(three@0.167.1))(@types/react@18.3.11)(postprocessing@6.36.3(three@0.167.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(suspend-react@0.1.3(react@18.3.1))(three-stdlib@2.33.0(three@0.167.1))(three@0.167.1)' - : dependencies: + '@readyplayerme/visage@5.2.2(77y7j6k2wh36lq4o7jpmcdawda)': + dependencies: '@react-three/drei': 9.114.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/react@18.3.11)(@types/three@0.163.0)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1) '@react-three/fiber': 8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1) '@react-three/postprocessing': 2.16.3(@react-three/fiber@8.17.10(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(three@0.167.1))(@types/three@0.163.0)(react@18.3.1)(three@0.167.1) @@ -9571,8 +9595,8 @@ snapshots: lit: 3.1.0 qrcode: 1.5.3 - ? '@web3modal/wagmi@5.1.11(@types/react@18.3.11)(@wagmi/connectors@5.1.15(@types/react@18.3.11)(@wagmi/core@2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)))(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4))(@wagmi/core@2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)))(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(wagmi@2.12.17(@tanstack/query-core@5.59.13)(@tanstack/react-query@5.59.13(react@18.3.1))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(immer@9.0.21)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4))' - : dependencies: + '@web3modal/wagmi@5.1.11(4bgwviibhtp5ogz6m55z7sujoy)': + dependencies: '@wagmi/connectors': 5.1.15(@types/react@18.3.11)(@wagmi/core@2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)))(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react-native@0.75.4(@babel/core@7.25.8)(@babel/preset-env@7.25.8(@babel/core@7.25.8))(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10))(react@18.3.1)(typescript@5.6.3)(utf-8-validate@5.0.10)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4) '@wagmi/core': 2.13.8(@tanstack/query-core@5.59.13)(@types/react@18.3.11)(immer@9.0.21)(react@18.3.1)(typescript@5.6.3)(viem@2.21.23(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.22.4)) '@walletconnect/ethereum-provider': 2.16.1(@types/react@18.3.11)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(utf-8-validate@5.0.10) @@ -10587,8 +10611,8 @@ snapshots: '@typescript-eslint/parser': 8.8.1(eslint@8.57.1)(typescript@5.6.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.0(eslint@8.57.1) eslint-plugin-react: 7.37.1(eslint@8.57.1) eslint-plugin-react-hooks: 5.0.0-canary-7118f5dd7-20230705(eslint@8.57.1) @@ -10607,37 +10631,37 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1): + eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 is-glob: 4.0.3 optionalDependencies: - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - '@typescript-eslint/parser' - eslint-import-resolver-node - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1): + eslint-module-utils@2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): dependencies: debug: 3.2.7 optionalDependencies: '@typescript-eslint/parser': 8.8.1(eslint@8.57.1)(typescript@5.6.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): + eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 @@ -10648,7 +10672,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.8.1(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 @@ -12786,6 +12810,10 @@ snapshots: react: 18.3.1 scheduler: 0.23.2 + react-hook-form@7.53.1(react@18.3.1): + dependencies: + react: 18.3.1 + react-is@16.13.1: {} react-is@17.0.2: {} diff --git a/src/app/brand/[id]/page.js b/src/app/brand/[id]/page.js index 5bca79a..194d64f 100644 --- a/src/app/brand/[id]/page.js +++ b/src/app/brand/[id]/page.js @@ -1,48 +1,63 @@ -"use client" -import React, { useState, useEffect } from 'react' -import Link from 'next/link'; +"use client"; +import React, { useState, useEffect } from "react"; +import Link from "next/link"; +import { useAccount } from "wagmi"; import MostLovedCard from "../../../components/mostLovedCard"; import HotNftCard from "../../../components/hotNftCard"; -import Header1 from '../../../components/header1' -import Footer from '../../../components/footer' +import Header1 from "../../../components/header1"; +import Footer from "../../../components/footer"; const Brand = ({ params }) => { - const brandName = params?.id.replace(/-/g, ' ').replace(/\b\w/g, char => char.toUpperCase()); + const brandName = params?.id + .replace(/-/g, " ") + .replace(/\b\w/g, (char) => char.toUpperCase()); - const [brand, setBrand] = useState([]); + const [brand, setBrand] = useState(); const [collections, setcollections] = useState([]); - const [nfts, setnfts] = useState([]) + const [nfts, setnfts] = useState([]); const [loading, setloading] = useState(false); + const [isOwner, setIsOwner] = useState(false); + const { address: userAddress } = useAccount(); useEffect(() => { const brandmatch = async () => { setloading(true); - const baseUri = process.env.NEXT_PUBLIC_URI || 'https://app.myriadflow.com'; + const baseUri = + process.env.NEXT_PUBLIC_URI || "https://app.myriadflow.com"; try { - const res = await fetch(`${baseUri}/brands/all/554b4903-9a06-4031-98f4-48276c427f78`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' + const res = await fetch( + `${baseUri}/brands/all/554b4903-9a06-4031-98f4-48276c427f78`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - }); - - const phyres = await fetch(`${baseUri}/collections/all/554b4903-9a06-4031-98f4-48276c427f78`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' + ); + + const phyres = await fetch( + `${baseUri}/collections/all/554b4903-9a06-4031-98f4-48276c427f78`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - }); - - const nfts = await fetch(`${baseUri}/phygitals/all/554b4903-9a06-4031-98f4-48276c427f78`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' + ); + + const nfts = await fetch( + `${baseUri}/phygitals/all/554b4903-9a06-4031-98f4-48276c427f78`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - }); + ); if (!res.ok || !phyres.ok || !nfts.ok) { - throw new Error('Failed to fetch data'); + throw new Error("Failed to fetch data"); } const result = await res.json(); @@ -50,203 +65,366 @@ const Brand = ({ params }) => { const phynfts = await nfts.json(); // Find the corresponding brand in result - const matchedBrand = result.find(brand => brand.name === brandName); + const matchedBrand = result.find((brand) => brand.name === brandName); if (matchedBrand) { + const isOwner = + userAddress?.toLowerCase() === + matchedBrand?.payout_address?.toLowerCase(); + console.log(isOwner, matchedBrand, userAddress); + setIsOwner(isOwner); setBrand(matchedBrand); const brandId = matchedBrand.id; // console.log("Brand Id",brandid) - // Filter collections by the brand id - const matchedCollections = collections.filter(collection => collection.brand_id === brandId); + const matchedCollections = collections.filter( + (collection) => collection.brand_id === brandId + ); // Extract the IDs of the matched collections - const matchedCollectionIds = matchedCollections.map(collection => collection.id); + const matchedCollectionIds = matchedCollections.map( + (collection) => collection.id + ); // Filter NFTs by the matched collection IDs - const matchedNFTs = phynfts.filter(nft => matchedCollectionIds.includes(nft.collection_id)); + const matchedNFTs = phynfts.filter((nft) => + matchedCollectionIds.includes(nft.collection_id) + ); setcollections(matchedCollections); - setnfts(matchedNFTs) + setnfts(matchedNFTs); setloading(false); } } catch (error) { - console.error('Error fetching data:', error); + console.error("Error fetching data:", error); setloading(false); } - } + }; brandmatch(); - }, []) - + }, []); return ( <>
-
+
{brand?.name} {brand?.name}
-
- -
- {brand?.name} -
-
-
- {brand?.description} +
+
+
+
+ {brand?.name} +
+
{brand?.description}
- - +
+ {/* {isOwner && ( */} + {/* +
EDIT BRAND
+ */} + {/* )} */} + -
SHARE
+ backgroundOrigin: "border-box", + backgroundClip: "content-box, border-box", + WebkitBackgroundClip: "content-box, border-box", // For Safari + display: "block", + width: "180px", + height: "50px", + textAlign: "center", + }} + > +
SHARE
+ +
+
+ {brand?.website && ( + + Website + + )} + {brand?.twitter && ( + + Website + + )} + {brand?.instagram && ( + + Website + + )} + {brand?.facebook && ( + + Website + + )} + {brand?.discord && ( + + Website + + )} + {brand?.additional_link && + brand.additional_link === "whatsapp" && ( + + WhatsApp + + )} + {brand?.additional_link && + brand.additional_link === "youtube" && ( + + WhatsApp + + )} + {brand?.additional_link && + brand.additional_link === "telegram" && ( + + WhatsApp + + )} + {brand?.additional_link && + brand.additional_link === "linkedin" && ( + + WhatsApp + + )} + {brand?.additional_link && brand.additional_link === "google" && ( + + WhatsApp + + )} + {brand?.additional_link && brand.additional_link === "tiktok" && ( + + WhatsApp + + )} + {brand?.additional_link && + brand.additional_link === "snapchat" && ( + + WhatsApp + + )} + {brand?.additional_link && + brand.additional_link === "pinterest" && ( + + WhatsApp + + )} +
+
- -
- {brand.website && ( - - Website - - )} - {brand.twitter && ( - - Website - - )} - {brand.instagram && ( - - Website - - )} - {brand.facebook && ( - - Website - - )} - {brand.discord && ( - - Website - - )} - {brand.additional_link && brand.additional_link === 'whatsapp' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'youtube' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'telegram' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'linkedin' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'google' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'tiktok' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'snapchat' && ( - - WhatsApp - - )} - {brand.additional_link && brand.additional_link === 'pinterest' && ( - - WhatsApp - - )} - +
+ Collections
- -
Collections
- -
+
{collections?.map((nft, index) => ( ))}
-
Phygitals
+
+ Phygitals +
-
+
{nfts?.map((nft, index) => ( ))}
-
-
+
- {loading && (
{ }} id="popupmodal" > -
-
-
+
+
+
Loading icon {
)} - - ) -} + ); +}; -export default Brand; \ No newline at end of file +export default Brand; diff --git a/src/app/profile-setting/page.js b/src/app/profile-setting/page.js index f75342b..369d480 100644 --- a/src/app/profile-setting/page.js +++ b/src/app/profile-setting/page.js @@ -1,626 +1,883 @@ "use client"; -import React, { useState, useEffect } from 'react'; -import Header1 from '../../components/header1'; -import Footer from '../../components/footer'; -import { useAccount } from 'wagmi'; -import { ToastContainer, toast } from 'react-toastify'; -import 'react-toastify/dist/ReactToastify.css'; -import Link from 'next/link'; -import { v4 as uuidv4 } from 'uuid'; +import React, { useState, useEffect } from "react"; +import Header1 from "../../components/header1"; +import Footer from "../../components/footer"; +import { useAccount } from "wagmi"; +import { ToastContainer, toast } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; +import Link from "next/link"; +import { v4 as uuidv4 } from "uuid"; function ProfileSettingsPage() { - const { address } = useAccount(); + const { address } = useAccount(); - const [displayName, setDisplayName] = useState(''); - const [userName, setUserName] = useState(''); - const [bio, setBio] = useState(''); - const [website, setWebsite] = useState(''); - const [x, setx] = useState(''); - const [instagram, setInstagram] = useState(''); - const [discord, setDiscord] = useState(''); - const [allusernames,setAllUsernames] = useState([]); - const [coverImage, setCoverImage] = useState(''); - const [profileImage, setProfileImage] = useState(''); - const [email, setEmail] = useState(''); - const [profileid, setId] = useState(''); - const [selectedSocialLink, setSelectedSocialLink] = useState(''); - const [link, setLink] = useState(''); + const [displayName, setDisplayName] = useState(""); + const [userName, setUserName] = useState(""); + const [bio, setBio] = useState(""); + const [website, setWebsite] = useState(""); + const [x, setx] = useState(""); + const [instagram, setInstagram] = useState(""); + const [discord, setDiscord] = useState(""); + const [allusernames, setAllUsernames] = useState([]); + const [coverImage, setCoverImage] = useState(""); + const [profileImage, setProfileImage] = useState(""); + const [email, setEmail] = useState(""); + const [profileid, setId] = useState(""); + const [selectedSocialLink, setSelectedSocialLink] = useState(""); + const [link, setLink] = useState(""); - const [isEditing, setIsEditing] = useState(false); - const [isCoverHovered, setIsCoverHovered] = useState(false); - const [isProfileHovered, setIsProfileHovered] = useState(false); - const [isCoverPopupVisible, setIsCoverPopupVisible] = useState(false); - const [isProfilePopupVisible, setIsProfilePopupVisible] = useState(false); - const [selectedFile, setSelectedFile] = useState(null); - const [isUploading, setIsUploading] = useState(false); - const [showForm, setShowForm] = useState(false); - const [isAddressesOpen, setIsAddressesOpen] = useState(false); + const [isEditing, setIsEditing] = useState(false); + const [isCoverHovered, setIsCoverHovered] = useState(false); + const [isProfileHovered, setIsProfileHovered] = useState(false); + const [isCoverPopupVisible, setIsCoverPopupVisible] = useState(false); + const [isProfilePopupVisible, setIsProfilePopupVisible] = useState(false); + const [selectedFile, setSelectedFile] = useState(null); + const [isUploading, setIsUploading] = useState(false); + const [showForm, setShowForm] = useState(false); + const [isAddressesOpen, setIsAddressesOpen] = useState(false); + const [currentSection, setCurrentSection] = useState("profile"); + const [validationError, setValidationError] = useState(""); - const [currentSection, setCurrentSection] = useState('profile'); - const [validationError, setValidationError] = useState(''); + const [addresses, setAddresses] = useState([ + { + id: "", + full_name: "", + street_address: "", + street_address_2: "", + city: "", + pincode: "", + country: "", + }, + ]); + const countries = ["USA", "Canada", "UK", "Australia"]; - const [addresses, setAddresses] = useState([{ id: '', full_name: '', street_address: '', street_address_2: '', city: '', pincode: '', country: '' }]); - const countries = ['USA', 'Canada', 'UK', 'Australia']; + const handleAddAddress = () => { + // Use functional update to ensure the latest state is used + setAddresses((prevAddresses) => [ + ...prevAddresses, + { + id: uuidv4(), + full_name: "", + street_address: "", + street_address_2: "", + city: "", + pincode: "", + country: "", + }, + ]); + }; - const handleAddAddress = () => { - // Use functional update to ensure the latest state is used - setAddresses(prevAddresses => [ - ...prevAddresses, - { id: uuidv4(), full_name: '', street_address: '', street_address_2: '', city: '', pincode: '', country: '' } - ]); - }; + const handleAddressChange = (index, field, value) => { + // Use functional update to ensure the latest state is used + setAddresses((prevAddresses) => { + const newAddresses = [...prevAddresses]; + newAddresses[index][field] = value; + return newAddresses; // Return the updated addresses + }); + }; - const handleAddressChange = (index, field, value) => { - // Use functional update to ensure the latest state is used - setAddresses(prevAddresses => { - const newAddresses = [...prevAddresses]; - newAddresses[index][field] = value; - return newAddresses; // Return the updated addresses - }); - }; + const baseUri = process.env.NEXT_PUBLIC_URI || "https://app.myriadflow.com"; - const baseUri = process.env.NEXT_PUBLIC_URI || 'https://app.myriadflow.com'; + const deleteAddress = async (id) => { + try { + const response = await fetch(`${baseUri}/profiles/addresses/${id}`, { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + }); - const deleteAddress = async (id) => { - try { - const response = await fetch(`${baseUri}/profiles/addresses/${id}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json', - }, - }); + if (response.ok) { + toast.success("Address deleted successfully!"); + window.location.reload(); + } else { + const errorData = await response.json(); + toast.error(`Failed to delete address: ${errorData.error}`); + } + } catch (error) { + console.error("Error:", error); + toast.error("An error occurred while deleting the address."); + } + }; - if (response.ok) { - toast.success('Address deleted successfully!'); - window.location.reload(); - } else { - const errorData = await response.json(); - toast.error(`Failed to delete address: ${errorData.error}`); - } - } catch (error) { - console.error('Error:', error); - toast.error('An error occurred while deleting the address.'); + const deleteAccount = async () => { + try { + const response = await fetch( + `${baseUri}/profiles/walletandemail/${address}/${email}`, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, } - }; + ); - const deleteAccount = async () => { - try { - const response = await fetch(`${baseUri}/profiles/walletandemail/${address}/${email}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json', - }, - }); + if (response.ok) { + toast.success("Account deleted successfully!"); + window.location.reload(); + } else { + const errorData = await response.json(); + toast.error(`Failed to delete account: ${errorData.error}`); + } + } catch (error) { + console.error("Error:", error); + toast.error("An error occurred while deleting the account."); + } + }; - if (response.ok) { - toast.success('Account deleted successfully!'); - window.location.reload(); - } else { - const errorData = await response.json(); - toast.error(`Failed to delete account: ${errorData.error}`); - } - } catch (error) { - console.error('Error:', error); - toast.error('An error occurred while deleting the account.'); - } - }; + const handleDelete = () => { + setShowForm(true); + }; + + const handleSave = async () => { + // Validate username length + if (userName.length < 4) { + setValidationError("Username must be at least 4 characters long."); + return; + } else if (userName !== userName.toLowerCase()) { + setValidationError("Username must be in lowercase."); + return; + } else if (userName.includes(" ")) { + setValidationError("Username cannot contain spaces."); + return; + } else if (allusernames.some((profile) => profile.username === userName)) { + setValidationError("This username is already taken."); + return; + } else if (!/^[a-z]+$/.test(userName)) { + setValidationError( + "Username can only contain letters (no special characters)." + ); + return; + } else { + setValidationError(""); + } - const handleDelete = () => { - setShowForm(true) + const profileData = { + name: displayName, + email: email, + username: userName, + bio: bio, + website: website, + x: x, + instagram: instagram, + discord: discord, + cover_image: coverImage, + profile_image: profileImage, + selected_social_link: selectedSocialLink, + link: link, }; - const handleSave = async () => { - // Validate username length - if (userName.length < 4) { - setValidationError('Username must be at least 4 characters long.'); - return; - } else if (userName !== userName.toLowerCase()) { - setValidationError('Username must be in lowercase.'); - return; - } else if (userName.includes(' ')) { - setValidationError('Username cannot contain spaces.'); - return; - } else if (allusernames.some(profile => profile.username === userName)) { - setValidationError('This username is already taken.'); - return; - } else if (!/^[a-z]+$/.test(userName)) { - setValidationError('Username can only contain letters (no special characters).'); - return; - } else { - setValidationError(''); - } + try { + const response = await fetch(`${baseUri}/profiles/${address}`, { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(profileData), + }); - const profileData = { - name: displayName, - email: email, - username: userName, - bio: bio, - website: website, - x: x, - instagram: instagram, - discord: discord, - cover_image: coverImage, - profile_image: profileImage, - selected_social_link: selectedSocialLink, - link: link - }; + await Promise.all( + addresses.map(async (addressesall, index) => { + if (addressesall.id && addressesall.id === addressesall.id) { + try { + const addressData = await fetch( + `${baseUri}/profiles/addresses/${profileid}`, + { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(addresses), + } + ); - try { - const response = await fetch(`${baseUri}/profiles/${address}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(profileData) - }); + if (addressData.ok) { + console.log("Address Updated Successfully"); + } + } catch (error) { + console.error("Error fetching address data", error); + } + } else { + try { + const responseAddress = await fetch( + `${baseUri}/profiles/addresses/${profileid}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(addresses), + } + ); + if (responseAddress.ok) { + console.log("Address Added Successfully"); + } + } catch (error) { + console.error("Failed to save profile settings."); + } + } + }) + ); - await Promise.all(addresses.map(async (addressesall, index) => { - if (addressesall.id && addressesall.id === addressesall.id) { - try { - const addressData = await fetch(`${baseUri}/profiles/addresses/${profileid}`, { - method: "PUT", - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(addresses) - }); + if (response.ok) { + console.log("Profile settings saved successfully!"); + setIsEditing(false); + } else { + console.error("Failed to save profile settings."); + } + } catch (error) { + console.error("Error:", error); + } + }; - if (addressData.ok) { - console.log("Address Updated Successfully"); - } - } catch (error) { - console.error('Error fetching address data', error); - } - } else { - try { - const responseAddress = await fetch(`${baseUri}/profiles/addresses/${profileid}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(addresses) - }); - if (responseAddress.ok) { - console.log("Address Added Successfully"); - } - } catch (error) { - console.error('Failed to save profile settings.'); - } - } - })); + const handleFileChange = (event) => { + const files = event.target.files; + if (files && files.length > 0) { + setSelectedFile(files[0]); + } + }; - if (response.ok) { - console.log('Profile settings saved successfully!'); - setIsEditing(false); - } else { - console.error('Failed to save profile settings.'); - } - } catch (error) { - console.error('Error:', error); - } - }; + const handleFileUpload = async (type) => { + if (!selectedFile) return; + setIsUploading(true); + const formData = new FormData(); + formData.set("file", selectedFile); - const handleFileChange = (event) => { - const files = event.target.files; - if (files && files.length > 0) { - setSelectedFile(files[0]); + try { + const response = await fetch("/api/files", { + method: "POST", + body: formData, + }); + + if (response.ok) { + const data = await response.json(); + const ipfsHash = data.IpfsHash; + if (type === "cover") { + setCoverImage(ipfsHash); + console.log("Coverimage", coverImage); + setIsCoverPopupVisible(false); + } else if (type === "profile") { + setProfileImage(ipfsHash); + setIsProfilePopupVisible(false); } - }; + setIsEditing(true); // Enable save button after upload + } else { + console.error("Failed to upload image."); + } + } catch (error) { + console.error("Error uploading file:", error); + } finally { + setIsUploading(false); + } + }; - const handleFileUpload = async (type) => { - if (!selectedFile) return; - setIsUploading(true); - const formData = new FormData(); - formData.set('file', selectedFile); + const handleEditClick = (type) => { + if (type === "cover") { + setIsCoverPopupVisible(true); + } else if (type === "profile") { + setIsProfilePopupVisible(true); + } + }; - try { - const response = await fetch("/api/files", { - method: 'POST', - body: formData - }); + const handleButtonClick = (section) => { + setCurrentSection(section); + }; - if (response.ok) { - const data = await response.json(); - const ipfsHash = data.IpfsHash; - if (type === 'cover') { - setCoverImage(ipfsHash); - console.log("Coverimage", coverImage) - setIsCoverPopupVisible(false); - } else if (type === 'profile') { - setProfileImage(ipfsHash); - setIsProfilePopupVisible(false); - } - setIsEditing(true); // Enable save button after upload - } else { - console.error('Failed to upload image.'); + useEffect(() => { + const getUserData = async () => { + if (address) { + try { + const response = await fetch( + `${baseUri}/profiles/wallet/${address}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - } catch (error) { - console.error('Error uploading file:', error); - } finally { - setIsUploading(false); - } - }; + ); - const handleEditClick = (type) => { - if (type === 'cover') { - setIsCoverPopupVisible(true); - } else if (type === 'profile') { - setIsProfilePopupVisible(true); + if (response.ok) { + const data = await response.json(); + setId(data.id); + setDisplayName(data.name); + setUserName(data.username); + setCoverImage(data.cover_image); + setProfileImage(data.profile_image); + setBio(data.bio); + setWebsite(data.website); + setx(data.x); + setInstagram(data.instagram); + setDiscord(data.discord); + setSelectedSocialLink(data.selected_social_link); + setLink(data.link); + setEmail(data.email); + } else { + console.log("No user found"); + } + } catch (error) { + console.error("Error fetching user data", error); } + } }; + getUserData(); + }, [address]); - const handleButtonClick = (section) => { - setCurrentSection(section); - }; - - useEffect(() => { - const getUserData = async () => { - if (address) { - try { - const response = await fetch(`${baseUri}/profiles/wallet/${address}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - }); - - if (response.ok) { - const data = await response.json(); - setId(data.id); - setDisplayName(data.name); - setUserName(data.username); - setCoverImage(data.cover_image); - setProfileImage(data.profile_image); - setBio(data.bio); - setWebsite(data.website); - setx(data.x); - setInstagram(data.instagram); - setDiscord(data.discord); - setSelectedSocialLink(data.selected_social_link); - setLink(data.link); - setEmail(data.email); - } else { - console.log('No user found'); - } - } catch (error) { - console.error('Error fetching user data', error); - } + useEffect(() => { + if (profileid) { + const getAddressData = async () => { + try { + const addressData = await fetch( + `${baseUri}/profiles/addresses/${profileid}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - }; - getUserData(); - }, [address]); + ); - useEffect(() => { - if (profileid) { - const getAddressData = async () => { - try { - const addressData = await fetch(`${baseUri}/profiles/addresses/${profileid}`, { - method: "GET", - headers: { - 'Content-Type': 'application/json', - }, - }); + if (addressData.ok) { + const addressdata = await addressData.json(); + setAddresses(addressdata); + } + } catch (error) { + console.error("Error fetching address data", error); + } + }; - if (addressData.ok) { - const addressdata = await addressData.json(); - setAddresses(addressdata); - } - } catch (error) { - console.error('Error fetching address data', error); - } - }; + getAddressData(); + } + }, [profileid]); + + useEffect(() => { + if (address) { + const getAllProfile = async () => { + try { + const usernameData = await fetch(`${baseUri}/profiles/all`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }); - getAddressData(); + if (usernameData.ok) { + const usernamedata = await usernameData.json(); + setAllUsernames(usernamedata); + } + } catch (error) { + console.error("Error fetching address data", error); } - }, [profileid]) + }; - useEffect(() => { - if (address) { - const getAllProfile = async () => { - try { - const usernameData = await fetch(`${baseUri}/profiles/all`, { - method: "GET", - headers: { - 'Content-Type': 'application/json', - }, - }); + getAllProfile(); + } + }, [address]); - if (usernameData.ok) { - const usernamedata = await usernameData.json(); - setAllUsernames(usernamedata); - } - } catch (error) { - console.error('Error fetching address data', error); - } - }; + return ( + <> +
+ +
- getAllProfile(); - } - }, [address]) +

+ Profile Settings +

+
+ {/* Sidebar */} +
+ {" "} +
+ {" "} +
+ + {instagram || x ? ( +
+

+ You have completed the verification process. Your profile is + visible on the Users page. +

- return ( - <> -
- + Verified Icon + + +
+ ) : ( +
+ Verified Icon +

+ Click to proceed with the verification process to become a + creator and gain the trust of the community! +

+ +
+ )} +
-

Profile Settings

-
- {/* Sidebar */} -
-
-
+ {/* Main Content */} +
+ {currentSection === "profile" ? ( + <> + {/* Cover image */} +
setIsCoverHovered(true)} + onMouseLeave={() => setIsCoverHovered(false)} + onClick={() => handleEditClick("cover")} + > + {isCoverHovered && ( + + )} + +
setIsProfileHovered(true)} + onMouseLeave={() => setIsProfileHovered(false)} + onClick={() => handleEditClick("profile")} + > + Profile + + {isProfileHovered && ( - {instagram || x ? ( -
-

You have completed the verification process. Your profile is visible on the Users page.

- - Verified Icon - - - -
- ) : ( -
- Verified Icon -

Click to proceed with the verification process to become a creator and gain the trust of the community!

- -
- )} - + )}
+
- {/* Main Content */} -
- {currentSection === 'profile' ? ( - <> - {/* Cover image */} -
setIsCoverHovered(true)} - onMouseLeave={() => setIsCoverHovered(false)} - onClick={() => handleEditClick('cover')} - > - {isCoverHovered && ( - - )} - - -
setIsProfileHovered(true)} - onMouseLeave={() => setIsProfileHovered(false)} - onClick={() => handleEditClick('profile')} - > - Profile - - {isProfileHovered && ( - - )} -
-
+
+ + { + setDisplayName(e.target.value); + setIsEditing(true); + }} + style={{ + padding: "10px", + borderRadius: "8px", + border: "1px solid #D1D5DB", + width: "50%", + marginBottom: "20px", + }} + /> + + { + setEmail(e.target.value); + setIsEditing(true); + }} + style={{ + padding: "10px", + borderRadius: "8px", + border: "1px solid #D1D5DB", + width: "50%", + marginBottom: "20px", + }} + /> -
- - { - setDisplayName(e.target.value); - setIsEditing(true); - }} - style={{ padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB', width: '50%', marginBottom: '20px' }} - /> - - { - setEmail(e.target.value); - setIsEditing(true); - }} - style={{ padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB', width: '50%', marginBottom: '20px' }} - /> - - - { - setUserName(e.target.value); - setIsEditing(true); - }} - style={{ padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB', width: '50%', marginBottom: '20px' }} - /> - {validationError && ( -

- {validationError} -

- )} - - -