Skip to content

Commit

Permalink
fix: display success message when uploading from SubmissionsView.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
bsilkyn committed May 23, 2024
1 parent 0f0f41a commit e5c2503
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions frontend/src/views/submissions/SubmissionsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { PrimeIcons } from 'primevue/api';
import AllSubmission from '@/components/submissions/AllSubmission.vue';
import { useGroup } from '@/composables/services/group.service.ts';
import { useSubmission } from '@/composables/services/submission.service.ts';
import { useMessagesStore } from '@/store/messages.store.ts';
const { t } = useI18n();
const route = useRoute();
const { project, getProjectByID } = useProject();
const { course, getCourseByID } = useCourses();
const { group, getGroupByID } = useGroup();
const { submission, submissions, createSubmission, getSubmissionByGroup } = useSubmission();
const { addSuccessMessage, addErrorMessage } = useMessagesStore();
/* State */
const files = ref<File[]>([]);
Expand All @@ -32,13 +34,24 @@ onMounted(async () => {
const onUpload = async (callback: () => void): Promise<void> => {
if (group.value !== null) {
console.log(files.value);
await createSubmission(files.value as File[], group.value.id);
if (submission.value != null) {
submissions.value = [...(submissions.value ?? []), submission.value];
try {
console.log(files.value);
await createSubmission(files.value as File[], group.value.id);
addSuccessMessage(
t('toasts.messages.success'),
t('toasts.messages.submissions.create.success')
);
if (submission.value != null) {
submissions.value = [...(submissions.value ?? []), submission.value];
}
files.value = [];
callback();
} catch (e) {
addErrorMessage(
t('toasts.messages.error'),
t('toasts.messages.submissions.create.error')
);
}
files.value = [];
callback();
}
};
Expand Down

0 comments on commit e5c2503

Please sign in to comment.