Skip to content

Commit 408fe14

Browse files
committed
fix: resolve type-check errors in holidays app and complete CI compatibility
1 parent c0b3ad4 commit 408fe14

1 file changed

Lines changed: 37 additions & 22 deletions

File tree

src/views/holidays/index.vue

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ interface Holiday {
2828
month?: number
2929
}
3030
31-
const typeLabels: Record<string, string> = {
31+
const typeLabels: Record<Holiday['type'], string> = {
3232
vietnam: '🇻🇳 Việt Nam',
3333
regional: '🏔️ Vùng Miền Việt Nam',
3434
international: '🌍 Quốc Tế',
3535
}
3636
37+
const getTypeLabel = (type: Holiday['type']): string => typeLabels[type]
38+
39+
const getMonthName = (month: number): string => monthNames[month - 1] ?? 'Tháng'
40+
3741
const monthNames = [
3842
'Tháng 1',
3943
'Tháng 2',
@@ -394,10 +398,15 @@ const holidays = ref<Holiday[]>([
394398
},
395399
])
396400
401+
interface GroupedMonth {
402+
month: number
403+
holidays: Holiday[]
404+
}
405+
397406
const activeType = ref<'vietnam' | 'regional' | 'international' | 'all'>('all')
398407
const searchQuery = ref('')
399408
400-
const groupedHolidays = computed(() => {
409+
const groupedHolidays = computed((): GroupedMonth[] => {
401410
let filtered = holidays.value
402411
403412
if (activeType.value !== 'all') {
@@ -412,27 +421,30 @@ const groupedHolidays = computed(() => {
412421
}
413422
414423
// Group by month
415-
const grouped: Record<number, Holiday[]> = {}
424+
const result: GroupedMonth[] = []
416425
for (let i = 1; i <= 12; i++) {
417-
grouped[i] = []
426+
result.push({ month: i, holidays: [] })
418427
}
419428
420429
filtered.forEach((h) => {
421-
if (h.month) {
422-
grouped[h.month].push(h)
430+
if (h.month != null) {
431+
const group = result.find((g) => g.month === h.month)
432+
if (group) {
433+
group.holidays.push(h)
434+
}
423435
}
424436
})
425437
426438
// Sort each month's holidays by date
427-
Object.values(grouped).forEach((arr) => {
428-
arr.sort((a, b) => {
429-
const aNum = parseInt(a.date.split('/')[0]) || 0
430-
const bNum = parseInt(b.date.split('/')[0]) || 0
439+
result.forEach((group) => {
440+
group.holidays.sort((a, b) => {
441+
const aNum = Number(a.date.split('/')[0]) || 0
442+
const bNum = Number(b.date.split('/')[0]) || 0
431443
return aNum - bNum
432444
})
433445
})
434446
435-
return grouped
447+
return result.filter((group) => group.holidays.length > 0)
436448
})
437449
</script>
438450

@@ -441,7 +453,7 @@ const groupedHolidays = computed(() => {
441453
<!-- Header -->
442454
<div class="border-b border-border-default bg-bg-surface py-8">
443455
<div class="mx-auto max-w-6xl px-6">
444-
<AppBreadcrumb />
456+
<AppBreadcrumb :items="[{ label: meta.name }]" />
445457
<div class="mt-6">
446458
<h1 class="font-display text-5xl font-bold text-text-primary">
447459
🎉 Các Ngày Lễ Trong Năm
@@ -522,26 +534,29 @@ const groupedHolidays = computed(() => {
522534

523535
<!-- Holidays by Month (Timeline View) -->
524536
<div class="mx-auto max-w-6xl px-6 py-12">
525-
<div v-if="Object.values(groupedHolidays).some((arr) => arr.length > 0)" class="space-y-12">
537+
<div v-if="groupedHolidays.length > 0" class="space-y-12">
526538
<div
527-
v-for="(month, monthIndex) in groupedHolidays"
528-
:key="`month-${monthIndex}`"
539+
v-for="(monthGroup, idx) in groupedHolidays"
540+
:key="`month-${monthGroup.month}`"
529541
class="animate-fade-up"
530-
:style="`animation-delay: ${monthIndex * 50}ms`"
542+
:style="`animation-delay: ${idx * 50}ms`"
531543
>
532544
<!-- Month Header -->
533-
<div v-if="month.length > 0" class="mb-6 flex items-center gap-4">
545+
<div class="mb-6 flex items-center gap-4">
534546
<h2 class="font-display text-2xl font-bold text-accent-coral">
535-
// {{ monthNames[monthIndex] }}
547+
// {{ getMonthName(monthGroup.month) }}
536548
</h2>
537549
<div class="flex-grow border-t border-border-default" />
538-
<span class="text-sm text-text-tertiary">{{ month.length }} ngày lễ</span>
550+
<span class="text-sm text-text-tertiary">{{ monthGroup.holidays.length }} ngày lễ</span>
539551
</div>
540552

541553
<!-- Holidays in Month -->
542-
<div v-if="month.length > 0" class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
554+
<div
555+
v-if="monthGroup.holidays.length > 0"
556+
class="grid gap-4 md:grid-cols-2 lg:grid-cols-3"
557+
>
543558
<div
544-
v-for="holiday in month"
559+
v-for="holiday in monthGroup.holidays"
545560
:key="holiday.id"
546561
class="border border-border-default bg-bg-surface p-5 transition hover:bg-bg-elevated"
547562
>
@@ -551,7 +566,7 @@ const groupedHolidays = computed(() => {
551566
<Icon :icon="holiday.icon" class="size-5 text-white" />
552567
</div>
553568
<span class="text-xs font-semibold text-accent-sky">{{
554-
typeLabels[holiday.type]
569+
getTypeLabel(holiday.type)
555570
}}</span>
556571
</div>
557572

0 commit comments

Comments
 (0)