diff --git a/appointment-frontend/src/components/feedback/Feedback.vue b/appointment-frontend/src/components/feedback/Feedback.vue
index 435711b57..315864a66 100644
--- a/appointment-frontend/src/components/feedback/Feedback.vue
+++ b/appointment-frontend/src/components/feedback/Feedback.vue
@@ -26,7 +26,7 @@
-
+
-
-
-
-
-
+
+
+
+
{{consentMessage}}
-
-
+
Submit
Submit
@@ -138,9 +136,9 @@
-
-
-
+
+
+
{{consentMessage}}
@@ -152,7 +150,7 @@
Submit
Submit
@@ -244,7 +242,6 @@ import { th } from 'date-fns/locale'
],
feedbackType: '',
feedbackMessage: '',
- name: '',
email: '',
phone: '',
feedbackHeader: '',
@@ -261,6 +258,9 @@ import { th } from 'date-fns/locale'
}
})
export default class Feedback extends Vue {
+ private emailRules
+ private phoneRules
+ private valid
private feedbackServiceChannel: string = ConfigHelper.getFeedbackServiceChannel()
private formEntryTime: number
private submitComplete: boolean
@@ -269,9 +269,9 @@ export default class Feedback extends Vue {
private feedbackMessage: string = ''
private feedbackHeader: string = ''
private feedbackType: string = ''
- private name: string
- private email: string
- private phone: string
+ private citizenName: string = ''
+ private email: string = ''
+ private phone: string = ''
private appointmentModule = getModule(AppointmentModule, this.$store)
private authModule = getModule(AuthModule, this.$store)
private showFeedbackArea = false
@@ -299,6 +299,7 @@ export default class Feedback extends Vue {
this.submitInProgress = false
this.feedbackType = feedbackType
this.responseRequired = false
+ this.showResponsePage = false
if (feedbackType === 'compliment') {
this.feedbackHeader = 'Send us a compliment'
}
@@ -333,7 +334,7 @@ export default class Feedback extends Vue {
this.feedbackRequest.variables.engagement.value = this.feedbackType
this.feedbackRequest.variables.citizen_comments.value = this.feedbackMessage + formSubmitTime
this.feedbackRequest.variables.response.value = this.responseRequired ? 'true' : 'false'
- this.feedbackRequest.variables.citizen_name.value = this.name === '' ? 'None' : this.name
+ this.feedbackRequest.variables.citizen_name.value = this.citizenName === '' ? 'None' : this.citizenName
this.feedbackRequest.variables.citizen_contact.value = this.phone === '' ? 'None' : this.phone
this.feedbackRequest.variables.citizen_email.value = this.email === '' ? 'None' : this.email
this.feedbackRequest.variables.service_date.value = this.getCurrentDateinFormat()
@@ -348,7 +349,7 @@ export default class Feedback extends Vue {
private clearFields () {
this.feedbackMessage = ''
- this.name = ''
+ this.citizenName = ''
this.email = ''
this.phone = ''
}
@@ -388,7 +389,40 @@ export default class Feedback extends Vue {
return 'Email or Phone no is required'
}
}
+ private validateRules () {
+ let phoneCondition = this.phone !== undefined && this.phone !== ''
+ let emailCondition = this.email !== undefined && this.email !== ''
+ if (emailCondition || phoneCondition) {
+ if (emailCondition) {
+ let formatResponse = /.+@.+\..+/.test(this.email) ? true : 'Email must be valid'
+ this.emailRules = [formatResponse]
+ this.phoneRules = [true]
+ }
+ if (phoneCondition) {
+ let formatResponse = /^\d{10}$/.test(this.phone) ? true : 'Phone must be valid'
+ this.phoneRules = [formatResponse]
+ this.emailRules = [true]
+ }
+ } else {
+ this.emailRules = ['Email or Phone is required']
+ this.phoneRules = ['Email or Phone is required']
+ }
+ }
+ private validateSubmit () {
+ if (this.responseRequired) {
+ return !(this.valid && this.consent)
+ } else if (!this.responseRequired) {
+ return !this.valid
+ } else {
+ return true
+ }
+ }
+
+ private showExpandedView () {
+ return this.showResponsePage && this.responseRequired
+ }
}
+