Browse Source

fix join-us form attachments

Olivier Massot 1 năm trước cách đây
mục cha
commit
da4f89b4c3
1 tập tin đã thay đổi với 15 bổ sung16 xóa
  1. 15 16
      components/JoinUs/Form.vue

+ 15 - 16
components/JoinUs/Form.vue

@@ -138,9 +138,8 @@ const validateResume = () =>
 
 const validateFileSize = () =>
   (resumeUpload.value !== null &&
-    resumeUpload.value[0] !== null &&
     // @ts-ignore
-    resumeUpload.value[0].size < maxFileSize * 1024 * 1024) ||
+    resumeUpload.value.size < maxFileSize * 1024 * 1024) ||
   'La taille du fichier ne doit pas dépasser ' + maxFileSize + ' Mo'
 
 const validateNonEmptyMessage = (message: string | null) =>
@@ -154,34 +153,34 @@ const validateMessageLength = (message: string | null) =>
  * Soumet le formulaire de candidature (boite de dialogue)
  */
 const submit = async () => {
-  const { valid } = await form.value.validate()
-
-  if (!valid) {
-    jobApplicationSent.value = false
-    return
-  }
-
+  console.log(resumeUpload.value)
   jobApplication.resume =
-    resumeUpload.value !== null && resumeUpload.value[0] !== null
+    resumeUpload.value !== null
       ? {
           // @ts-ignore
-          name: resumeUpload.value[0].name,
-          content: await FileUtils.blobToBase64(resumeUpload.value[0]),
+          name: resumeUpload.value.name,
+          content: await FileUtils.blobToBase64(resumeUpload.value),
         }
       : null
 
   jobApplication.motivationLetter =
-    motivationLetterUpload.value !== null &&
-    motivationLetterUpload.value[0] !== null
+    motivationLetterUpload.value !== null
       ? {
           // @ts-ignore
-          name: motivationLetterUpload.value[0].name,
+          name: motivationLetterUpload.value.name,
           content: await FileUtils.blobToBase64(
-            motivationLetterUpload.value[0]
+            motivationLetterUpload.value
           ),
         }
       : null
 
+  const { valid } = await form.value!.validate()
+
+  if (!valid) {
+    jobApplicationSent.value = false
+    return
+  }
+
   await em.persist(JobApplication, jobApplication)
 
   jobApplicationSent.value = true