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
|
||||
: formData;
|
||||
|
||||
// Capture tags before 'favorite' is excluded from insert
|
||||
const tags = convertStringToArray(photoForm.tags) ?? [];
|
||||
if (photoForm.favorite === 'true') {
|
||||
tags.push(TAG_FAVS);
|
||||
}
|
||||
|
||||
// Parse FormData:
|
||||
// - remove server action ID
|
||||
// - remove empty strings
|
||||
// - remove fields excluded from insert
|
||||
// - trim strings
|
||||
Object.keys(photoForm).forEach(key => {
|
||||
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 {
|
||||
...(photoForm as PhotoFormData & { filmSimulation?: FilmSimulation }),
|
||||
...!photoForm.id && { id: generateNanoid() },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user