@byu-oit/vue-decision-processing-components 8.37.0-0 → 8.37.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,126 +15,82 @@
15
15
  -->
16
16
  <template>
17
17
  <div class="ces-hold">
18
- <span
19
- v-if="loaded"
20
- :class="holdSet ? flagClass : noFlagClass"
21
- >
22
- <font-awesome-icon :icon="holdIcon" />
23
- {{ holdSet ? 'CES Standards Hold' : 'No CES Standards Hold' }}
24
- </span>
25
- <span v-else-if="error" class="text-error">
26
- <font-awesome-icon :icon="holdIcon" />
27
- Error checking CES Standards Hold
28
- </span>
29
- <span v-else class="text-gray">
30
- <font-awesome-icon :icon="spinner" spin />
31
- Loading...
18
+ <span :class="statusClass">
19
+ <font-awesome-icon :icon="flagIcon" />
20
+
21
+ {{cesHoldStatus}}
32
22
  </span>
33
23
  </div>
34
24
  </template>
35
25
  <script>
36
- import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
37
- import { faCheck, faExclamationTriangle, faQuestionCircle, faSpinner } from '@fortawesome/free-solid-svg-icons'
26
+ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
27
+ import { faCheck, faExclamationTriangle, faSquare, faMinus, faHourglassHalf, faQuestionCircle } from '@fortawesome/free-solid-svg-icons'
38
28
 
39
- import { mapState } from 'vuex'
29
+ import { mapGetters } from 'vuex'
40
30
 
