feat: qalendar typing
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Qalendar } from "qalendar";
|
import { Qalendar } from "qalendar";
|
||||||
|
import { CalendarEvent } from "./event.class";
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
month: {
|
month: {
|
||||||
@@ -9,10 +10,14 @@ const config = {
|
|||||||
defaultMode: 'month',
|
defaultMode: 'month',
|
||||||
isSilent: true,
|
isSilent: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
events: CalendarEvent[]
|
||||||
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Qalendar :config></Qalendar>
|
<Qalendar :config :events></Qalendar>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
29
frontend/src/components/calendar/event.class.ts
Normal file
29
frontend/src/components/calendar/event.class.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { toSimpleDateString } from "../../utils/date/converters.util"
|
||||||
|
|
||||||
|
export class CalendarEvent {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
description: string
|
||||||
|
color: "red" | "yellow" | "blue"
|
||||||
|
with?: string
|
||||||
|
time: { start: string; end: string }
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
timeStart: Date,
|
||||||
|
timeEnd: Date,
|
||||||
|
withPerson?: string,
|
||||||
|
color: "red" | "yellow" | "blue" = "red"
|
||||||
|
) {
|
||||||
|
this.title = title
|
||||||
|
this.description = description
|
||||||
|
this.time = {
|
||||||
|
start: toSimpleDateString(timeStart),
|
||||||
|
end: toSimpleDateString(timeEnd),
|
||||||
|
}
|
||||||
|
this.with = withPerson
|
||||||
|
this.color = color
|
||||||
|
this.id = new Date().getTime().toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,21 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Calendar from '../components/calendar/Calendar.vue';
|
import Calendar from '../components/calendar/Calendar.vue';
|
||||||
|
import { CalendarEvent } from '../components/calendar/event.class';
|
||||||
|
|
||||||
|
const events: CalendarEvent[] = []
|
||||||
|
|
||||||
|
const newEvent = new CalendarEvent(
|
||||||
|
"Advanced algebra",
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores assumenda corporis doloremque et expedita molestias necessitatibus quam quas temporibus veritatis. Deserunt excepturi illum nobis perferendis praesentium repudiandae saepe sapiente voluptatem!",
|
||||||
|
new Date("2025-03-11T12:05:00"),
|
||||||
|
new Date("2025-03-12T13:35:00"),
|
||||||
|
"Chandler Bing",
|
||||||
|
"red"
|
||||||
|
)
|
||||||
|
|
||||||
|
events.push(newEvent)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Calendar />
|
<Calendar :events="events" />
|
||||||
</template>
|
</template>
|
||||||
@@ -36,4 +36,11 @@ export const timestampToDate = (obj: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toSimpleDateString(date: Date): string {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0")
|
||||||
|
const day = String(date.getDate()).padStart(2, "0")
|
||||||
|
return `${year}-${month}-${day}`
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true,
|
"noUncheckedSideEffectImports": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"lib": ["ES2015", "DOM"]
|
"lib": ["ES2020", "DOM"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user