Fix userpic upload mutation

This commit is contained in:
ilya-bkv 2024-03-18 14:55:07 +03:00
parent 96685507ea
commit 546d3d2659
2 changed files with 6 additions and 12 deletions

View File

@ -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)

View File

@ -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 }));
}
}