diff --git a/src/components/ProfileSettings/ProfileSettings.tsx b/src/components/ProfileSettings/ProfileSettings.tsx index 1c2afd98..70389ccb 100644 --- a/src/components/ProfileSettings/ProfileSettings.tsx +++ b/src/components/ProfileSettings/ProfileSettings.tsx @@ -123,7 +123,7 @@ export const ProfileSettings = () => { setIsUserpicUpdating(true) const result = await handleImageUpload(uploadFile) - updateFormField('userpic', result.url) + updateFormField('pic', result.url) setUserpicFile(null) setIsUserpicUpdating(false) diff --git a/src/context/profile.tsx b/src/context/profile.tsx index 1b88f149..48262694 100644 --- a/src/context/profile.tsx +++ b/src/context/profile.tsx @@ -54,18 +54,12 @@ export const ProfileFormProvider = (props: { children: JSX.Element }) => { const updateFormField = (fieldName: string, value: string, remove?: boolean) => { if (fieldName === 'links') { - if (remove) { - setForm( - 'links', - form.links.filter((item) => item !== value), - ) - } else { - setForm((prev) => ({ ...prev, links: [...prev.links, value] })) - } + setForm((prev) => { + const updatedLinks = remove ? prev.links.filter((item) => item !== value) : [...prev.links, value]; + return { ...prev, links: updatedLinks }; + }); } else { - setForm({ - [fieldName]: value, - }) + setForm((prev) => ({ ...prev, [fieldName]: value })); } }