Fix userpic upload mutation
This commit is contained in:
parent
96685507ea
commit
546d3d2659
|
@ -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)
|
||||||
|
|
|
@ -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 {
|
|
||||||
setForm((prev) => ({ ...prev, links: [...prev.links, value] }))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setForm({
|
setForm((prev) => ({ ...prev, [fieldName]: value }));
|
||||||
[fieldName]: value,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user