Skip to content

Commit

Permalink
vage fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DRIESASTER committed May 19, 2024
1 parent 532482b commit 8445c42
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
13 changes: 10 additions & 3 deletions frontend/src/components/project/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ watch(
() => props.modelValue,
(newValue) => {
if (newValue) {
date.value = new Date(newValue);
if (new Date(newValue).getTime() !== date.value.getTime()) {
date.value = new Date(newValue);
}
}
},
{ immediate: true }
);
function formatTime(date: Date): string {
return `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`;
const formattedTime = `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`;
return formattedTime;
}
watch(
Expand All @@ -53,7 +56,11 @@ watch(
const [hours, minutes] = time.value.split(":").map(Number);
const updatedDate = new Date(date.value);
updatedDate.setHours(hours, minutes, 0, 0);
emit("update:modelValue", new Date(updatedDate));
if (hours === 0 && minutes === 0) {
emit("update:modelValue", new Date(updatedDate));
} else {
emit("update:modelValue", new Date(updatedDate));
}
},
{ deep: true }
);
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/queries/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export function useUpdateProjectMutation(): UseMutationReturnType<
mutationFn: ({ projectId, projectData }) => updateProject(projectId, projectData),

onSuccess: (_, variables) => {
queryClient.invalidateQueries(PROJECT_QUERY_KEY(projectId));
console.log(variables.projectId);
queryClient.invalidateQueries(PROJECT_QUERY_KEY(variables.projectId));
console.log("Project updated successfully.");
},

Expand Down
17 changes: 16 additions & 1 deletion frontend/src/views/CreateProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
<FilesInput v-model="files" />
</v-col>
<v-col cols="12">
<RequirementsInput v-model="requirements" />
<RequirementsInput
:model-value="requirements"
@update:modelValue="requirements = $event"
/>
</v-col>
</v-row>
<v-row>
Expand Down Expand Up @@ -166,10 +169,12 @@ watch(
projectData,
(project) => {
if (project) {
console.log(project);
project_title.value = project.name;
deadline.value = new Date(project.deadline);
publishDate.value = new Date(project.publish_date);
requirements.value = project.requirements.map((req) => ({ ...req }));
console.log(requirements.value);
const description = project.description;
selectedSubject.value = project.subject_id;
nextTick(() => {
Expand Down Expand Up @@ -204,6 +209,14 @@ const publishDateModel = computed({
},
});
watch(
requirements,
(newVal) => {
console.log("Updated Requirements in Parent:", newVal);
},
{ deep: true }
);
function updateDeadline(val) {
deadlineModel.value = val;
}
Expand Down Expand Up @@ -281,6 +294,7 @@ async function submitForm() {
}
function formatProjectData() {
console.log(toRaw(requirements.value));
return {
name: project_title.value,
deadline: deadline.value.toISOString(),
Expand All @@ -304,6 +318,7 @@ async function updateProject(projectData) {
}
async function createProject(projectData) {
console.log(projectData);
const createdProjectId = await createProjectMutation.mutateAsync(projectData);
projectData.project_id = createdProjectId;
await handleGroupCreation(createdProjectId);
Expand Down

0 comments on commit 8445c42

Please sign in to comment.