fix: linter
This commit is contained in:
parent
2180425323
commit
f1ef976ac5
4 changed files with 50 additions and 79 deletions
|
@ -20,7 +20,7 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
||||||
description: assignment.description,
|
description: assignment.description,
|
||||||
learningPath: assignment.learningPathHruid,
|
learningPath: assignment.learningPathHruid,
|
||||||
language: assignment.learningPathLanguage,
|
language: assignment.learningPathLanguage,
|
||||||
deadline: assignment.deadline,
|
deadline: assignment.deadline ?? new Date(),
|
||||||
groups: assignment.groups.map((group) => mapToGroupDTO(group, assignment.within)),
|
groups: assignment.groups.map((group) => mapToGroupDTO(group, assignment.within)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +1,30 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { deadlineRules } from "@/utils/assignment-rules.ts";
|
import { deadlineRules } from "@/utils/assignment-rules.ts";
|
||||||
|
|
||||||
const date = ref("");
|
const emit = defineEmits<(e: "update:deadline", value: Date) => void>();
|
||||||
const time = ref("23:59");
|
|
||||||
const emit = defineEmits(["update:deadline"]);
|
|
||||||
|
|
||||||
const formattedDeadline = computed(() => {
|
const datetime = ref("");
|
||||||
if (!date.value || !time.value) return "";
|
|
||||||
return `${date.value} ${time.value}`;
|
// Watch the datetime value and emit the update
|
||||||
|
watch(datetime, (val) => {
|
||||||
|
const newDate = new Date(val);
|
||||||
|
if (!isNaN(newDate.getTime())) {
|
||||||
|
emit("update:deadline", newDate);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateDeadline(): void {
|
|
||||||
if (date.value && time.value) {
|
|
||||||
emit("update:deadline", formattedDeadline.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="date"
|
v-model="datetime"
|
||||||
label="Select Deadline Date"
|
type="datetime-local"
|
||||||
type="date"
|
label="Select Deadline"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
density="compact"
|
density="compact"
|
||||||
:rules="deadlineRules"
|
:rules="deadlineRules"
|
||||||
required
|
required
|
||||||
@update:modelValue="updateDeadline"
|
/>
|
||||||
></v-text-field>
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-card-text>
|
|
||||||
<v-text-field
|
|
||||||
v-model="time"
|
|
||||||
label="Select Deadline Time"
|
|
||||||
type="time"
|
|
||||||
variant="outlined"
|
|
||||||
density="compact"
|
|
||||||
@update:modelValue="updateDeadline"
|
|
||||||
></v-text-field>
|
|
||||||
</v-card-text>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const deadlineRules = [
|
||||||
return "Invalid date or time.";
|
return "Invalid date or time.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedDateTime < now) {
|
if (selectedDateTime <= now) {
|
||||||
return "The deadline must be in the future.";
|
return "The deadline must be in the future.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
const classController = new ClassController();
|
const classController = new ClassController();
|
||||||
|
|
||||||
const assignments = asyncComputed(async () => {
|
const assignments = asyncComputed(
|
||||||
|
async () => {
|
||||||
const classes = classesQueryResults?.data?.value?.classes;
|
const classes = classesQueryResults?.data?.value?.classes;
|
||||||
if (!classes) return [];
|
if (!classes) return [];
|
||||||
|
|
||||||
|
@ -50,9 +51,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
// Order the assignments by deadline
|
// Order the assignments by deadline
|
||||||
return result
|
return result.flat().sort((a, b) => {
|
||||||
.flat()
|
|
||||||
.sort((a, b) => {
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const aTime = new Date(a.deadline).getTime();
|
const aTime = new Date(a.deadline).getTime();
|
||||||
const bTime = new Date(b.deadline).getTime();
|
const bTime = new Date(b.deadline).getTime();
|
||||||
|
@ -65,8 +64,10 @@
|
||||||
|
|
||||||
return aTime - bTime;
|
return aTime - bTime;
|
||||||
});
|
});
|
||||||
}, [], {evaluating: true});
|
},
|
||||||
|
[],
|
||||||
|
{ evaluating: true },
|
||||||
|
);
|
||||||
|
|
||||||
async function goToCreateAssignment(): Promise<void> {
|
async function goToCreateAssignment(): Promise<void> {
|
||||||
await router.push("/assignment/create");
|
await router.push("/assignment/create");
|
||||||
|
@ -88,11 +89,6 @@
|
||||||
mutate({ cid: clsId, an: num });
|
mutate({ cid: clsId, an: num });
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPastDeadline(deadline?: string | Date): boolean {
|
|
||||||
if (!deadline) return false;
|
|
||||||
return new Date(deadline).getTime() < Date.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date?: string | Date): string {
|
function formatDate(date?: string | Date): string {
|
||||||
if (!date) return "–";
|
if (!date) return "–";
|
||||||
const d = new Date(date);
|
const d = new Date(date);
|
||||||
|
@ -122,9 +118,6 @@
|
||||||
return "deadline-upcoming";
|
return "deadline-upcoming";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const user = await auth.loadUser();
|
const user = await auth.loadUser();
|
||||||
username.value = user?.profile?.preferred_username ?? "";
|
username.value = user?.profile?.preferred_username ?? "";
|
||||||
|
@ -167,8 +160,6 @@
|
||||||
{{ t("deadline") }}:
|
{{ t("deadline") }}:
|
||||||
<span>{{ formatDate(assignment.deadline) }}</span>
|
<span>{{ formatDate(assignment.deadline) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
|
@ -200,7 +191,6 @@
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
</v-container>
|
</v-container>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -237,7 +227,9 @@
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||||
background-color: white;
|
background-color: white;
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
transition:
|
||||||
|
transform 0.2s,
|
||||||
|
box-shadow 0.2s;
|
||||||
}
|
}
|
||||||
.assignment-card:hover {
|
.assignment-card:hover {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
|
@ -295,6 +287,4 @@
|
||||||
color: #777;
|
color: #777;
|
||||||
padding: 3rem 0;
|
padding: 3rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue