From c19cccc44489af4d4d643249f5bcb7a7ca388917 Mon Sep 17 00:00:00 2001 From: Norbert Maciaszek Date: Sun, 16 Nov 2025 19:18:29 +0100 Subject: [PATCH] Refactor GiftModal and PersonModal components to utilize updated data types, enhancing type safety. Introduce 'ceneo_id' field in GiftModal for price tracking integration and adjust onSave methods to align with new data structures in the database. Update DB methods to reflect changes in data handling for gifts and persons. --- src/components/molecules/GiftModal/index.tsx | 32 +++++++++++------ .../molecules/PersonModal/index.tsx | 4 +-- src/lib/db/index.ts | 34 ++++--------------- src/lib/db/types.d.ts | 2 ++ src/types/global.d.ts | 31 ++--------------- 5 files changed, 35 insertions(+), 68 deletions(-) diff --git a/src/components/molecules/GiftModal/index.tsx b/src/components/molecules/GiftModal/index.tsx index 65dc139..0c18cd9 100644 --- a/src/components/molecules/GiftModal/index.tsx +++ b/src/components/molecules/GiftModal/index.tsx @@ -10,16 +10,7 @@ type Props = { gift?: Gift; yearId: string; personId?: string; - onSave: (data: { - title: string; - description: string; - link: string; - cost: number; - imageUrl: string; - status: Gift['status']; - year: string; - person: string; - }) => Promise; + onSave: (data: Omit) => Promise; }; export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, onSave }) => { @@ -30,6 +21,7 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, const [imageUrl, setImageUrl] = useState(gift?.imageUrl || ''); const [status, setStatus] = useState(gift?.status || 'planned'); const [selectedPersonId, setSelectedPersonId] = useState(personId || ''); + const [ceneoId, setCeneoId] = useState(gift?.ceneo_id || ''); const [isLoading, setIsLoading] = useState(false); useEffect(() => { @@ -41,6 +33,7 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, setImageUrl(gift.imageUrl || ''); setStatus(gift.status); setSelectedPersonId(gift.person); + setCeneoId(gift.ceneo_id || ''); } else { setTitle(''); setDescription(''); @@ -49,6 +42,7 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, setImageUrl(''); setStatus('planned'); setSelectedPersonId(personId || ''); + setCeneoId(''); } }, [gift, personId, isOpen]); @@ -63,6 +57,7 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, cost, imageUrl, status, + ceneo_id: ceneoId, year: yearId, person: selectedPersonId, }); @@ -166,6 +161,23 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, disabled={isLoading} /> +
+ + setCeneoId(e.target.value)} + className='w-full px-4 py-2 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all' + disabled={isLoading} + /> +

+ Jeśli produkt nie został jeszcze kupiony i zostanie podany jego ID na ceneo, bot będzie obserwował ceny i w + razie zmian będzie informował o tym na discord. +

+