Merge branch 'main' into static
This commit is contained in:
commit
6ffbc34d77
@ -4,6 +4,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
FORM_METADATA_ENTRIES,
|
FORM_METADATA_ENTRIES,
|
||||||
PhotoFormData,
|
PhotoFormData,
|
||||||
|
convertFormKeysToLabels,
|
||||||
getInitialErrors,
|
getInitialErrors,
|
||||||
isFormValid,
|
isFormValid,
|
||||||
} from './form';
|
} from './form';
|
||||||
@ -44,13 +45,13 @@ export default function PhotoForm({
|
|||||||
// is refreshed by parent
|
// is refreshed by parent
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Object.keys(updatedExifData ?? {}).length > 0) {
|
if (Object.keys(updatedExifData ?? {}).length > 0) {
|
||||||
const changedKeys: string[] = [];
|
const changedKeys: (keyof PhotoFormData)[] = [];
|
||||||
|
|
||||||
setFormData(currentForm => {
|
setFormData(currentForm => {
|
||||||
Object.entries(updatedExifData ?? {})
|
Object.entries(updatedExifData ?? {})
|
||||||
.forEach(([key, value]) => {
|
.forEach(([key, value]) => {
|
||||||
if (currentForm[key as keyof PhotoFormData] !== value) {
|
if (currentForm[key as keyof PhotoFormData] !== value) {
|
||||||
changedKeys.push(key);
|
changedKeys.push(key as keyof PhotoFormData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,8 +62,9 @@ export default function PhotoForm({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (changedKeys.length > 0) {
|
if (changedKeys.length > 0) {
|
||||||
|
const fields = convertFormKeysToLabels(changedKeys);
|
||||||
toastSuccess(
|
toastSuccess(
|
||||||
`Updated EXIF fields: ${changedKeys.join(', ')}`,
|
`Updated EXIF fields: ${fields.join(', ')}`,
|
||||||
8000,
|
8000,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -84,6 +84,9 @@ export const FORM_METADATA_ENTRIES =
|
|||||||
(Object.entries(FORM_METADATA) as [keyof PhotoFormData, FormMeta][])
|
(Object.entries(FORM_METADATA) as [keyof PhotoFormData, FormMeta][])
|
||||||
.filter(([_, meta]) => !meta.hideTemporarily);
|
.filter(([_, meta]) => !meta.hideTemporarily);
|
||||||
|
|
||||||
|
export const convertFormKeysToLabels = (keys: (keyof PhotoFormData)[]) =>
|
||||||
|
keys.map(key => FORM_METADATA[key].label.toUpperCase());
|
||||||
|
|
||||||
export const getInitialErrors = (
|
export const getInitialErrors = (
|
||||||
formData: Partial<PhotoFormData>
|
formData: Partial<PhotoFormData>
|
||||||
): Partial<Record<keyof PhotoFormData, string>> =>
|
): Partial<Record<keyof PhotoFormData, string>> =>
|
||||||
|
|||||||
@ -13,6 +13,8 @@ export default function ToasterWithThemes() {
|
|||||||
classNames: {
|
classNames: {
|
||||||
toast: clsx(
|
toast: clsx(
|
||||||
'font-mono font-normal',
|
'font-mono font-normal',
|
||||||
|
'!text-gray-900 dark:!text-gray-100',
|
||||||
|
'!bg-white dark:!bg-black',
|
||||||
'!border-gray-200 dark:!border-gray-800',
|
'!border-gray-200 dark:!border-gray-800',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user