Skip to content

Commit a5f114b

Browse files
authored
feat: Add carrier dropdown and remediation logic to PhoneDoctor component (#1282)
- import BaseSelect component and formatCmsItem helper function - add state management for carrier selection and remediation extraction - fetch and initialize dropdown items from CMS on component mount - update error section layout to use grid and fix toggling logic for issues - introduce BaseSelect dropdown for carrier selection and display remediation content
1 parent fb8e18d commit a5f114b

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

src/components/phone/PhoneDoctor.vue

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { isWebSocketAvailable } from '@/utils/websocket';
1313
import PhoneTestService from '@/services/phone.test.service';
1414
import BaseInput from '@/components/BaseInput.vue';
1515
import User from '@/models/User';
16+
import BaseSelect from '@/components/BaseSelect.vue';
17+
import { formatCmsItem } from '@/utils/helpers';
1618
1719
const { t } = useI18n();
1820
const { currentUser } = useCurrentUser();
@@ -61,13 +63,34 @@ const showingNoCallIssues = ref(false);
6163
const showingNotPlayingNicelyIssues = ref(false);
6264
const showingPressOneIssues = ref(false);
6365
const showingPrematureHangupIssues = ref(false);
66+
const nothingWorked = ref(false);
67+
68+
const selectedCarrier = ref(null);
69+
const carrierRemediation = computed(() => {
70+
if (selectedCarrier.value) {
71+
return dropdownItems.value.find((item) => item.id === selectedCarrier.value)
72+
?.content;
73+
}
74+
return '';
75+
});
76+
const dropdownItems = ref([]);
6477
6578
const supportedPhoneLanguages = computed(() => {
6679
const languages = Language.all();
6780
const ids = new Set([2, 7]);
6881
return languages.filter((l) => ids.has(Number(l.id)));
6982
});
7083
84+
async function getCarrierDropdownItems() {
85+
const response = await axios.get(
86+
`${import.meta.env.VITE_APP_API_BASE_URL}/cms?tags=phone-doctor`,
87+
);
88+
if (response && response.data && response.data.results)
89+
dropdownItems.value = response.data.results.filter((item) =>
90+
item.tags.includes('dropdown'),
91+
);
92+
}
93+
7194
async function configureAgent() {
7295
const { data: currentAgent } = await axios.get(
7396
`${import.meta.env.VITE_APP_API_BASE_URL}/phone_agents/me`,
@@ -617,6 +640,10 @@ const resetDiagnostics = () => {
617640
}
618641
isDiagnosticsRunning.value = false;
619642
};
643+
644+
onMounted(() => {
645+
getCarrierDropdownItems();
646+
});
620647
</script>
621648

622649
<template>
@@ -853,7 +880,7 @@ const resetDiagnostics = () => {
853880
</template>
854881

855882
<div v-if="stepStatuses['test'] === STEP_STATUS.ERROR">
856-
<div class="flex gap-3 mt-5">
883+
<div class="grid gap-3 mt-5 grid-cols-3">
857884
<base-button
858885
:action="
859886
() => {
@@ -892,7 +919,6 @@ const resetDiagnostics = () => {
892919
showingNotPlayingNicelyIssues = true;
893920
showingNoCallIssues = false;
894921
showingVoicemailIssues = false;
895-
showingNotPlayingNicelyIssues = false;
896922
showingPressOneIssues = false;
897923
showingPrematureHangupIssues = false;
898924
nothingWorked = false;
@@ -1001,18 +1027,18 @@ const resetDiagnostics = () => {
10011027
>
10021028
{{ $t('phoneDashboard.try_again') }}
10031029
</base-button>
1004-
<base-button
1005-
:action="
1006-
() => {
1007-
nothingWorked = true;
1008-
}
1009-
"
1010-
variant="outline"
1011-
size="large"
1012-
>
1013-
{{ $t('phoneDoctor.nothing_worked') }}
1014-
</base-button>
10151030
</div>
1031+
<base-button
1032+
:action="
1033+
() => {
1034+
nothingWorked = true;
1035+
}
1036+
"
1037+
variant="outline"
1038+
size="large"
1039+
>
1040+
{{ $t('phoneDoctor.nothing_worked') }}
1041+
</base-button>
10161042
</div>
10171043
<div v-if="showingPrematureHangupIssues" class="mt-5">
10181044
{{ $t('phoneDoctor.hung_up_on_me_troubleshooting') }}
@@ -1039,7 +1065,22 @@ const resetDiagnostics = () => {
10391065
</div>
10401066
<div v-if="nothingWorked" class="mt-5">
10411067
{{ $t('phoneDoctor.google_voice_instructions') }}
1042-
***Insert Carrier dropdown here from the CMS. pull from CMS items tagged with `phone-doctor` and `dropdown`. The subject should be the dropdown selector. Then when they select it, the body of the CMS should appear. The body will have html, so make sure that v-html renders.
1068+
<base-select
1069+
v-model="selectedCarrier"
1070+
:options="dropdownItems"
1071+
select-classes="bg-white border w-64 mx-2 z-toolbar"
1072+
item-key="id"
1073+
label="title"
1074+
class="my-2"
1075+
>
1076+
<template #selected-option="{ option }">
1077+
<div class="w-full px-2">{{ $t(formatCmsItem(option.title)) }}</div>
1078+
</template>
1079+
<template #option="{ option }">
1080+
{{ $t(formatCmsItem(option.title)) }}
1081+
</template>
1082+
</base-select>
1083+
{{ $t(formatCmsItem(carrierRemediation)) }}
10431084
</div>
10441085

10451086
<base-button

0 commit comments

Comments
 (0)