-
- {{ currentDate.currentDateTitle }}
-
+
+
+
+ {{ currentDate.currentDateTitle }}
+
+
diff --git a/src/stores/calendar.ts b/src/stores/calendar.ts
index 9f7b09b..6de1dfd 100644
--- a/src/stores/calendar.ts
+++ b/src/stores/calendar.ts
@@ -1,7 +1,7 @@
import { computed, type Ref, type ComputedRef, ref } from 'vue'
import { defineStore } from 'pinia'
import { useUrlSearchParams } from '@vueuse/core'
-import type { LeimPeriod, LeimPeriodShort } from '@/models/Date'
+import type { LeimDate, LeimPeriod, LeimPeriodShort } from '@/models/Date'
type CalendarViewType = 'month' | 'year' | 'decade' | 'century'
@@ -80,6 +80,14 @@ export const useCalendar = defineStore('calendar', () => {
const defaultDay = String(12)
const defaultMonth = String(7)
const defaultYear = String(3209)
+ const defaultDate: ComputedRef
= computed(() => {
+ return {
+ day: Number(defaultDay),
+ month: Number(defaultMonth),
+ year: Number(defaultYear),
+ period: 'nante'
+ }
+ })
// Assign default values if no params exist in URL
if (!params.day) {
@@ -142,6 +150,13 @@ export const useCalendar = defineStore('calendar', () => {
currentDateTitle
}
+ const currentLeimDate: LeimDate = {
+ day: Number(currentDay.value),
+ month: Number(currentMonth.value),
+ year: Number(currentYear.value),
+ period: currentPeriod.value
+ }
+
/**
* Moves the current date forward one month
*/
@@ -223,17 +238,33 @@ export const useCalendar = defineStore('calendar', () => {
}
}
+ function compareTwoDates(date1: LeimDate, date2: LeimDate) {
+ // To refacto to be more precise
+ return JSON.stringify({ ...date1 }) === JSON.stringify({ ...date2 })
+ }
+
+ function jumpToDefaultDate() {
+ params.day = defaultDay
+ params.month = defaultMonth
+ params.year = defaultYear
+ currentConfig.value.viewType = 'month'
+ }
+
return {
staticConfig,
viewTypeOptions,
currentConfig,
currentDate,
+ defaultDate,
+ currentLeimDate,
params,
getPeriodOfYear,
incrementMonth,
decrementMonth,
setMonth,
incrementYear,
- decrementYear
+ decrementYear,
+ jumpToDefaultDate,
+ compareTwoDates
}
})
diff --git a/src/stores/characters.ts b/src/stores/characters.ts
index e124ac8..8709eb0 100644
--- a/src/stores/characters.ts
+++ b/src/stores/characters.ts
@@ -9,6 +9,7 @@ export type Character = {
export const useCharacters = defineStore('characters', () => {
const characters: Character[] = [
+ { name: 'Quacille Lévios', birth: { day: 3, month: 6, year: 3162, period: 'nante' } },
{ name: 'Quacille Lévios', birth: { day: 3, month: 6, year: 3162, period: 'nante' } },
{ name: 'Lazarus Tymos', birth: { day: 29, month: 9, year: 3145, period: 'nante' } },
{ name: 'Ernestin Pomel', birth: { day: 11, month: 2, year: 3179, period: 'nante' } }
diff --git a/src/stores/events.ts b/src/stores/events.ts
index 9ca812c..18e68f8 100644
--- a/src/stores/events.ts
+++ b/src/stores/events.ts
@@ -5,9 +5,10 @@ import { useCharacters, type Character } from './characters'
import type { LeimDate } from '@/models/Date'
import { useCalendar } from './calendar'
-type CalendarEvent = {
+export type CalendarEvent = {
title: string
date: LeimDate
+ category: 'birth' | 'death'
}
export const useCalendarEvents = defineStore('calendar-events', () => {
@@ -20,7 +21,11 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
)
const characterBirthEvents = computed(() => {
return charactersWithBirthData.value.map((character) => {
- return { title: `Naissance de ${character.name}`, date: character.birth } as CalendarEvent
+ return {
+ title: `${character.name}`,
+ date: character.birth,
+ category: 'birth'
+ } as CalendarEvent
})
})
@@ -30,7 +35,11 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
)
const characterDeathEvents = computed(() => {
return charactersWithDeathData.value.map((character) => {
- return { title: `Décès de ${character.name}`, date: character.death } as CalendarEvent
+ return {
+ title: `${character.name}`,
+ date: character.death,
+ category: 'death'
+ } as CalendarEvent
})
})