From d27313e866390eabe930cfc480a883079e7228c7 Mon Sep 17 00:00:00 2001 From: Norbert Maciaszek Date: Tue, 11 Nov 2025 16:43:30 +0100 Subject: [PATCH] Refactor Badge component to remove unused onClick prop, update Modal component to prevent close on inner click, and enhance GiftCard and GiftModal components to support multiple links with Badge display. --- src/components/atoms/Badge/index.tsx | 3 +-- src/components/atoms/Modal/index.tsx | 2 +- src/components/molecules/GiftCard/index.tsx | 15 +++++++++++++-- src/components/molecules/GiftModal/index.tsx | 8 ++++---- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/atoms/Badge/index.tsx b/src/components/atoms/Badge/index.tsx index 9665b00..6a80d32 100644 --- a/src/components/atoms/Badge/index.tsx +++ b/src/components/atoms/Badge/index.tsx @@ -2,10 +2,9 @@ import { FC } from 'react'; type Props = { children: React.ReactNode; - onClick: () => void; disabled?: boolean; }; -export const Badge: FC = ({ children, onClick, disabled }) => { +export const Badge: FC = ({ children, disabled }) => { return {children}; }; diff --git a/src/components/atoms/Modal/index.tsx b/src/components/atoms/Modal/index.tsx index 5a58d08..63678df 100644 --- a/src/components/atoms/Modal/index.tsx +++ b/src/components/atoms/Modal/index.tsx @@ -24,7 +24,7 @@ export const Modal: FC = ({ isOpen, onClose, title, children, footer }) = if (!isOpen) return null; return ( -
+
e.stopPropagation()}> diff --git a/src/components/molecules/GiftCard/index.tsx b/src/components/molecules/GiftCard/index.tsx index 6bf393d..46aa842 100644 --- a/src/components/molecules/GiftCard/index.tsx +++ b/src/components/molecules/GiftCard/index.tsx @@ -7,6 +7,8 @@ import { useGlobalStore } from '@/app/store/global'; import { DB } from '@/lib/db'; import { useRouter } from 'next/navigation'; import { Button } from '@/components/atoms/Button'; +import { Badge } from '@/components/atoms/Badge'; +import Link from 'next/link'; type Props = { hideDetails?: boolean; @@ -19,7 +21,7 @@ export const GiftCard: FC = ({ hideDetails = false, editable = fal const year = useGlobalStore((s) => s.year); const router = useRouter(); - const { title, description, cost, status, created, expand } = gift; + const { title, description, cost, status, created, expand, link } = gift; const bgByStatus = { planned: 'bg-gray-100', @@ -42,9 +44,18 @@ export const GiftCard: FC = ({ hideDetails = false, editable = fal onClick={editable ? () => setIsOpen(true) : undefined}>
-
+

{title}

+ {link && ( +
+ {link.split('\n').map((line, index) => ( + e.stopPropagation()}> + Link {index + 1} + + ))} +
+ )} {description &&

{description}

}
Data dodania: {new Date(created).toLocaleDateString()} diff --git a/src/components/molecules/GiftModal/index.tsx b/src/components/molecules/GiftModal/index.tsx index 48c64fc..84184b7 100644 --- a/src/components/molecules/GiftModal/index.tsx +++ b/src/components/molecules/GiftModal/index.tsx @@ -156,12 +156,12 @@ export const GiftModal: FC = ({ isOpen, onClose, gift, yearId, personId, - setLink(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' + rows={3} + 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 resize-none' disabled={isLoading} />