Merge pull request 'Calendar-attendance-fix' (#108) from Calendar-attendance-fix into main
Reviewed-on: #108
This commit was merged in pull request #108.
This commit is contained in:
@@ -26,7 +26,7 @@ export interface CalendarSignup {
|
|||||||
eventID: number;
|
eventID: number;
|
||||||
status: CalendarAttendance;
|
status: CalendarAttendance;
|
||||||
member_name?: string;
|
member_name?: string;
|
||||||
member_unit?: string;
|
unit_name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CalendarEventShort {
|
export interface CalendarEventShort {
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ export async function editCalendarEvent(eventData: CalendarEvent) {
|
|||||||
export async function setCancelCalendarEvent(eventID: number, cancel: boolean) {
|
export async function setCancelCalendarEvent(eventID: number, cancel: boolean) {
|
||||||
let route = cancel ? "cancel" : "uncancel";
|
let route = cancel ? "cancel" : "uncancel";
|
||||||
|
|
||||||
console.log(route);
|
|
||||||
let res = await fetch(`${addr}/calendar/${eventID}/${route}`, {
|
let res = await fetch(`${addr}/calendar/${eventID}/${route}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ const maybe = computed<CalendarSignup[]>(() => { return activeEvent.value.eventS
|
|||||||
const declined = computed<CalendarSignup[]>(() => { return activeEvent.value.eventSignups.filter((s) => s.status == CalendarAttendance.NotAttending) })
|
const declined = computed<CalendarSignup[]>(() => { return activeEvent.value.eventSignups.filter((s) => s.status == CalendarAttendance.NotAttending) })
|
||||||
const viewedState = ref<CalendarAttendance>(CalendarAttendance.Attending);
|
const viewedState = ref<CalendarAttendance>(CalendarAttendance.Attending);
|
||||||
|
|
||||||
let user = useUserStore();
|
let userStore = useUserStore();
|
||||||
const myAttendance = computed<CalendarSignup | null>(() => {
|
const myAttendance = computed<CalendarSignup | null>(() => {
|
||||||
if (!user.isLoggedIn) return null;
|
if (!userStore.isLoggedIn) return null;
|
||||||
return activeEvent.value.eventSignups.find(
|
return activeEvent.value.eventSignups.find(
|
||||||
(s) => s.member_id === user.user.id
|
(s) => s.member_id === userStore.user.member.member_id
|
||||||
) || null;
|
) || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -79,8 +79,8 @@ async function setAttendance(state: CalendarAttendance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const canEditEvent = computed(() => {
|
const canEditEvent = computed(() => {
|
||||||
if (!user.isLoggedIn) return false;
|
if (!userStore.isLoggedIn) return false;
|
||||||
if (user.user.id == activeEvent.value.creator_id)
|
if (userStore.user.member.member_id == activeEvent.value.creator_id)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,11 +104,11 @@ const attendanceTab = ref<"Alpha" | "Echo" | "Other">("Alpha");
|
|||||||
const attendanceList = computed<CalendarSignup[]>(() => {
|
const attendanceList = computed<CalendarSignup[]>(() => {
|
||||||
let out: CalendarSignup[] = [];
|
let out: CalendarSignup[] = [];
|
||||||
if (attendanceTab.value === 'Alpha') {
|
if (attendanceTab.value === 'Alpha') {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Alpha Company');
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name === 'Alpha Company');
|
||||||
} else if (attendanceTab.value === 'Echo') {
|
} else if (attendanceTab.value === 'Echo') {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Echo Company')
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name === 'Echo Company')
|
||||||
} else {
|
} else {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit != 'Alpha Company' && s.member_unit != 'Echo Company')
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name != 'Alpha Company' && s.unit_name != 'Echo Company')
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusOrder: Record<CalendarAttendance, number> = {
|
const statusOrder: Record<CalendarAttendance, number> = {
|
||||||
@@ -126,11 +126,11 @@ const attendanceCountsByGroup = computed(() => {
|
|||||||
const signups = activeEvent.value.eventSignups ?? [];
|
const signups = activeEvent.value.eventSignups ?? [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Alpha: signups.filter(s => s.member_unit === "Alpha Company").length,
|
Alpha: signups.filter(s => s.unit_name === "Alpha Company").length,
|
||||||
Echo: signups.filter(s => s.member_unit === "Echo Company").length,
|
Echo: signups.filter(s => s.unit_name === "Echo Company").length,
|
||||||
Other: signups.filter(s =>
|
Other: signups.filter(s =>
|
||||||
s.member_unit !== "Alpha Company" &&
|
s.unit_name !== "Alpha Company" &&
|
||||||
s.member_unit !== "Echo Company"
|
s.unit_name !== "Echo Company"
|
||||||
).length,
|
).length,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -215,7 +215,7 @@ defineExpose({ forceReload })
|
|||||||
<CircleAlert></CircleAlert> This event has been cancelled
|
<CircleAlert></CircleAlert> This event has been cancelled
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section v-if="isPast && user.isLoggedIn" class="w-full">
|
<section v-if="isPast && userStore.isLoggedIn" class="w-full">
|
||||||
<ButtonGroup class="flex w-full">
|
<ButtonGroup class="flex w-full">
|
||||||
<Button variant="outline"
|
<Button variant="outline"
|
||||||
:class="myAttendance?.status === CalendarAttendance.Attending ? 'border-2 border-primary text-primary' : ''"
|
:class="myAttendance?.status === CalendarAttendance.Attending ? 'border-2 border-primary text-primary' : ''"
|
||||||
|
|||||||
Reference in New Issue
Block a user