Skip to content

Commit 2e8bd35

Browse files
committed
Merge branch 'release/v3.0.11'
2 parents 2e9e92e + f7d2ccc commit 2e8bd35

2 files changed

Lines changed: 43 additions & 36 deletions

File tree

src/lib/fetchQuests.ts

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type FirestoreQuest = {
4343
/** Quest-specific settings stored in Firestore */
4444
settings: {
4545
heroCarouselOrder: number | null;
46+
isVisible: boolean;
4647
};
4748

4849
timestamps: {
@@ -66,43 +67,46 @@ export const fetchQuests = async (): Promise<Quest[]> => {
6667

6768
const snapshot = await getDocs(q);
6869

69-
return snapshot.docs.map((doc) => {
70-
const data = doc.data() as FirestoreQuest;
70+
return snapshot.docs
71+
.map((doc) => {
72+
const data = doc.data() as FirestoreQuest;
7173

72-
// Map tasks with localized labels preserved
73-
const tasks: QuestTask[] = data.tasks.map((task) => ({
74-
id: task.id,
75-
label: coerceLText(task.label),
76-
points: task.points,
77-
actionButton: task.actionButton
78-
? {
79-
label: coerceLText(task.actionButton.label),
80-
url: task.actionButton.url,
81-
}
82-
: undefined,
83-
}));
74+
// Map tasks with localized labels preserved
75+
const tasks: QuestTask[] = data.tasks.map((task) => ({
76+
id: task.id,
77+
label: coerceLText(task.label),
78+
points: task.points,
79+
actionButton: task.actionButton
80+
? {
81+
label: coerceLText(task.actionButton.label),
82+
url: task.actionButton.url,
83+
}
84+
: undefined,
85+
}));
8486

85-
// Compose domain Quest
86-
const quest: Quest = {
87-
id: doc.id,
88-
project: {
89-
name: coerceLText(data.project.name),
90-
logoUrl: data.project.logoUrl,
91-
},
92-
title: coerceLText(data.title),
93-
description: coerceLText(data.description ?? ""),
94-
catchphrase: coerceLText(data.catchphrase ?? ""),
95-
backgroundImages: data.backgroundImages,
96-
tasks,
97-
settings: {
98-
heroCarouselOrder: data.settings.heroCarouselOrder,
99-
},
100-
timestamps: {
101-
createdAt: data.timestamps.createdAt.toDate(),
102-
updatedAt: data.timestamps.updatedAt.toDate(),
103-
},
104-
};
87+
// Compose domain Quest
88+
const quest: Quest = {
89+
id: doc.id,
90+
project: {
91+
name: coerceLText(data.project.name),
92+
logoUrl: data.project.logoUrl,
93+
},
94+
title: coerceLText(data.title),
95+
description: coerceLText(data.description ?? ""),
96+
catchphrase: coerceLText(data.catchphrase ?? ""),
97+
backgroundImages: data.backgroundImages,
98+
tasks,
99+
settings: {
100+
heroCarouselOrder: data.settings.heroCarouselOrder,
101+
isVisible: data.settings.isVisible,
102+
},
103+
timestamps: {
104+
createdAt: data.timestamps.createdAt.toDate(),
105+
updatedAt: data.timestamps.updatedAt.toDate(),
106+
},
107+
};
105108

106-
return quest;
107-
});
109+
return quest;
110+
})
111+
.filter((quest) => quest.settings.isVisible);
108112
};

src/types/quest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ export type Quest = {
5151
settings: {
5252
/** Order in HeroCarousel (null = not shown, 1..N = display order) */
5353
heroCarouselOrder: number | null;
54+
55+
/** Controls whether the quest is visible on the platform */
56+
isVisible: boolean;
5457
};
5558

5659
/** Record timestamps */

0 commit comments

Comments
 (0)