diff --git a/src/components/icons/ErrorDocumentIcon.vue b/src/components/icons/ErrorDocumentIcon.vue new file mode 100644 index 0000000..e0caede --- /dev/null +++ b/src/components/icons/ErrorDocumentIcon.vue @@ -0,0 +1,11 @@ + diff --git a/src/localisation/en.ts b/src/localisation/en.ts index 60dd49c..dd9b0ae 100644 --- a/src/localisation/en.ts +++ b/src/localisation/en.ts @@ -311,6 +311,11 @@ export const en = { tutor: { BIG_FILE: 'File size exceeds 5 MB.', BAD_EXTENSION: 'File type not supported. Only PDF, TXT, and DOCX files are allowed.', + retry: { + title: 'Please try again', + description: 'An issue occurred while extracting the provided content, please try again.', + button: 'retry' + }, loading: { wait: 'Please wait', search: { diff --git a/src/localisation/fr.ts b/src/localisation/fr.ts index 8c269b7..edff1e2 100644 --- a/src/localisation/fr.ts +++ b/src/localisation/fr.ts @@ -317,6 +317,12 @@ export const fr = { BIG_FILE: 'La taille du fichier dépasse 5 Mo.', BAD_EXTENSION: 'Type de fichier non pris en charge. Seuls les fichiers PDF, TXT et DOCX sont acceptés.', + retry: { + title: 'Veuillez réessayer', + description: + "Un problème est survenu lors de l'extraction du contenu renseigné, veuillez relancer.", + button: 'relancer la requếte' + }, loading: { wait: 'Veuillez patienter', search: { diff --git a/src/stores/tutor.ts b/src/stores/tutor.ts index 1ae9100..b1ae1c6 100644 --- a/src/stores/tutor.ts +++ b/src/stores/tutor.ts @@ -25,6 +25,7 @@ export const useTutorStore = defineStore('tutor', () => { const setStep = (newStep: number) => (step.value = newStep); // ERROR STATES + const shouldRetryAction: Ref = ref(false); const hasSearchError: Ref = ref(false); const reloadError: Ref = ref(false); const hasSyllabusError: Ref = ref(false); @@ -83,6 +84,7 @@ export const useTutorStore = defineStore('tutor', () => { const retrieveTutorSearch = async (arg: File[]) => { isLoading.value = true; + shouldRetryAction.value = false; const formData = new FormData(); arg.forEach((file) => { if (file) { @@ -94,8 +96,16 @@ export const useTutorStore = defineStore('tutor', () => { const resp = await postAxios('/tutor/search', formData, { headers: { 'content-type': 'multipart/form-data' } }); - tutorSearch.value = resp.data; - hasSearchError.value = false; + if (resp.status === 204) { + shouldRetryAction.value = true; + } else { + tutorSearch.value = resp.data; + hasSearchError.value = false; + isLoading.value = false; + shouldRetryAction.value = false; + + goNext(); + } } catch (error: any) { console.error('Error during tutor search:', error); hasSearchError.value = true; @@ -105,7 +115,6 @@ export const useTutorStore = defineStore('tutor', () => { setStep(1); } finally { searchedFiles.value = arg; - isLoading.value = false; } }; @@ -128,7 +137,7 @@ export const useTutorStore = defineStore('tutor', () => { return; } - if (_isequal(searchedFiles.value, arg)) { + if (_isequal(searchedFiles.value, arg) && !shouldRetryAction.value) { hasNewSearch.value = false; goNext(); return; @@ -137,8 +146,6 @@ export const useTutorStore = defineStore('tutor', () => { tutorSearch.value = undefined; await retrieveTutorSearch(arg); hasNewSearch.value = true; - - goNext(); }; const retrieveSyllabus = async () => { @@ -249,6 +256,7 @@ export const useTutorStore = defineStore('tutor', () => { selectedSources, level, duration, + shouldRetryAction, description }; }); diff --git a/src/views/TutorPage.vue b/src/views/TutorPage.vue index b1e31a4..6961e9c 100644 --- a/src/views/TutorPage.vue +++ b/src/views/TutorPage.vue @@ -6,6 +6,7 @@ import ThirdStep from '@/components/tutor/ThirdStep.vue'; import StepsIndicator from '@/components/tutor/StepsIndicator.vue'; import ModalWrapper from '@/components/ModalWrapper.vue'; import ErrorComponent from '@/components/ErrorComponent.vue'; +import ErrorDocumentIcon from '@/components/icons/ErrorDocumentIcon.vue'; import { useTutorStore } from '@/stores/tutor'; const store = useTutorStore(); @@ -42,7 +43,28 @@ const stepToAction: Record<1 | 2 | 3, () => Promise> = { -
+
+
+

+ + {{ $t('tutor.retry.title') }} +

+ +

+ {{ $t('tutor.retry.description') }} +

+ +
+
+

{{ $t(getI18nText.title) }}