1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
Zhiyuan Zheng
2022-06-21 23:45:11 +02:00
parent 41d85bf738
commit 29977b6c9e

View File

@@ -64,14 +64,18 @@ type MutationVarsProfile = MutationVarsProfileBase & {
const mutationFunction = async ({ type, data }: MutationVarsProfile) => { const mutationFunction = async ({ type, data }: MutationVarsProfile) => {
const formData = new FormData() const formData = new FormData()
if (type === 'fields_attributes') { if (type === 'fields_attributes') {
const tempData = data as { name: string; value: string }[] if (!data.length) {
tempData.forEach((d, index) => { formData.append('fields_attributes[]', '')
formData.append(`fields_attributes[${index}][name]`, d.name) } else {
formData.append(`fields_attributes[${index}][value]`, d.value) const tempData = data as { name: string; value: string }[]
}) tempData.forEach((d, index) => {
formData.append(`fields_attributes[${index}][name]`, d.name)
formData.append(`fields_attributes[${index}][value]`, d.value)
})
}
} else if (type === 'avatar' || type === 'header') { } else if (type === 'avatar' || type === 'header') {
formData.append(type, { formData.append(type, {
uri: `file://${data}`, uri: data,
name: 'image/jpeg', name: 'image/jpeg',
type: 'image/jpeg' type: 'image/jpeg'
} as any) } as any)