-
Podsumowanie roku {data.year}
+
{heading ?? `Podsumowanie roku ${data.year}`}
diff --git a/src/helpers/formatStatus/index.ts b/src/helpers/formatStatus/index.ts
index a683606..31331c1 100644
--- a/src/helpers/formatStatus/index.ts
+++ b/src/helpers/formatStatus/index.ts
@@ -6,6 +6,8 @@ export const formatStatus = (status: Gift['status']) => {
return 'Do kupienia';
case 'bought':
return 'Kupione';
+ case 'ready':
+ return 'Do spakowania';
case 'wrapped':
return 'Gotowe';
}
diff --git a/src/lib/db/index.ts b/src/lib/db/index.ts
index 0975254..70d0ee0 100644
--- a/src/lib/db/index.ts
+++ b/src/lib/db/index.ts
@@ -46,7 +46,7 @@ export const DB = {
link: string;
cost: number;
imageUrl: string;
- status: 'planned' | 'decided' | 'bought' | 'wrapped';
+ status: Gift['status'];
year: string;
person: string;
}): Promise => {
@@ -71,7 +71,7 @@ export const DB = {
link: string;
cost: number;
imageUrl: string;
- status: 'planned' | 'decided' | 'bought' | 'wrapped';
+ status: Gift['status'];
year: string;
person: string;
},
@@ -88,9 +88,14 @@ export const DB = {
'gifts-': id,
});
},
- getGifts: async (yearId: string): Promise => {
+ getGifts: async (year: number): Promise => {
+ const yearRecord = await pb.collection('gifts_year').getFirstListItem(`year = ${year}`);
+ if (!yearRecord) {
+ return [];
+ }
+
return await pb.collection('gifts_items').getFullList({
- filter: `year = "${yearId}"`,
+ filter: `year = "${yearRecord.id}"`,
expand: 'year,person',
fields: '*,expand.year.year,expand.person.name,expand.year.id,expand.person.id',
});
diff --git a/src/lib/db/types.d.ts b/src/lib/db/types.d.ts
index 3a9bbb5..b0402df 100644
--- a/src/lib/db/types.d.ts
+++ b/src/lib/db/types.d.ts
@@ -25,7 +25,7 @@ namespace DB {
link: string;
cost: number;
imageUrl: string;
- status: 'planned' | 'decided' | 'bought' | 'wrapped';
+ status: 'planned' | 'decided' | 'bought' | 'ready' | 'wrapped';
created: Date;
updated: Date;
diff --git a/src/types/global.d.ts b/src/types/global.d.ts
index 9f34226..7fe9495 100644
--- a/src/types/global.d.ts
+++ b/src/types/global.d.ts
@@ -42,7 +42,7 @@ type Gift = {
link: string;
cost: number;
imageUrl: string;
- status: 'planned' | 'decided' | 'bought' | 'wrapped';
+ status: 'planned' | 'decided' | 'bought' | 'ready' | 'wrapped';
created: Date;
updated: Date;