diff --git a/package-lock.json b/package-lock.json index c16c628..ccd06f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "pocketbase": "^0.26.3", "react": "19.2.0", "react-dom": "19.2.0", + "react-icons": "^5.5.0", "zustand": "^5.0.8" }, "devDependencies": { @@ -1556,6 +1557,15 @@ "react": "^19.2.0" } }, + "node_modules/react-icons": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", + "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", + "license": "MIT", + "peerDependencies": { + "react": "*" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", diff --git a/package.json b/package.json index d48593a..52eee3e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "pocketbase": "^0.26.3", "react": "19.2.0", "react-dom": "19.2.0", + "react-icons": "^5.5.0", "zustand": "^5.0.8" }, "devDependencies": { diff --git a/src/components/atoms/Badge/index.tsx b/src/components/atoms/Badge/index.tsx index 6a80d32..e174ca3 100644 --- a/src/components/atoms/Badge/index.tsx +++ b/src/components/atoms/Badge/index.tsx @@ -6,5 +6,9 @@ type Props = { }; export const Badge: FC = ({ children, disabled }) => { - return {children}; + return ( + + {children} + + ); }; diff --git a/src/components/molecules/GiftCard/index.tsx b/src/components/molecules/GiftCard/index.tsx index 904485d..0249100 100644 --- a/src/components/molecules/GiftCard/index.tsx +++ b/src/components/molecules/GiftCard/index.tsx @@ -9,6 +9,8 @@ import { useRouter } from 'next/navigation'; import { Button } from '@/components/atoms/Button'; import { Badge } from '@/components/atoms/Badge'; import Link from 'next/link'; +import { Heading } from '@/components/atoms/Heading'; +import { FaTrashAlt } from 'react-icons/fa'; type Props = { hideDetails?: boolean; @@ -20,6 +22,7 @@ export const GiftCard: FC = ({ hideDetails = false, editable = fal const [isOpen, setIsOpen] = useState(false); const year = useGlobalStore((s) => s.year); const router = useRouter(); + editable = editable || !!gift.id; const { title, description, cost, status, created, expand, link } = gift; @@ -38,42 +41,30 @@ export const GiftCard: FC = ({ hideDetails = false, editable = fal return ( <>
setIsOpen(true) : undefined}> -
-
-
-

{title}

+
+
+
+ + {title} + {editable && ( -
- -
+ { + e.stopPropagation(); + handleDelete(); + }} + /> )}
- {description &&

{description}

} -
- Data dodania: {new Date(created).toLocaleDateString()} - Koszt: {formatCurrency(cost)} - {!hideDetails && ( - <> - - Dla: {expand?.person.name} - - )} - Status: {formatStatus(status)} -
+ {link && ( -
+
{link.split('\n').map((line, index) => ( e.stopPropagation()}> Link {index + 1} @@ -82,6 +73,16 @@ export const GiftCard: FC = ({ hideDetails = false, editable = fal
)}
+
+ Koszt: {formatCurrency(cost)} + {!hideDetails && ( + <> + + Dla: {expand?.person.name} + + )} +
+ {description &&

{description}

}
diff --git a/src/components/molecules/PersonCard/client.tsx b/src/components/molecules/PersonCard/client.tsx index b406138..ece22d0 100644 --- a/src/components/molecules/PersonCard/client.tsx +++ b/src/components/molecules/PersonCard/client.tsx @@ -28,7 +28,7 @@ export const PersonCardEdit: FC = ({ person }) => { -
diff --git a/src/components/molecules/PersonCard/index.tsx b/src/components/molecules/PersonCard/index.tsx index 36d54dd..51a51a2 100644 --- a/src/components/molecules/PersonCard/index.tsx +++ b/src/components/molecules/PersonCard/index.tsx @@ -1,42 +1,36 @@ -'use client'; import { Heading } from '@/components/atoms/Heading'; import { formatCurrency } from '@/helpers/formatCurrency'; -import { FC, useState } from 'react'; +import { FC } from 'react'; import { GiftCard } from '../GiftCard'; import { GiftCardAdd, PersonCardEdit } from './client'; -import { Button } from '@/components/atoms/Button'; export const PersonCard: FC = (person) => { - const [isOpen, setIsOpen] = useState(false); const { name, notes, expand } = person; const { gifts } = expand; return (
-
-
- {name} -
+
+ + {name} + + {notes &&

{notes}

}
- {notes &&

{notes}

}
Ilość prezentów: {gifts?.length || 0} Koszt: {formatCurrency(gifts?.reduce((acc, gift) => acc + gift.cost, 0) || 0)}
-
+
Prezenty
- {isOpen && } -
- -
+
- {isOpen && gifts?.map((gift) => )} + {gifts?.map((gift) => ( + + ))}
); };