diff --git a/components/pages/grocery/EditGroceryItem.tsx b/components/pages/grocery/EditGroceryItem.tsx index c92ac2f..6162c44 100644 --- a/components/pages/grocery/EditGroceryItem.tsx +++ b/components/pages/grocery/EditGroceryItem.tsx @@ -1,68 +1,66 @@ -import { View, Text } from "react-native"; -import React, { RefObject, useEffect, useRef, useState } from "react"; -import { TextField, TextFieldRef } from "react-native-ui-lib"; -import { - GroceryCategory, - IGrocery, - useGroceryContext, -} from "@/contexts/GroceryContext"; -import { TouchableWithoutFeedback } from "react-native-gesture-handler"; +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"; interface IEditGrocery { - id?: number; - title: string; - setTitle: (value: string) => void; - setCategory?: (category: GroceryCategory) => void; - category: GroceryCategory; - setSubmit?: (value: boolean) => void; - updateCategory?: (id: number, changes: Partial) => void; - closeEdit?: (value: boolean) => void; + id?: number; + title: string; + setTitle: (value: string) => void; + setCategory?: (category: GroceryCategory) => void; + category: GroceryCategory; + setSubmit?: (value: boolean) => void; + updateCategory?: (id: number, changes: Partial) => void; + closeEdit?: (value: boolean) => void; } -const EditGroceryItem = ({ editGrocery }: { editGrocery: IEditGrocery }) => { - const { fuzzyMatchGroceryCategory } = useGroceryContext(); - const inputRef = useRef(null); +const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => { + const {fuzzyMatchGroceryCategory} = useGroceryContext(); + const inputRef = useRef(null); - useEffect(() => { - if (editGrocery.setCategory) - editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title)); - }, [editGrocery.title]); + useEffect(() => { + if (editGrocery.setCategory) + editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title)); + }, [editGrocery.title]); - useEffect(() => { - if (inputRef.current) { - inputRef.current.focus(); // Focus on the TextField - } - }, []); + useEffect(() => { + if (inputRef.current) { + inputRef.current.focus(); // Focus on the TextField + } + }, []); - return ( - - { - 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 - }); - }} - maxLength={25} - /> - {editGrocery.category} - - ); + return ( + + { + 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 + }); + }} + maxLength={25} + /> + {editGrocery.category} + + ); }; export default EditGroceryItem; diff --git a/components/pages/grocery/GroceryItem.tsx b/components/pages/grocery/GroceryItem.tsx index 893d835..1e45dc3 100644 --- a/components/pages/grocery/GroceryItem.tsx +++ b/components/pages/grocery/GroceryItem.tsx @@ -75,7 +75,7 @@ const GroceryItem = ({ {!isEditingTitle ? ( setIsEditingTitle(true)}> - {item.title} + {item.title} ) : ( diff --git a/components/pages/grocery/GroceryList.tsx b/components/pages/grocery/GroceryList.tsx index 35adb0a..fe87ee9 100644 --- a/components/pages/grocery/GroceryList.tsx +++ b/components/pages/grocery/GroceryList.tsx @@ -178,29 +178,29 @@ const GroceryList = () => { {/* Approved Section */} - Shopping List {approvedVisible && ( - { - setApprovedVisible(false); - }} - /> + { + setApprovedVisible(false); + }} + /> )} {!approvedVisible && ( - { - setApprovedVisible(true); - }} - /> + { + setApprovedVisible(true); + }} + /> )} + Shopping List