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