Fix favorite form bug
This commit is contained in:
parent
1a154e71bd
commit
3ed2f28f2e
@ -242,9 +242,16 @@ export const convertFormDataToPhotoDbInsert = (
|
|||||||
? Object.fromEntries(formData) as PhotoFormData
|
? Object.fromEntries(formData) as PhotoFormData
|
||||||
: formData;
|
: formData;
|
||||||
|
|
||||||
|
// Capture tags before 'favorite' is excluded from insert
|
||||||
|
const tags = convertStringToArray(photoForm.tags) ?? [];
|
||||||
|
if (photoForm.favorite === 'true') {
|
||||||
|
tags.push(TAG_FAVS);
|
||||||
|
}
|
||||||
|
|
||||||
// Parse FormData:
|
// Parse FormData:
|
||||||
// - remove server action ID
|
// - remove server action ID
|
||||||
// - remove empty strings
|
// - remove empty strings
|
||||||
|
// - remove fields excluded from insert
|
||||||
// - trim strings
|
// - trim strings
|
||||||
Object.keys(photoForm).forEach(key => {
|
Object.keys(photoForm).forEach(key => {
|
||||||
const meta = FORM_METADATA()[key as keyof PhotoFormData];
|
const meta = FORM_METADATA()[key as keyof PhotoFormData];
|
||||||
@ -259,11 +266,6 @@ export const convertFormDataToPhotoDbInsert = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const tags = convertStringToArray(photoForm.tags) ?? [];
|
|
||||||
if (photoForm.favorite === 'true') {
|
|
||||||
tags.push(TAG_FAVS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...(photoForm as PhotoFormData & { filmSimulation?: FilmSimulation }),
|
...(photoForm as PhotoFormData & { filmSimulation?: FilmSimulation }),
|
||||||
...!photoForm.id && { id: generateNanoid() },
|
...!photoForm.id && { id: generateNanoid() },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user