Skip to content

Commit

Permalink
feat(manual-dialer): add hotline validation (#1310)
Browse files Browse the repository at this point in the history
- Add `hasActiveHotline` computed property to ensure a hotline is active before allowing dial functionality.
- Import `useActiveHotlines` to check for active hotline incidents.
- Update button `:disabled` logic to include `hasActiveHotline`.
- Optimize imports by removing unused `useI18n` and `useEmitter`.
  • Loading branch information
tabiodun authored Nov 29, 2024
1 parent 45dc2b6 commit 126ad05
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/phone/ManualDialer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
:alt="
dialing ? $t('phoneDashboard.dialing') : $t('phoneDashboard.dial')
"
:disabled="dialing || !phone || after10pmEastern"
:disabled="dialing || !phone || after10pmEastern || !hasActiveHotline"
@click="handleDial"
></base-button>

Expand All @@ -71,6 +71,7 @@ import useEmitter from '../../hooks/useEmitter';
import BaseInput from '@/components/BaseInput.vue';
import moment from 'moment';
import PhoneNumberInput from '@/components/PhoneNumberInput.vue';
import { useActiveHotlines } from '@/hooks/useActiveHotlines';
export default defineComponent({
name: 'EnhancedManualDialer',
Expand All @@ -87,8 +88,7 @@ export default defineComponent({
},
emits: ['onDial', 'onRemoveNumberFromQueue'],
setup(props, { emit }) {
const { t } = useI18n();
const { emitter } = useEmitter();
const { isLoading, incidentsWithActiveHotline } = useActiveHotlines();
const phone = ref('');
const selectedCountryCode = ref('+1');
Expand Down Expand Up @@ -116,6 +116,10 @@ export default defineComponent({
emit('onRemoveNumberFromQueue', phone.value);
};
const hasActiveHotline = computed(() => {
return incidentsWithActiveHotline.value.length > 0;
});
onMounted(() => {
updateAfter10State();
if (props.phoneNumber) {
Expand All @@ -129,6 +133,7 @@ export default defineComponent({
handleDial,
removeNumberFromQueue,
after10pmEastern,
hasActiveHotline,
};
},
});
Expand Down

0 comments on commit 126ad05

Please sign in to comment.