From b02fe25c65ce1a748de503aa9d0c653160f25e12 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 29 Feb 2024 15:44:20 +0100 Subject: [PATCH 1/6] fix: Roles address leading to duplicate empty string violating address unique constraint --- .../RolesForm/components/RoleField/RoleField.AddNewProfile.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.AddNewProfile.tsx b/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.AddNewProfile.tsx index ec800560a9..001bb0d951 100644 --- a/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.AddNewProfile.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.AddNewProfile.tsx @@ -25,6 +25,7 @@ export const AddNewProfile: React.FC = ({ profileType: AccountType.User, name: '', profileImage: DEFAULT_PROFILE_USER_AVATAR, + address: null, }); }} > From d31ada10dcebaa6ab52f6e9b58370e5baa89d057 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 29 Feb 2024 16:26:53 +0100 Subject: [PATCH 2/6] fix: add missing onUpload to RolesField --- .../components/organisms/RolesForm/RolesForm.tsx | 13 +++++++++++++ .../components/ProfileModal/ProfileModal.tsx | 2 +- .../RolesForm/components/RoleField/RoleField.tsx | 3 +++ .../organisms/RolesForm/hooks/useSaveProfile.tsx | 1 + web-marketplace/src/pages/Roles/Roles.tsx | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/web-marketplace/src/components/organisms/RolesForm/RolesForm.tsx b/web-marketplace/src/components/organisms/RolesForm/RolesForm.tsx index 1d57f81148..00b239f77d 100644 --- a/web-marketplace/src/components/organisms/RolesForm/RolesForm.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/RolesForm.tsx @@ -14,6 +14,7 @@ import OnBoardingCard from 'web-components/src/components/cards/OnBoardingCard'; import EditIcon from 'web-components/src/components/icons/EditIcon'; import TextField from 'web-components/src/components/inputs/new/TextField/TextField'; +import { apiUri } from 'lib/apiUri'; import { errorBannerTextAtom } from 'lib/atoms/error.atoms'; import { useAuth } from 'lib/auth/auth'; import { getAccountByAddrQuery } from 'lib/queries/react-query/registry-server/graphql/getAccountByAddrQuery/getAccountByAddrQuery'; @@ -31,6 +32,7 @@ import { ProfileModalSchemaType } from './components/ProfileModal/ProfileModal.s import { RoleField } from './components/RoleField/RoleField'; import { useSaveProfile } from './hooks/useSaveProfile'; import { rolesFormSchema, RolesFormSchemaType } from './RolesForm.schema'; +import { useHandleUpload } from '../MediaForm/hooks/useHandleUpload'; interface RolesFormProps { submit: (props: RoleSubmitProps) => Promise; @@ -38,10 +40,12 @@ interface RolesFormProps { onPrev?: () => void; initialValues?: RolesFormSchemaType; isOnChain: boolean; + projectId?: string; } const RolesForm: React.FC> = ({ initialValues, + projectId, submit, onNext, onPrev, @@ -127,6 +131,13 @@ const RolesForm: React.FC> = ({ const saveProfile = useSaveProfile(); + const [offChainProjectId, setOffChainProjectId] = useState(projectId); + const { handleUpload } = useHandleUpload({ + offChainProjectId, + apiServerUrl: apiUri, + setOffChainProjectId, + }); + return (
> = ({ accounts={accountsProjectDeveloper} saveProfile={saveProfile} activeAccountId={activeAccountId} + onUpload={handleUpload} {...form.register('projectDeveloper')} /> > = ({ accounts={accountsVerifier} saveProfile={saveProfile} activeAccountId={activeAccountId} + onUpload={handleUpload} {...form.register('verifier')} /> {isOnChain && admin && ( diff --git a/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx b/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx index 96d593abee..7b8d96d7a1 100644 --- a/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx @@ -26,7 +26,7 @@ interface ProfileModalProps { initialValues?: ProfileModalSchemaType; onClose: () => void; onSubmit: (profile: ProfileModalSchemaType) => void; - onUpload?: (imageFile: File) => Promise; + onUpload?: (imageFile: File) => Promise; } function ProfileModal({ diff --git a/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.tsx b/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.tsx index 91a8c063c9..eb0e3805d8 100644 --- a/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/components/RoleField/RoleField.tsx @@ -49,6 +49,7 @@ interface Props { profile: ProfileModalSchemaType, initialValue?: ProfileModalSchemaType | null, ) => Promise<{ id: string; creatorId: string } | undefined>; + onUpload?: (imageFile: File) => Promise; } export const RoleField = forwardRef( @@ -67,6 +68,7 @@ export const RoleField = forwardRef( accounts, saveProfile, activeAccountId, + onUpload, }: Props, ref, ) => { @@ -210,6 +212,7 @@ export const RoleField = forwardRef( {profileAdd && ( { const account = await saveProfile(profile); diff --git a/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx b/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx index b2843edbf5..8f5ee0d577 100644 --- a/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx @@ -34,6 +34,7 @@ export const useSaveProfile = () => { addr: profile.address, creatorId: activeAccountId, }; + if (edit) { await updateAccount({ variables: { diff --git a/web-marketplace/src/pages/Roles/Roles.tsx b/web-marketplace/src/pages/Roles/Roles.tsx index 199a384276..3f0d16522c 100644 --- a/web-marketplace/src/pages/Roles/Roles.tsx +++ b/web-marketplace/src/pages/Roles/Roles.tsx @@ -96,6 +96,7 @@ const Roles: React.FC> = () => { isOnChain={ !editContextLoading && !!onChainProject && !!wallet?.address } + projectId={offChainProject?.id} /> From 4d194f94ff9cdcdf0e5ace7e3bd5aed12a0ff8f5 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 29 Feb 2024 16:28:55 +0100 Subject: [PATCH 3/6] chore: rm space --- .../src/components/organisms/RolesForm/hooks/useSaveProfile.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx b/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx index 8f5ee0d577..b2843edbf5 100644 --- a/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx +++ b/web-marketplace/src/components/organisms/RolesForm/hooks/useSaveProfile.tsx @@ -34,7 +34,6 @@ export const useSaveProfile = () => { addr: profile.address, creatorId: activeAccountId, }; - if (edit) { await updateAccount({ variables: { From d23ab624af2b6b6a992d5ea2abb400c8f46ce798 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 29 Feb 2024 16:33:07 +0100 Subject: [PATCH 4/6] fix: ts error --- .../src/components/inputs/new/ImageField/ImageField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-components/src/components/inputs/new/ImageField/ImageField.tsx b/web-components/src/components/inputs/new/ImageField/ImageField.tsx index 7795fe6102..b9c0c883e8 100644 --- a/web-components/src/components/inputs/new/ImageField/ImageField.tsx +++ b/web-components/src/components/inputs/new/ImageField/ImageField.tsx @@ -25,7 +25,7 @@ interface Props { fixedCrop?: Partial; children: ReactNode; setValue: (value: string) => void; - onUpload?: (imageFile: File) => Promise; + onUpload?: (imageFile: File) => Promise; sx?: { label?: SxProps; button?: SxProps; From e7bd3f9b799536fefea32d6b69dbff7f2b37b277 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 7 Mar 2024 13:26:36 +0100 Subject: [PATCH 5/6] fix: add width to ReactCrop --- web-components/src/components/image-crop/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web-components/src/components/image-crop/index.tsx b/web-components/src/components/image-crop/index.tsx index a52ae10753..059bceffe6 100644 --- a/web-components/src/components/image-crop/index.tsx +++ b/web-components/src/components/image-crop/index.tsx @@ -100,6 +100,7 @@ export default function ImageCrop({ */ const onLoad = useCallback( (img: HTMLImageElement) => { + console.log(img); imgRef.current = img; const imgWidth = img.width; const imgHeight = img.height; @@ -152,7 +153,7 @@ export default function ImageCrop({ onComplete={setCompletedCrop} circularCrop={circularCrop} crossorigin="anonymous" - imageStyle={{ maxHeight: mobileMatches ? 380 : 500 }} + imageStyle={{ width: '100%', maxHeight: mobileMatches ? 380 : 500 }} /> {children} From e6d7aa2beb3a8ce5b8c044c0660c3400c63f0a15 Mon Sep 17 00:00:00 2001 From: blushi Date: Thu, 7 Mar 2024 13:37:32 +0100 Subject: [PATCH 6/6] fix: set min lenfth of 1 for profile name in roles form --- .../RolesForm/components/ProfileModal/ProfileModal.schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.schema.ts b/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.schema.ts index 37d19b2747..2e355523fa 100644 --- a/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.schema.ts +++ b/web-marketplace/src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.schema.ts @@ -8,7 +8,7 @@ export const profileModalSchema = z.object({ id: z.string().optional(), creatorId: z.string().nullable().optional(), profileType: z.custom(), - name: z.string(), + name: z.string().min(1), profileImage: z.string(), description: z.string().max(160).optional(), address: optionalAddressSchema,