Skip to content

Commit

Permalink
chore: creation of courses and projects through their respective view…
Browse files Browse the repository at this point in the history
…s handle the errors on their own
  • Loading branch information
bsilkyn committed May 24, 2024
1 parent 4e0f50f commit 93ae55b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions frontend/src/views/courses/CreateCourseView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useMessagesStore } from '@/store/messages.store.ts';
/* Composable injections */
const { t } = useI18n();
const { addSuccessMessage } = useMessagesStore();
const { addSuccessMessage, addErrorMessage } = useMessagesStore();
const { push } = useRouter();
const { faculties, getFaculties } = useFaculty();
const { createCourse } = useCourses();
Expand All @@ -28,11 +28,11 @@ const loading = ref(true);
*/
async function saveCourse(course: Course): Promise<void> {
try {
await createCourse(course);
await createCourse(course, false);
addSuccessMessage(t('toasts.messages.success'), t('toasts.messages.courses.create.success', [course.name]));
await push({ name: 'dashboard' });
} catch (error: any) {
// TODO error message
addErrorMessage(t('toasts.messages.error'), t('toasts.messages.courses.create.error', [course.name]));
}
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/projects/CreateProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const loading = ref(true);
async function saveProject(newProject: Project, numberOfGroups: number): Promise<void> {
try {
if (course.value !== null) {
await createProject(newProject, course.value.id, numberOfGroups);
await createProject(newProject, course.value.id, numberOfGroups, false);
if (project.value !== null) {
await setStructureChecks(newProject.structure_checks ?? [], project.value.id);
await setExtraChecks(newProject.extra_checks ?? [], project.value.id);
await setStructureChecks(newProject.structure_checks ?? [], project.value.id, false);
await setExtraChecks(newProject.extra_checks ?? [], project.value.id, false);
addSuccessMessage(
t('toasts.messages.success'),
t('toasts.messages.projects.create.success', [project.value?.name]),
Expand All @@ -60,7 +60,7 @@ async function saveProject(newProject: Project, numberOfGroups: number): Promise
}
}
} catch (error: any) {
processError(error);
addErrorMessage(t('toasts.messages.error'), t('toasts.messages.projects.create.error', [project.value?.name]));
}
}
Expand Down

0 comments on commit 93ae55b

Please sign in to comment.