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.
This commit is contained in:
@@ -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<Gift & Props> = ({ 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<Gift & Props> = ({ hideDetails = false, editable = fal
|
||||
onClick={editable ? () => setIsOpen(true) : undefined}>
|
||||
<div className='flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4'>
|
||||
<div className='flex-1'>
|
||||
<div className='flex items-center justify-between gap-3 mb-2 pb-2 border-b border-gray-200'>
|
||||
<div className='flex items-center justify-between gap-3 mb-2'>
|
||||
<h3 className='text-lg font-semibold text-gray-800'>{title}</h3>
|
||||
</div>
|
||||
{link && (
|
||||
<div className='flex flex-wrap items-center gap-2 mb-2'>
|
||||
{link.split('\n').map((line, index) => (
|
||||
<Link href={line} target='_blank' key={index} onClick={(e) => e.stopPropagation()}>
|
||||
<Badge>Link {index + 1}</Badge>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{description && <p className='text-base text-gray-600 mb-3'>{description}</p>}
|
||||
<div className='flex flex-wrap items-center gap-4 text-sm text-gray-500'>
|
||||
<span>Data dodania: {new Date(created).toLocaleDateString()}</span>
|
||||
|
||||
Reference in New Issue
Block a user