Only show future appointments
This commit is contained in:
parent
e7ea2f8922
commit
9a3af24f72
|
|
@ -1,31 +1,50 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useCurrentCourseSession } from "@/composables";
|
import { useCurrentCourseSession, useDashboardPersons } from "@/composables";
|
||||||
import DueDateSingle from "@/components/dueDates/DueDateSingle.vue";
|
import DueDateSingle from "@/components/dueDates/DueDateSingle.vue";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useExpertCockpitStore } from "@/stores/expertCockpit";
|
import { useExpertCockpitStore } from "@/stores/expertCockpit";
|
||||||
|
import _ from "lodash";
|
||||||
|
import LoadingSpinner from "@/components/ui/LoadingSpinner.vue";
|
||||||
|
|
||||||
const expertCockpitStore = useExpertCockpitStore();
|
const expertCockpitStore = useExpertCockpitStore();
|
||||||
const courseSession = useCurrentCourseSession();
|
const courseSession = useCurrentCourseSession();
|
||||||
|
|
||||||
|
const courseSessionId = courseSession.value.id;
|
||||||
|
|
||||||
|
const { loading: loadingDates, currentDueDates } = useDashboardPersons();
|
||||||
|
|
||||||
const circleDates = computed(() => {
|
const circleDates = computed(() => {
|
||||||
const dueDates = courseSession.value.due_dates.filter((dueDate) => {
|
const courseSessionId = courseSession.value.id;
|
||||||
if (!expertCockpitStore.currentCircle) return false;
|
const circleId = expertCockpitStore.currentCircle?.id ?? "0";
|
||||||
return expertCockpitStore.currentCircle.id == dueDate?.circle?.id;
|
const dueDates = currentDueDates.value.filter((dueDate) => {
|
||||||
|
return (
|
||||||
|
dueDate.course_session_id === courseSessionId && dueDate.circle?.id === circleId
|
||||||
|
);
|
||||||
});
|
});
|
||||||
return dueDates.slice(0, 4);
|
return _.take(dueDates, 3);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col space-y-2">
|
<div v-if="loadingDates" class="m-8 flex justify-center">
|
||||||
|
<LoadingSpinner />
|
||||||
|
</div>
|
||||||
|
<div v-else class="flex flex-col space-y-2">
|
||||||
<h3 class="heading-3">{{ $t("Nächste Termine") }}</h3>
|
<h3 class="heading-3">{{ $t("Nächste Termine") }}</h3>
|
||||||
<div
|
<div
|
||||||
v-for="dueDate in circleDates"
|
v-for="dueDate in circleDates"
|
||||||
:key="dueDate.id"
|
:key="dueDate.id"
|
||||||
class="border-t border-gray-500 pt-2"
|
class="border-t border-gray-500 pt-2"
|
||||||
>
|
>
|
||||||
<DueDateSingle :due-date="dueDate" :single-line="true"></DueDateSingle>
|
<DueDateSingle :due-date="dueDate"></DueDateSingle>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="circleDates.length === 0">{{ $t("dueDates.noDueDatesAvailable") }}</div>
|
<div v-if="circleDates.length === 0">{{ $t("dueDates.noDueDatesAvailable") }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<router-link
|
||||||
|
class="btn-secondary mt-4"
|
||||||
|
:to="`/dashboard/due-dates?session=${courseSessionId}`"
|
||||||
|
>
|
||||||
|
{{ $t("a.Alle Termine anzeigen") }}
|
||||||
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import type {
|
||||||
PerformanceCriteria,
|
PerformanceCriteria,
|
||||||
} from "@/types";
|
} from "@/types";
|
||||||
import { useQuery } from "@urql/vue";
|
import { useQuery } from "@urql/vue";
|
||||||
|
import dayjs from "dayjs";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import orderBy from "lodash/orderBy";
|
import orderBy from "lodash/orderBy";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
|
|
@ -502,6 +503,9 @@ export function useDashboardPersons() {
|
||||||
const dashboardDueDates = ref<DashboardDueDate[]>([]);
|
const dashboardDueDates = ref<DashboardDueDate[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// due dates from today to the next year
|
||||||
|
const currentDueDates = ref<DashboardDueDate[]>([]);
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
|
|
@ -519,6 +523,18 @@ export function useDashboardPersons() {
|
||||||
}
|
}
|
||||||
return dueDate;
|
return dueDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currentDueDates.value = dashboardDueDates.value.filter((dueDate) => {
|
||||||
|
let refDate = dayjs(dueDate.start);
|
||||||
|
if (dueDate.end) {
|
||||||
|
refDate = dayjs(dueDate.end);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
refDate >= dayjs().startOf("day") &&
|
||||||
|
refDate <= dayjs().add(1, "year").endOf("day")
|
||||||
|
);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching data:", error);
|
console.error("Error fetching data:", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -531,6 +547,7 @@ export function useDashboardPersons() {
|
||||||
return {
|
return {
|
||||||
dashboardPersons,
|
dashboardPersons,
|
||||||
dashboardDueDates,
|
dashboardDueDates,
|
||||||
|
currentDueDates,
|
||||||
loading,
|
loading,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ type CourseItem = DropboxItem & {
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { loading, dashboardDueDates } = useDashboardPersons();
|
const { loading, currentDueDates: dashboardDueDates } = useDashboardPersons();
|
||||||
|
|
||||||
const courses = computed(() => {
|
const courses = computed(() => {
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -248,13 +248,13 @@ def get_dashboard_due_dates(request):
|
||||||
due_dates = []
|
due_dates = []
|
||||||
today = date.today()
|
today = date.today()
|
||||||
for due_date in all_due_dates:
|
for due_date in all_due_dates:
|
||||||
due_dates.append(due_date)
|
# due_dates.append(due_date)
|
||||||
# if due_date.end:
|
if due_date.end:
|
||||||
# if due_date.end.date() >= today:
|
if due_date.end.date() >= today:
|
||||||
# due_dates.append(due_date)
|
due_dates.append(due_date)
|
||||||
# elif due_date.start:
|
elif due_date.start:
|
||||||
# if due_date.start.date() >= today:
|
if due_date.start.date() >= today:
|
||||||
# due_dates.append(due_date)
|
due_dates.append(due_date)
|
||||||
|
|
||||||
due_dates.sort(key=lambda x: x.start)
|
due_dates.sort(key=lambda x: x.start)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue