Refactored the store system

This commit is contained in:
Alexis
2024-08-20 09:15:05 +02:00
parent 7244120219
commit e978acfc71
26 changed files with 446 additions and 240 deletions

View File

@@ -1,8 +1,6 @@
<script lang="ts" setup>
import type { RPGDate } from '@/models/Date'
import type { CalendarEvent } from '@/models/CalendarEvent'
import { useCalendar } from '@/stores/CalendarStore'
import { useCalendarEvents } from '@/stores/EventStore'
import { useElementBounding } from '@vueuse/core'
import { storeToRefs } from 'pinia'
import { computed, ref, type ComputedRef } from 'vue'
@@ -18,8 +16,7 @@ const calendarTile = ref()
const calendarEventsList = ref()
const { defaultDate, selectDate, areDatesIdentical } = useCalendar()
const { selectedDate } = storeToRefs(useCalendar())
const { currentEvents } = storeToRefs(useCalendarEvents())
const { selectedDate, currentEvents } = storeToRefs(useCalendar())
/**
* All events with a startDate / endDate that starts or ends on the tile

View File

@@ -2,8 +2,7 @@
import { useCalendar } from '@/stores/CalendarStore'
import { useThrottleFn } from '@vueuse/core'
const { currentDate, decrementMonth, incrementMonth } = useCalendar()
const { currentMonthData } = storeToRefs(useCalendar())
const { currentDate, decrementMonth, incrementMonth, currentMonthData } = useCalendar()
function handleWheel(e: WheelEvent) {
const isMovingUp = e.deltaY < 0
@@ -26,7 +25,7 @@ const moveCalendarRight = useThrottleFn(() => {
<template>
<div class="grid grid-cols-10" @wheel="handleWheel">
<CalendarStateMonthlyDayTile
v-for="day in currentMonthData.days"
v-for="day in currentMonthData?.days"
:key="`layout-month-grid-${day}`"
:date="{
day: day,

View File

@@ -1,21 +1,16 @@
<script lang="ts" setup>
import type { RPGDate } from '@/models/Date'
import { useCalendar } from '@/stores/CalendarStore'
import { useCalendarEvents } from '@/stores/EventStore'
import { storeToRefs } from 'pinia'
import { computed, type ComputedRef } from 'vue'
const { currentDate, defaultDate, selectDate } = useCalendar()
const { selectedDate } = storeToRefs(useCalendar())
const { currentEvents } = storeToRefs(useCalendarEvents())
const { currentDate, defaultDate, selectDate, areDatesIdentical } = useCalendar()
const { selectedDate, currentEvents } = storeToRefs(useCalendar())
const props = defineProps<{
monthNumber: number
dayNumber: number
}>()
const { areDatesIdentical } = useCalendar()
const tileDate: ComputedRef<RPGDate> = computed(() => {
return {
day: props.dayNumber,