From e5658238d9d53f5af4c422888a848c5a6491f295 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Thu, 31 Oct 2024 13:43:44 +0100 Subject: [PATCH 01/15] Update plan --- plan.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plan.md b/plan.md index 8508392..2c4f42d 100644 --- a/plan.md +++ b/plan.md @@ -44,8 +44,8 @@ Features: - [ ] filter collection based on favorites - [ ] _implement (un) mark favorite_ - [x] **implement navigation to card detail** -- [ ] **Card detail page** - - [ ] **display page with bar / qr code** +- [x] **Card detail page** + - [x] **display page with bar / qr code** - [ ] implement switch note visibility - [ ] _implement delete card dialog + remove card from local storage_ - [ ] _implement navigation to edit card page_ From e1a94ce752068a976ab3e2dd9761a3cd378116a0 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Thu, 31 Oct 2024 14:15:54 +0100 Subject: [PATCH 02/15] Add card-detail-page. --- app/card/card-detail-page.tsx | 54 +++++++++++++++++++++++++++++++++++ app/card/page.tsx | 10 ++++++- app/ui/secondary-header.tsx | 4 ++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/card/card-detail-page.tsx diff --git a/app/card/card-detail-page.tsx b/app/card/card-detail-page.tsx new file mode 100644 index 0000000..88fd004 --- /dev/null +++ b/app/card/card-detail-page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import useAppState from '@/app/lib/app-state/app-state'; +import { Routes } from '@/app/lib/shared'; +import PageTemplate from '@/app/ui/page-template'; +import { SecondaryHeader } from '@/app/ui/secondary-header'; +import { IconEdit, IconTrash } from '@tabler/icons-react'; +import { useSearchParams } from 'next/navigation'; + +export function CardDetailPage() { + const searchParams = useSearchParams(); + const id = searchParams.get('id'); + const [state, dispatch] = useAppState(); + const card = state.cards.find(c => c.id === id); + if (!card) { + return ( + } + > + card not found + + ); + } + return ( + + + + + } + /> + } + > +
card
+
{card.name}
+
{card.id}
+
{card.code}
+
{card.note}
+
{card.bgColor}
+
{JSON.stringify(card.icon)}
+
{card.favorite}
+
{card.codeFormat}
+
+ ); +} diff --git a/app/card/page.tsx b/app/card/page.tsx index dda8869..18e0540 100644 --- a/app/card/page.tsx +++ b/app/card/page.tsx @@ -1,3 +1,11 @@ +import { CardDetailPage } from '@/app/card/card-detail-page'; +import Loading from '@/app/ui/loading'; +import { Suspense } from 'react'; + export default function CardPage() { - return
Card
; + return ( + }> + + + ); } diff --git a/app/ui/secondary-header.tsx b/app/ui/secondary-header.tsx index 462bd86..a462440 100644 --- a/app/ui/secondary-header.tsx +++ b/app/ui/secondary-header.tsx @@ -17,7 +17,9 @@ export function SecondaryHeader({ -
{title}
+
+ {title} +
{rightAction}
); From a4d12ea02a24c79deb0edb53b6165bf3a0855fc2 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Thu, 31 Oct 2024 14:39:48 +0100 Subject: [PATCH 03/15] Use MainMessage component. --- app/card/card-detail-page.tsx | 24 ++++++++++++++++++++++-- app/create-card/scanner.tsx | 13 ++++++------- app/ui/main-message.tsx | 21 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 app/ui/main-message.tsx diff --git a/app/card/card-detail-page.tsx b/app/card/card-detail-page.tsx index 88fd004..3b3b865 100644 --- a/app/card/card-detail-page.tsx +++ b/app/card/card-detail-page.tsx @@ -2,9 +2,17 @@ import useAppState from '@/app/lib/app-state/app-state'; import { Routes } from '@/app/lib/shared'; +import { MainMessage } from '@/app/ui/main-message'; import PageTemplate from '@/app/ui/page-template'; import { SecondaryHeader } from '@/app/ui/secondary-header'; -import { IconEdit, IconTrash } from '@tabler/icons-react'; +import { + IconCards, + IconEdit, + IconHome, + IconPlus, + IconTrash, +} from '@tabler/icons-react'; +import Link from 'next/link'; import { useSearchParams } from 'next/navigation'; export function CardDetailPage() { @@ -17,7 +25,19 @@ export function CardDetailPage() { } > - card not found +
+ + + + + +
); } diff --git a/app/create-card/scanner.tsx b/app/create-card/scanner.tsx index 6eeccd6..54a486d 100644 --- a/app/create-card/scanner.tsx +++ b/app/create-card/scanner.tsx @@ -4,6 +4,7 @@ import { CreateCardFormActions, CreateCardFormActionTypes, } from '@/app/create-card/createCardFormReducer'; +import { MainMessage } from '@/app/ui/main-message'; import { Html5Qrcode, Html5QrcodeResult, @@ -112,16 +113,14 @@ export default function Scanner({ >
{!activeDevice && ( -
-

Please grant camera permissions.

-

- Without those permissions, it will be impossible to scan and save - your cards. -

+ -
+ )} ); diff --git a/app/ui/main-message.tsx b/app/ui/main-message.tsx new file mode 100644 index 0000000..0aa5ed0 --- /dev/null +++ b/app/ui/main-message.tsx @@ -0,0 +1,21 @@ +import clsx from 'clsx'; + +export function MainMessage({ + className, + children, + title, + description, +}: { + className?: string; + children?: React.ReactNode; + title: string; + description: string; +}) { + return ( +
+

{title}

+

{description}

+ {children} +
+ ); +} From 57c5efc6077daec1aecd66adbd7ec747c5a3c7a1 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Thu, 31 Oct 2024 14:59:43 +0100 Subject: [PATCH 04/15] Style card detail a bit. --- app/(homescreens)/layout.tsx | 2 +- app/card/card-detail-page.tsx | 71 ++++++++++++++++++++++++----------- app/ui/company-icon.tsx | 17 +++++++-- app/ui/primary-header.tsx | 2 +- app/ui/secondary-header.tsx | 2 +- 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/app/(homescreens)/layout.tsx b/app/(homescreens)/layout.tsx index 24bebcd..d76b308 100644 --- a/app/(homescreens)/layout.tsx +++ b/app/(homescreens)/layout.tsx @@ -8,7 +8,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
{children}