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) setIsUserpicUpdating(true)
const result = await handleImageUpload(uploadFile) const result = await handleImageUpload(uploadFile)
updateFormField('userpic', result.url) updateFormField('pic', result.url)
setUserpicFile(null) setUserpicFile(null)
setIsUserpicUpdating(false) setIsUserpicUpdating(false)

View File

@ -54,18 +54,12 @@ export const ProfileFormProvider = (props: { children: JSX.Element }) => {
const updateFormField = (fieldName: string, value: string, remove?: boolean) => { const updateFormField = (fieldName: string, value: string, remove?: boolean) => {
if (fieldName === 'links') { if (fieldName === 'links') {
if (remove) { setForm((prev) => {
setForm( const updatedLinks = remove ? prev.links.filter((item) => item !== value) : [...prev.links, value];
'links', return { ...prev, links: updatedLinks };
form.links.filter((item) => item !== value), });
)
} else { } else {
setForm((prev) => ({ ...prev, links: [...prev.links, value] })) setForm((prev) => ({ ...prev, [fieldName]: value }));
}
} else {
setForm({
[fieldName]: value,
})
} }
} }