Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

date fixes #389

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions frontend/src/components/ProjectTeacherComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Inputfield from "./Inputfield.tsx";
import {SelectionBox} from "./SelectionBox.tsx";
import 'react-calendar/dist/Calendar.css';
import {FaEraser, FaUpload} from "react-icons/fa";
import {ProjectTeacher, Value} from "../types/project.ts";
import {ProjectTeacher} from "../types/project.ts";
import "../assets/styles/teacher_components.css"
import SimpleTests from "./SimpleTests/SimpleTests.tsx";
import {TeacherOrStudent} from "./SimpleTests/TeacherOrStudentEnum.tsx";
Expand Down Expand Up @@ -35,7 +35,7 @@ export function ProjectTeacherComponent(props: {
const [courseName, setCourseName] = useState<string>(props.project.courseName)
const [hours, setHours] = useState<number>(props.project.hours);
const [minutes, setMinutes] = useState<number>(props.project.minutes);
const [deadline, setDeadline] = useState<Value>(props.project.deadline);
const [deadline, setDeadline] = useState<string>(props.project.deadline);
const [description, setDescription] = useState(props.project.description);
const [max_students, setMaxStudents] = useState(props.project.maxGroupMembers);
const [groups, setGroups] = useState(props.project.amount_groups);
Expand Down Expand Up @@ -78,10 +78,10 @@ export function ProjectTeacherComponent(props: {
_.isEqual(groupProject, initialValues.value9) &&
_.isEqual(dockerString, initialValues.value10) &&
_.isEqual(visible, initialValues.value11) &&
_.isEqual(archived, initialValues.value12) &&
_.isEqual(archived, initialValues.value12);
_.isEqual(groups, initialValues.value13);
const second_part_1 = (deadline as Date).toDateString();
const second_part_2 = (initialValues.value5 as Date).toDateString();
const second_part_1 = deadline;
const second_part_2 = initialValues.value5;
const second_part = _.isEqual(second_part_1, second_part_2);
const third_part = groupProject && Number.isNaN(max_students);
return projectName !== "" && (props.is_new === true || !((first_part && second_part) || third_part));
Expand Down Expand Up @@ -172,7 +172,7 @@ export function ProjectTeacherComponent(props: {
async function handleSaveClick() {
const projectInput: ProjectInput = {
name: projectName,
deadline: (deadline as Date).toISOString(),
deadline: deadline,
visible: visible,
archived: archived,
description: description,
Expand Down Expand Up @@ -296,7 +296,12 @@ export function ProjectTeacherComponent(props: {
className="field-body is-flex is-flex-direction-column is-align-items-start is-justify-content-center">
<div>
<div>
<Calendar onChange={date => setDeadline(date)} value={deadline}
<Calendar onChange={date => {
if (date) {
setDeadline((new Date(date.toLocaleString())).toISOString())
}
}}
value={new Date(deadline)}
locale={t('create_project.deadline.locale')}/>
</div>
<div className="is-horizontal field is-justify-content-center mt-2">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/teacher/CreateProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function CreateProject(): JSX.Element {
projectId: -1,
courseName: data.courses[0].course_name,
all_courses: data.courses,
deadline: new Date(Date.now()),
deadline: (new Date(Date.now())).toISOString(),
description: "",
groupProject: false,
hours: 0,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/teacher/ProjectViewTeacher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function ProjectViewTeacher() {
courseName: project_data.course_name,
hours: deadline_date.getHours(),
minutes: deadline_date.getMinutes(),
deadline: deadline_date,
deadline: deadline_date.toISOString(),
visible: project_data.project_visible,
archived: project_data.project_archived,
description: project_data.project_description,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type ProjectTeacher = {
courseName: string,
hours: number,
minutes: number,
deadline: Value,
deadline: string,
visible: boolean,
archived: boolean,
description: string,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

export function deadline_to_string(deadline: string){
if (deadline === "-"){
return "-"
}
const deadline_date = new Date(deadline)
const hours = String(deadline_date.getHours()).padStart(2, '0');
const minutes = String(deadline_date.getMinutes()).padStart(2, '0');
Expand Down