diff --git a/components/pages/grocery/EditGroceryItem.tsx b/components/pages/grocery/EditGroceryItem.tsx index 6162c44..cfdb56d 100644 --- a/components/pages/grocery/EditGroceryItem.tsx +++ b/components/pages/grocery/EditGroceryItem.tsx @@ -1,17 +1,17 @@ import {Text, View} from "react-native"; import React, {useEffect, useRef} from "react"; import {TextField, TextFieldRef} from "react-native-ui-lib"; -import {GroceryCategory, IGrocery, useGroceryContext,} from "@/contexts/GroceryContext"; +import {GroceryCategory, useGroceryContext,} from "@/contexts/GroceryContext"; interface IEditGrocery { - id?: number; + id?: string; title: string; + category: GroceryCategory; setTitle: (value: string) => void; setCategory?: (category: GroceryCategory) => void; - category: GroceryCategory; setSubmit?: (value: boolean) => void; - updateCategory?: (id: number, changes: Partial) => void; closeEdit?: (value: boolean) => void; + handleEditSubmit?: Function } const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => { @@ -49,12 +49,18 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => { editGrocery.setTitle(value); }} onSubmitEditing={() => { - if (editGrocery.setSubmit) editGrocery.setSubmit(true); - if (editGrocery.closeEdit) editGrocery.closeEdit(false); - if (editGrocery.updateCategory && editGrocery.id) - editGrocery.updateCategory(editGrocery.id, { - category: fuzzyMatchGroceryCategory(editGrocery.title), title: editGrocery.title - }); + if (editGrocery.setSubmit) { + editGrocery.setSubmit(true); + } + if (editGrocery.setCategory) { + editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title)); + } + if (editGrocery.handleEditSubmit) { + editGrocery.handleEditSubmit({id: editGrocery.id, title: editGrocery.title, category: editGrocery.category}); + } + if (editGrocery.closeEdit) { + editGrocery.closeEdit(false); + } }} maxLength={25} /> diff --git a/components/pages/grocery/GroceryItem.tsx b/components/pages/grocery/GroceryItem.tsx index 1e45dc3..cfc0e36 100644 --- a/components/pages/grocery/GroceryItem.tsx +++ b/components/pages/grocery/GroceryItem.tsx @@ -80,15 +80,15 @@ const GroceryItem = ({ ) : ( )} {!item.approved ? (