-
Notifications
You must be signed in to change notification settings - Fork 28
/
StaffPaymentDialog.vue
241 lines (221 loc) · 6.11 KB
/
StaffPaymentDialog.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<template>
<BaseDialog
:setDisplay="display"
:setOptions="options"
@proceed="proceed($event)"
>
<template #content>
<StaffPayment
:staffPaymentData="staffPaymentData"
:validate="validating"
:displaySideLabel="false"
:displayPriorityCheckbox="false"
@update:staff-payment-data="onStaffPaymentDataUpdate($event)"
@valid="valid = $event"
/>
<v-row
v-if="showCertifiedCheckbox"
noGutters
>
<v-col>
<v-checkbox
id="certify-checkbox"
v-model="certify"
class="mt-2"
label="Make this a Certified Search ($25.00)"
hideDetails
/>
</v-col>
</v-row>
</template>
</BaseDialog>
</template>
<script lang="ts">
import {
computed,
defineComponent,
nextTick,
reactive,
toRefs
} from 'vue'
import { useStore } from '@/store/store'
import { storeToRefs } from 'pinia'
import BaseDialog from '@/components/dialogs/BaseDialog.vue'
import StaffPayment from '@/components/common/StaffPayment.vue'
import { StaffPaymentOptions } from '@/enums'
import { DialogOptionsIF, StaffPaymentIF } from '@/interfaces'
export default defineComponent({
name: 'StaffPaymentDialog',
components: {
BaseDialog,
StaffPayment
},
props: {
setOptions: {
type: Object as () => DialogOptionsIF,
default: () => {
return {
acceptText: 'Submit',
cancelText: 'Cancel',
text: '',
title: 'Staff Payment'
}
}
},
setDisplay: {
type: Boolean,
default: false
},
setShowCertifiedCheckbox: {
type: Boolean,
default: false
}
},
emits: ['proceed'],
setup (props, { emit }) {
const { setStaffPayment, setSearchCertified } = useStore()
const { getStaffPayment } = storeToRefs(useStore())
const localState = reactive({
certify: false,
valid: false,
validating: false,
paymentOption: StaffPaymentOptions.NONE,
display: computed(() => {
return props.setDisplay
}),
options: computed(() => {
return props.setOptions
}),
showCertifiedCheckbox: computed(() => {
return props.setShowCertifiedCheckbox
}),
staffPaymentData: computed(() => {
let pd = getStaffPayment.value
if (!pd) {
pd = {
option: StaffPaymentOptions.NONE,
routingSlipNumber: '',
bcolAccountNumber: '',
datNumber: '',
folioNumber: '',
isPriority: false
}
}
return pd
})
})
const proceed = async (val: boolean): Promise<void> => {
// Validate Forms
localState.validating = true
await nextTick()
if (val) {
if (localState.valid) {
setSearchCertified(localState.certify)
setStaffPayment(localState.staffPaymentData)
emit('proceed', val)
}
// is false... they cancelled or closed the box
} else {
// blank payment data when closing the box
const pd = {
option: StaffPaymentOptions.NONE,
routingSlipNumber: '',
bcolAccountNumber: '',
datNumber: '',
folioNumber: '',
isPriority: false
}
setStaffPayment(pd)
// reset certified
localState.certify = false
localState.validating = false
setSearchCertified(localState.certify)
emit('proceed', val)
}
}
/** Called when component's staff payment data has been updated. */
const onStaffPaymentDataUpdate = (val: StaffPaymentIF) => {
let staffPaymentData: StaffPaymentIF = {
...val
}
if (staffPaymentData.routingSlipNumber || staffPaymentData.bcolAccountNumber || staffPaymentData.datNumber) {
} else {
if (localState.paymentOption !== staffPaymentData.option) {
localState.paymentOption = staffPaymentData.option
}
}
// disable validation
switch (staffPaymentData.option) {
case StaffPaymentOptions.FAS:
staffPaymentData = {
option: StaffPaymentOptions.FAS,
routingSlipNumber: staffPaymentData.routingSlipNumber,
isPriority: staffPaymentData.isPriority,
bcolAccountNumber: '',
datNumber: '',
folioNumber: ''
}
break
case StaffPaymentOptions.BCOL:
staffPaymentData = {
option: StaffPaymentOptions.BCOL,
bcolAccountNumber: staffPaymentData.bcolAccountNumber,
datNumber: staffPaymentData.datNumber,
folioNumber: staffPaymentData.folioNumber,
isPriority: staffPaymentData.isPriority,
routingSlipNumber: ''
}
break
case StaffPaymentOptions.NO_FEE:
staffPaymentData = {
option: StaffPaymentOptions.NO_FEE,
routingSlipNumber: '',
isPriority: false,
bcolAccountNumber: '',
datNumber: '',
folioNumber: ''
}
break
case StaffPaymentOptions.NONE: // should never happen
break
}
setStaffPayment(staffPaymentData)
}
return {
proceed,
onStaffPaymentDataUpdate,
...toRefs(localState)
}
}
})
</script>
<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
// override internal whitespace
:deep(#staff-payment-container) {
padding: 0 !important;
margin: 0 !important;
}
// override default radio input background colour
:deep(.v-input--radio-group__input) {
background-color: white;
}
// remove margin below radio group
:deep(.v-input--radio-group > .v-input__control > .v-input__slot) {
margin-bottom: 0 !important;
}
// hide messages below radio group
:deep(.v-input--radio-group > .v-input__control > .v-messages) {
display: none;
}
:deep(.theme--light.v-label),
:deep(.theme--light.v-input input) {
color: $gray7;
}
:deep(.theme--light.v-label--is-disabled) {
color: rgba(0, 0, 0, 0.38);
}
:deep(.v-application--is-ltr .v-text-field .v-label) {
color: rgba(0, 0, 0, 0.6);
}
</style>