1
0
mirror of https://github.com/tooot-app/app synced 2025-02-18 12:50:46 +01: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 formData = new FormData()
if (type === 'fields_attributes') {
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)
})
if (!data.length) {
formData.append('fields_attributes[]', '')
} else {
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') {
formData.append(type, {
uri: `file://${data}`,
uri: data,
name: 'image/jpeg',
type: 'image/jpeg'
} as any)