Skip to content
Snippets Groups Projects
Commit 42a3ec0d authored by Omar Elkadi's avatar Omar Elkadi
Browse files

Add message and diagnose to SickForm and Server

parent 00686ee2
No related branches found
No related tags found
No related merge requests found
.DS_Store .DS_Store
node_modules node_modules
server/uploads
/dist /dist
......
...@@ -47,26 +47,26 @@ export class patientRoutes { ...@@ -47,26 +47,26 @@ export class patientRoutes {
// parse JSON to Objects // parse JSON to Objects
var patientStudent = JSON.parse(body.patientStudent); var patientStudent = JSON.parse(body.patientStudent);
var sickNote = JSON.parse(body.sickNoteData); var sickNote = JSON.parse(body.SickNote);
var message = JSON.parse(body.Message);
var sicknessReport = {
patientStudent,
sickNote
};
const file = req.file; const file = req.file;
if (!file) { if (!file) {
console.log("not file error"); console.log("not file error");
} }
res
.status(200)
.send("the body and the file are recived" + JSON.stringify(body));
const path = "./uploads/reports/" + patientStudent.MatrikelNumber + ".json"; const path = "./uploads/reports/" + patientStudent.MatrikelNumber + ".json";
var sicknessReport = {
patientStudent,
sickNote,
message,
sickNoteFilePath : path,
};
writeFile(path, JSON.stringify(sicknessReport), function (err) { writeFile(path, JSON.stringify(sicknessReport), function (err) {
if (err) return console.log(err); if (err) return console.log(err);
else return console.log("file generated in path: " + path); else return console.log("file generated in path: " + path);
}); });
res.status(200).send("the body and the file are recived" + JSON.stringify(body));
} }
} }
<template> <template>
<form <form
class="container mb-1 mt-1 p-1 border border-info rounded" class="container mb-3 mt-3 p-2 border border-info rounded"
@submit.prevent="OnSubmit" @submit.prevent="OnSubmit"
enctype="multipart/form-data" enctype="multipart/form-data"
> >
<div class="row">
<div class="col-md-8">
<!--1. name-->
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-5"> <div class="form-group col-md-5 col-sm-12 col-sm-12">
<label for="fname">Vorname</label> <label for="fname">Vorname</label>
<input <input
type="text" type="text"
...@@ -16,7 +18,7 @@ ...@@ -16,7 +18,7 @@
required required
/> />
</div> </div>
<div class="form-group col-md-5"> <div class="form-group col-md-5 col-sm-12">
<label for="lname">Nachname</label> <label for="lname">Nachname</label>
<input <input
type="text" type="text"
...@@ -37,8 +39,9 @@ ...@@ -37,8 +39,9 @@
/> />
</div> </div>
</div> </div>
<!--2. Email && phonenumber -->
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6 col-sm-12">
<label for="inputEmail4">E-mail</label> <label for="inputEmail4">E-mail</label>
<input <input
type="email" type="email"
...@@ -48,7 +51,7 @@ ...@@ -48,7 +51,7 @@
required required
/> />
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6 col-sm-12">
<label for="phone">Anrufnummer</label> <label for="phone">Anrufnummer</label>
<input <input
type="tel" type="tel"
...@@ -60,6 +63,7 @@ ...@@ -60,6 +63,7 @@
/> />
</div> </div>
</div> </div>
<!--3. Adress street haus num -->
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-10"> <div class="form-group col-md-10">
<label for="Street">Straße</label> <label for="Street">Straße</label>
...@@ -82,12 +86,13 @@ ...@@ -82,12 +86,13 @@
/> />
</div> </div>
</div> </div>
<!-- 4. Adress city + country-->
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="inputZip">Postleizahl</label> <label for="inputZip">Postleizahl</label>
<input type="text" class="form-control" id="inputZip" v-model="patientStudent.Address.ZIPcode" required /> <input type="text" class="form-control" id="inputZip" v-model="patientStudent.Address.ZIPcode" required />
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6 col-sm-12">
<label for="inputCity">Stadt</label> <label for="inputCity">Stadt</label>
<input type="text" class="form-control" id="inputCity" v-model="patientStudent.Address.City" required /> <input type="text" class="form-control" id="inputCity" v-model="patientStudent.Address.City" required />
</div> </div>
...@@ -100,7 +105,7 @@ ...@@ -100,7 +105,7 @@
</select> </select>
</div> </div>
</div> </div>
<!-- 5.Row --> <!-- 5.date select and file upload -->
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="date-input-start">Startdatum</label> <label for="date-input-start">Startdatum</label>
...@@ -116,18 +121,38 @@ ...@@ -116,18 +121,38 @@
<input class="form-control" type="file" id="formFile" ref="file" accept=".pdf,.docx,image/*" @change="handleFileUpload()" required> <input class="form-control" type="file" id="formFile" ref="file" accept=".pdf,.docx,image/*" @change="handleFileUpload()" required>
</div> </div>
</div> </div>
<!-- </div>
<div class="form-group"> <div class="col-md-4">
<div class="form-check"> <div class="form-row h-50 p-1">
<input class="form-check-input" type="checkbox" id="gridCheck" /> <div class="form-group col-md-12">
<label class="form-check-label" for="gridCheck"> <label for="diag">Diagnose</label>
Check me out <textarea
</label> type="text-area"
class="form-control h-75"
id="diag"
v-model="SickNote.diagnose"
required
>
</textarea>
</div>
</div>
<div class="form-row h-50 p-1">
<div class="form-group col-md-12">
<label for="mess">Nachricht</label>
<textarea
type="text-area"
class="form-control h-75"
id="mess"
v-model="Message"
required
>
</textarea>
</div> </div>
</div> </div>
--> </div>
<button type="submit" class="btn btn-success">Abschicken</button> </div>
</form> <button type="submit" class="btn btn-success">Abschicken</button>
</form>
</template> </template>
<script lang="ts"> <script lang="ts">
...@@ -153,9 +178,11 @@ export default { ...@@ -153,9 +178,11 @@ export default {
} }
}, },
SickNote: { SickNote: {
diagnose: '',
StartDate: new Date().getDate(), StartDate: new Date().getDate(),
EndDate: new Date().getDate() EndDate: new Date().getDate()
}, },
Message: '',
countries: countries:
[ [
{ name: 'Afghanistan', code: 'AF' }, { name: 'Afghanistan', code: 'AF' },
...@@ -405,6 +432,7 @@ export default { ...@@ -405,6 +432,7 @@ export default {
} }
}, },
methods: { methods: {
// get the file in a variable and check the validation
handleFileUpload () { handleFileUpload () {
// get the file from tag // get the file from tag
const file = this.$refs.file.files[0] const file = this.$refs.file.files[0]
...@@ -416,7 +444,7 @@ export default { ...@@ -416,7 +444,7 @@ export default {
console.log(fileExtension) console.log(fileExtension)
if (!allowedExtentions.includes(fileExtension)) { // extention validation if (!allowedExtentions.includes(fileExtension)) { // extention validation
this.$refs.file.value = null this.$refs.file.value = null // delete the file from selection
Swal.fire({ Swal.fire({
title: 'Fehler!', title: 'Fehler!',
text: 'Die Datei muss jpg, jpeg, png oder pdf', text: 'Die Datei muss jpg, jpeg, png oder pdf',
...@@ -445,7 +473,8 @@ export default { ...@@ -445,7 +473,8 @@ export default {
// prepare and bulid the messege // prepare and bulid the messege
// FormData is a dictionary type -> (key , value) // FormData is a dictionary type -> (key , value)
formData.append('patientStudent', JSON.stringify(this.patientStudent)) formData.append('patientStudent', JSON.stringify(this.patientStudent))
formData.append('sickNoteData', JSON.stringify(this.SickNote)) formData.append('SickNote', JSON.stringify(this.SickNote))
formData.append('Message', JSON.stringify(this.Message))
// add file to the message body // add file to the message body
formData.append('sickNoteEvidence', this.EvidenceFile) formData.append('sickNoteEvidence', this.EvidenceFile)
...@@ -459,7 +488,13 @@ export default { ...@@ -459,7 +488,13 @@ export default {
const data = res.data const data = res.data
console.log(data) console.log(data)
Swal.fire('Danke! Das Formular wurde schon gesandet') // trigger alert the the form is accepted
Swal.fire({
title: 'Gesandet!',
text: 'Danke für Ihre Meldung',
icon: 'success'
})
// reset the form
event.target.reset() event.target.reset()
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment