From eb7978e326f2c757f8e7dd018c4641f2cea59b9d Mon Sep 17 00:00:00 2001 From: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:18:53 +0200 Subject: [PATCH] Implement `EditProfile` container (#1427) * feat: add delete profile hook * feat: add profile editing * fix: update Header import * chore: remove sfx from confetti * fix: update jotai type * chore: add comment to assertion * chore: add ts path alias for @app dir * refactor: apply write-check * feat: remove profile atom and add swr hooks * feat: add ssr to page * feat: add profile owner guard * feat: add ssr with swr fallback * feat: add ssr with swr fallback for guild and role * chore: add note why use constant api url * chore: resolve schema errors in profile update --- package-lock.json | 8 +- package.json | 2 +- .../_components/StartProfile.tsx | 6 +- .../_hooks/useCreateProfile.tsx | 4 +- .../{create-profile => }/layout.tsx | 0 .../(marketing)/profile/[username]/atoms.ts | 5 - .../(marketing)/profile/[username]/page.tsx | 258 +++++++----------- .../profile/_components/ContributionCard.tsx | 10 +- .../profile/_components/EditContributions.tsx | 12 +- .../profile/_components/EditProfile.tsx | 66 +++-- .../profile/_components/OperatedGuildCard.tsx | 6 +- .../profile/_components/Profile.tsx | 93 +++++++ .../profile/_components/ProfileOwnerGuard.tsx | 14 + .../profile/_components/ProfileSkeleton.tsx | 103 +++---- .../profile/_hooks/useContribution.tsx | 2 +- .../profile/_hooks/useCreateContribution.tsx | 8 +- .../profile/_hooks/useDeleteContribution.tsx | 10 +- .../profile/_hooks/useDeleteProfile.ts | 38 +++ .../profile/_hooks/useUpdateContribution.tsx | 13 +- .../profile/_hooks/useUpdateProfile.ts | 47 ++++ .../_server_actions/revalidateContribution.ts | 7 + .../_server_actions/revalidateProfile.ts | 7 + src/v2/components/Confetti.tsx | 2 +- src/v2/components/SWRProvider.tsx | 11 + src/v2/lib/validations/profileSchema.ts | 41 +-- tsconfig.json | 3 +- 26 files changed, 476 insertions(+), 300 deletions(-) rename src/app/(marketing)/{create-profile => }/layout.tsx (100%) delete mode 100644 src/app/(marketing)/profile/[username]/atoms.ts create mode 100644 src/app/(marketing)/profile/_components/Profile.tsx create mode 100644 src/app/(marketing)/profile/_components/ProfileOwnerGuard.tsx create mode 100644 src/app/(marketing)/profile/_hooks/useDeleteProfile.ts create mode 100644 src/app/(marketing)/profile/_hooks/useUpdateProfile.ts create mode 100644 src/app/(marketing)/profile/_server_actions/revalidateContribution.ts create mode 100644 src/app/(marketing)/profile/_server_actions/revalidateProfile.ts create mode 100644 src/v2/components/SWRProvider.tsx diff --git a/package-lock.json b/package-lock.json index cf71af1034..e0692055fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "^1.9.30", + "@guildxyz/types": "^1.9.33", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -5476,9 +5476,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.30", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.30.tgz", - "integrity": "sha512-iSsYWu33IHXwy1MyDpeEspMVjLrpK4mX0UvLuwH/kuyoNjMUVFBWA1I1blw1t2g6CGBIbXL1ln8QjurrUS4+qg==", + "version": "1.9.33", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.33.tgz", + "integrity": "sha512-iekXya6x1D5nQufmNfw9NDpvjDHdDsNAuNF13/gf3yRbdp9jIJ7P+RIhJ/fGX4rX4tMomYauJ18BJNQTC/m6cQ==", "dependencies": { "zod": "^3.22.4" } diff --git a/package.json b/package.json index 237555df68..00700dce22 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "^1.9.30", + "@guildxyz/types": "^1.9.33", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/app/(marketing)/create-profile/_components/StartProfile.tsx b/src/app/(marketing)/create-profile/_components/StartProfile.tsx index 51062345e4..dc61028fc3 100644 --- a/src/app/(marketing)/create-profile/_components/StartProfile.tsx +++ b/src/app/(marketing)/create-profile/_components/StartProfile.tsx @@ -148,13 +148,11 @@ export const StartProfile: OnboardingChain = () => { {method === undefined ? ( <> -
- -
+ Connect farcaster
- -
- - - Edit profile - - - + + + Edit profile + + + + + +
( - +
{field.value ? ( { variant="unstyled" type="button" className={cn( - "-bottom-2 absolute left-4 size-28 translate-y-1/2 rounded-full border border-dotted", + "-bottom-2 absolute left-4 size-28 translate-y-1/2 rounded-full border-2 border-dotted", { "border-solid": field.value } )} {...getRootProps()} @@ -166,7 +180,12 @@ export const EditProfile = (profile: Schemas["ProfileUpdate"]) => { Name - + @@ -189,34 +208,37 @@ export const EditProfile = (profile: Schemas["ProfileUpdate"]) => { control={form.control} name="bio" render={({ field }) => ( - + Bio