Allow duplicate category feedback via submission
This commit is contained in:
@@ -20,12 +20,8 @@ const ManageCategoriesScreen = () => {
|
|||||||
}, {});
|
}, {});
|
||||||
}, [categories, products]);
|
}, [categories, products]);
|
||||||
|
|
||||||
const validateCategoryName = (value: string, editingId?: string | null) => {
|
const validateCategoryName = (value: string) => {
|
||||||
const trimmed = value.trim();
|
return Boolean(value.trim());
|
||||||
if (!trimmed) return false;
|
|
||||||
return !categories.some(
|
|
||||||
(category) => category.id !== editingId && category.name.toLowerCase() === trimmed.toLowerCase(),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const addCategory = async (name: string): Promise<ActionOutcome> => {
|
const addCategory = async (name: string): Promise<ActionOutcome> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user