41
- export default {
42
- name: 'DetailsCesHold',
43
- components: {
44
- FontAwesomeIcon
45
- },
46
- props: {
47
- flagClass: {
48
- type: String,
49
- default: 'text-error'
50
- },
51
- noFlagClass: {
52
- type: String,
53
- default: 'text-secondary'
54
- }
55
- },
56
- data () {
57
- return {
58
- error: false,
59
- loaded: false,
60
- holdSet: false
61
- }
62
- },
63
- computed: {
64
- ...mapState({
65
- env: 'environment',
66
- applicantId: state => state.application.applicantId,
67
- applicantFirstName: state => state.application.basic.preferredFirstName,
68
- applicantSurname: state => state.application.basic.surname,
69
- applicantDob: state => state.application.personalRecords.dateOfBirth
70
- }),
71
- spinner () { return faSpinner },
72
- holdIcon () {
73
- return this.holdSet ? faExclamationTriangle : this.error ? faQuestionCircle : faCheck
31
+ export default {
32
+ name: 'DetailsCesHold',
33
+ components: {
34
+ FontAwesomeIcon
35
+ },
36
+ computed: {
37
+ ...mapGetters([ 'flagByValue' ]),
38
+ flag() { return this.flagByValue('cesHolds') },
39
+ statusClass() {
40
+ if (this.flag != null){
41
+ switch(this.flag.state.toLowerCase()){
42
+ case 'pass':
43
+ return { 'text-success': true }
44
+ case 'fail':
45
+ return { 'text-danger': true }
46
+ case 'error':
47
+ return { 'text-danger': true, 'font-weight-bold': true }
48
+ case 'indeterminate':
49
+ return { 'text-dark': true }
50
+ default:
51
+ return { 'text-danger': true, 'font-weight-bold': true }
52
+ }
74
53
  }
75
54
  },
76
- methods: {
77
- getByuId: async function () {
78
- try {
79
- const surname = this.applicantSurname ? this.applicantSurname.trim() : ''
80
- const preferredFirstName = this.applicantFirstName ? this.applicantFirstName.trim() : ''
81
- const applicantDob = this.applicantDob ? new Date(this.applicantDob).toISOString().split('T')[0].trim() : ''
82
- const url = this.env === 'production'
83
- ? `https://api.byu.edu/byuapi/persons/v4/?preferred_first_name=${preferredFirstName}&surname=${surname}&vital_record.date_of_birth=${applicantDob}`
84
- : `https://api-sandbox.byu.edu/byuapi/persons/v4/?preferred_first_name=${preferredFirstName}&surname=${surname}&vital_record.date_of_birth=${applicantDob}`
85
-
86
- const { body, status } = await window.byu.auth.request({ url })
87
- if (status >= 400) {
88
- this.error = true
89
- return null
90
- }
91
-
92
- const data = JSON.parse(body)
93
- const recordCount = data.values.length
94
-
95
- if (recordCount !== 1) {
96
- return null
97
- }
98
-
99
- return data.values[0].byu_id.value
100
- } catch (err) {
101
- console.error(err)
102
- this.error = true
55
+ flagIcon() {
56
+ if (this.flag != null) {
57
+ switch (this.flag.state.toLowerCase()) {
58
+ case 'pass':
59
+ return faCheck
60
+ case 'fail':
61
+ return faMinus
62
+ case 'error':
63
+ return faExclamationTriangle
64
+ case 'indeterminate':
65
+ return faSquare
66
+ default:
67
+ return faExclamationTriangle
103
68
  }
104
69
  }
105
70
  },
106
- async mounted () {
107
- const applicantId = this.applicantId ? this.applicantId : await this.getByuId()
108
- if (!applicantId) {
109
- this.error = true
110
- return
111
- }
112
- try {
113
- const url = this.env !== 'development'
114
- ? `https://api.byu.edu/recordsYAPI/v1.0/student/byuId/${applicantId.trim()}/CESflagsHolds`
115
- : `https://api-sandbox.byu.edu/recordsYAPI/v1.0/student/byuId/${applicantId.trim()}/CESflagsHolds`
116
- const { body, status } = await window.byu.auth.request({ url })
117
- if (status >= 400) {
118
- this.error = true
119
- return
71
+ cesHoldStatus() {
72
+ if (this.flag != null) {
73
+ if (this.flag.message != null && this.flag.message.length > 0) {
74
+ return this.flag.message
120
75
  }
121
- const data = JSON.parse(body)
122
- const recordCount = data.metadata.rows
123
-
124
- if (recordCount > 0) {
125
- this.holdSet = true
126
- this.$emit('ces-hold-set')
127
- } else {
128
- this.$emit('ces-hold-clear')
76
+ else {
77
+ switch (this.flag.state.toLowerCase()) {
78
+ case 'pass':
79
+ return 'Everything looks good!'
80
+ case 'fail':
81
+ return 'Requires additional attention.'
82
+ case 'error':
83
+ return 'An error occurred. Try again later.'
84
+ case 'indeterminate':
85
+ return 'No data available.'
86
+ default:
87
+ return 'An error occurred. Try again later.'
88
+ }
129
89
  }
130
-
131
- this.loaded = true
132
- } catch (err) {
133
- console.error(err)
134
- this.error = true
135
90
  }
136
91
  }
137
92
  }
93
+ }
138
94
  </script>
139
95
  <style scoped>
140
96
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byu-oit/vue-decision-processing-components",
3
- "version": "8.37.0-0",
3
+ "version": "8.37.0-1",
4
4
  "description": "Vue components shared between decision processing systems for the CES schools.",
5
5
  "dependencies": {
6
6
  "@fortawesome/fontawesome-free": "^5.15.4",
@@ -34,6 +34,21 @@ const endorseVirtualFlag = flags => {
34
34
  return { value, name, type, isActive: false, isSet: false, isCleared: false, isBlocking: true, state: 'indeterminate' }
35
35
  }
36
36
 
37
+ const cesHoldsVirtualFlag = flags => {
38
+ const cesHoldsFlag = flags.filter(f => f.value === 'cesHolds')
39
+ if (cesHoldsFlag.length > 0) return cesHoldsFlag[0]
40
+
41
+ const cesFlags = flags.find(f => f.value === 'CES')
42
+ if (cesFlags != null) {
43
+ return { ...cesFlags, state: 'fail' }
44
+ }
45
+
46
+ const value = 'cesHolds'
47
+ const name = 'CES Standard Hold'
48
+ const type = 'Process'
49
+ return { value, name, type, isActive: false, isSet: false, isCleared: false, isBlocking: true, state: 'indeterminate' }
50
+ }
51
+
37
52
  // getters
38
53
  export const getters = {
39
54
  flags (state) {
@@ -47,6 +62,8 @@ export const getters = {
47
62
  return blockingVirtualFlag(flags)
48
63
  } else if (flagValue === 'endorsement') {
49
64
  return endorseVirtualFlag(flags)
65
+ } else if (flagValue === 'cesHolds') {
66
+ return cesHoldsVirtualFlag(flags)
50
67
  }
51
68
  const flag = flags.find(({ value }) => value === flagValue)
52
69
  return flag || { value: flagValue, name: flagValueToName(flagValue), isSet: false, isCleared: false, isActive: false }