added overlay function for tarot cards

This commit is contained in:
2026-03-08 03:52:25 -07:00
parent 84b340d7d1
commit 78abb582dd
17 changed files with 4050 additions and 1175 deletions

View File

@@ -310,9 +310,26 @@
function getCategoryOptions() {
const availableCategoryIds = new Set(state.questionBank.map((template) => template.categoryId));
const dynamic = CATEGORY_META
.filter((item) => availableCategoryIds.has(item.id))
.map((item) => ({ value: item.id, label: item.label }));
const labelByCategoryId = new Map(CATEGORY_META.map((item) => [item.id, item.label]));
state.questionBank.forEach((template) => {
const categoryId = String(template?.categoryId || "").trim();
const category = String(template?.category || "").trim();
if (categoryId && category && !labelByCategoryId.has(categoryId)) {
labelByCategoryId.set(categoryId, category);
}
});
const dynamic = [...availableCategoryIds]
.sort((left, right) => {
const leftLabel = String(labelByCategoryId.get(left) || left);
const rightLabel = String(labelByCategoryId.get(right) || right);
return leftLabel.localeCompare(rightLabel);
})
.map((categoryId) => ({
value: categoryId,
label: String(labelByCategoryId.get(categoryId) || categoryId)
}));
return [...FIXED_CATEGORY_OPTIONS, ...dynamic];
}
@@ -358,7 +375,9 @@
if (mode === "all") {
return "All";
}
return CATEGORY_META.find((item) => item.id === mode)?.label || "Category";
return CATEGORY_META.find((item) => item.id === mode)?.label
|| state.questionBank.find((template) => template.categoryId === mode)?.category
|| "Category";
}
function startRun(resetScore = false) {