diff --git a/client/src/components/dueDates/DueDateSingle.vue b/client/src/components/dueDates/DueDateSingle.vue index 68e6cc1c..c13d18da 100644 --- a/client/src/components/dueDates/DueDateSingle.vue +++ b/client/src/components/dueDates/DueDateSingle.vue @@ -7,6 +7,7 @@ diff --git a/client/src/components/dueDates/DueDatesLongList.vue b/client/src/components/dueDates/DueDatesLongList.vue new file mode 100644 index 00000000..b4399ced --- /dev/null +++ b/client/src/components/dueDates/DueDatesLongList.vue @@ -0,0 +1,43 @@ + + + diff --git a/client/src/components/dueDates/DueDatesShortList.vue b/client/src/components/dueDates/DueDatesShortList.vue index 1b73f8f2..abf95b82 100644 --- a/client/src/components/dueDates/DueDatesShortList.vue +++ b/client/src/components/dueDates/DueDatesShortList.vue @@ -1,10 +1,11 @@ @@ -13,16 +14,17 @@ import SingleDueDate from "@/components/dueDates/DueDateSingle.vue"; import { useCurrentCourseSession } from "@/composables"; import { defineProps } from "vue"; +// TODO: MaxCount is not working const props = defineProps<{ maxCount: { - type: number; default: 3; + type: number; }; }>(); const courseSession = useCurrentCourseSession(); console.log(props.maxCount); -const dueDates = courseSession.value.duedates.slice(0, 3); +const dueDates = courseSession.value.duedates.slice(0, props.maxCount); console.log(courseSession.value.duedates); diff --git a/client/src/components/dueDates/DueDatesTestData.ts b/client/src/components/dueDates/DueDatesTestData.ts new file mode 100644 index 00000000..1fdd6e16 --- /dev/null +++ b/client/src/components/dueDates/DueDatesTestData.ts @@ -0,0 +1,58 @@ +export const dueDatesTestData = () => { + return [ + { + id: 1, + start: "2023-06-14T15:00:00+02:00", + end: "2023-06-14T18:00:00+02:00", + title: "Präsenzkurs Kickoff", + url: "/course/überbetriebliche-kurse/learn/kickoff/präsenzkurs-kickoff", + course_session: 2, + page: 383, + }, + { + id: 2, + start: "2023-06-15T15:00:00+02:00", + end: "2023-06-15T18:00:00+02:00", + title: "Präsenzkurs Basis", + url: "/course/überbetriebliche-kurse/learn/basis/präsenzkurs-basis", + course_session: 2, + page: 397, + }, + { + id: 3, + start: "2023-06-16T15:00:00+02:00", + end: "2023-06-16T18:00:00+02:00", + title: "Präsenzkurs Fahrzeug", + url: "/course/überbetriebliche-kurse/learn/fahrzeug/präsenzkurs-fahrzeug", + course_session: 2, + page: 413, + }, + { + id: 4, + start: "2023-06-16T15:00:00+02:00", + end: "2023-06-16T18:00:00+02:00", + title: "Präsenzkurs Flugzeuge", + url: "/course/überbetriebliche-kurse/learn/fahrzeug/präsenzkurs-fahrzeug", + course_session: 2, + page: 413, + }, + { + id: 5, + start: "2023-07-16T11:00:00+02:00", + end: "2023-07-16T18:00:00+02:00", + title: "Präsenzkurs Motorräder", + url: "/course/überbetriebliche-kurse/learn/fahrzeug/präsenzkurs-fahrzeug", + course_session: 2, + page: 413, + }, + { + id: 6, + start: "2023-08-09T15:00:00+02:00", + end: "2023-08-09T19:00:00+02:00", + title: "Präsenzkurs Fahrräder", + url: "/course/überbetriebliche-kurse/learn/fahrzeug/präsenzkurs-fahrzeug", + course_session: 2, + page: 413, + }, + ]; +}; diff --git a/client/src/components/dueDates/DueDatesUtils.ts b/client/src/components/dueDates/DueDatesUtils.ts new file mode 100644 index 00000000..749b656b --- /dev/null +++ b/client/src/components/dueDates/DueDatesUtils.ts @@ -0,0 +1,27 @@ +export const formatDate = (start_str: string, end_str: string) => { + const start = new Date(start_str); + const end = new Date(end_str); + + const startDateString = getDateString(start); + const endDateString = getDateString(end); + + // if start and end are on the same day, dont show the day twice + if (startDateString === endDateString) { + return `${startDateString} ${getTimeString(start)} - ${getTimeString(end)}`; + } + return `${startDateString} ${getTimeString(start)} - ${endDateString} ${getTimeString( + end + )}`; +}; + +const getTimeString = (date: Date) => { + return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); +}; + +const getDateString = (date: Date) => { + return date.toLocaleDateString([], { + day: "numeric", + month: "short", + year: "numeric", + }); +}; diff --git a/client/src/pages/DashboardPage.vue b/client/src/pages/DashboardPage.vue index 44c3c8b5..89b8a608 100644 --- a/client/src/pages/DashboardPage.vue +++ b/client/src/pages/DashboardPage.vue @@ -1,4 +1,5 @@