Skip to content

Commit

Permalink
Removed replyRequestModel in ReplyRequestDialog.vue to simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstorey committed Nov 20, 2023
1 parent d836769 commit 2d1bde3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/messages/MessagesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
data() {
return {
showNewRequestDialog: false,
selectedAssistanceRequestId: null,
selectedAssistanceRequestId: '',
markReadButtonState: false,
markUnreadButtonInMessageTableState: false,
markUnreadButtonInConversationThreadState: false,
Expand Down
35 changes: 10 additions & 25 deletions frontend/src/components/messages/ReplyRequestDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<AppDialog v-model="isDisplayed" :title="`Request ${referenceNumber}`" persistent max-width="50%"
@close="closeReplyRequestDialog">
<template #content>
<v-form ref="replyRequestForm" v-model="replyRequestModel.isFormComplete" class="px-12 mx-8">
<v-form ref="replyRequestForm" v-model="isFormComplete" class="px-12 mx-8">
<v-row no-gutters class="mt-2">
<v-col class="v-col-12 blue-text pb-0">
<strong>Reply to request:</strong>
</v-col>
<v-col class="v-col-12">
<v-textarea v-model="replyRequestModel.message" placeholder="Enter message text" counter
<v-textarea v-model="message" placeholder="Enter message text" counter
maxlength="1000" variant="outlined" :rules="rules.required" :rows="6"></v-textarea>
</v-col>
</v-row>
Expand Down Expand Up @@ -63,7 +63,8 @@ export default {
emits: ['close', 'reply-success-event'],
data() {
return {
replyRequestModel: {},
isFormComplete: false,
message: null,
rules,
isDisplayed: false,
isLoading: false,
Expand All @@ -76,35 +77,15 @@ export default {
this.isDisplayed = value
},
},
assistanceRequestId: {
handler(value) {
this.replyRequestModel.assistanceRequestId = value
},
},
},
created() {
this.initReplyRequestModel()
},
methods: {
...mapActions(useMessagesStore, ['replyToAssistanceRequest']),
/**
* Initialize the reply request model.
*/
initReplyRequestModel() {
this.replyRequestModel = {
assistanceRequestId: this.assistanceRequestId,
message: null,
}
},
/**
* Reset the form and initialize the reply request model.
*/
resetForm() {
this.$refs.replyRequestForm?.reset()
this.initReplyRequestModel()
},
/**
Expand All @@ -120,10 +101,14 @@ export default {
*/
async submit() {
this.$refs.replyRequestForm?.validate()
if (this.replyRequestModel?.isFormComplete) {
if (this.isFormComplete) {
try {
this.isLoading = true
await this.replyToAssistanceRequest(this.replyRequestModel)
const payload = {
assistanceRequestId: this.assistanceRequestId,
message: this.message,
}
await this.replyToAssistanceRequest(payload)
this.$emit('reply-success-event', true) // emit success to flag showing success message
} catch (error) {
console.log(`Failed to create a reply for Assistance Request - ${error}`)
Expand Down

0 comments on commit 2d1bde3

Please sign in to comment.