From 9b93cd453f4bb08ecdb204d643eb8d9fad20e157 Mon Sep 17 00:00:00 2001 From: tonyco97 Date: Wed, 30 Oct 2024 11:41:25 +0100 Subject: [PATCH] speedDial. Avoid speedDials operators to be set as favourite --- .../history/ShowHistoryDrawerContent.tsx | 41 ++++++++++--------- lib/operators.ts | 12 +++++- public/locales/en/translation.json | 20 +++++++++ public/locales/it/translation.json | 20 +++++++++ 4 files changed, 71 insertions(+), 22 deletions(-) diff --git a/components/history/ShowHistoryDrawerContent.tsx b/components/history/ShowHistoryDrawerContent.tsx index 27b8c5b4..6cd298e7 100644 --- a/components/history/ShowHistoryDrawerContent.tsx +++ b/components/history/ShowHistoryDrawerContent.tsx @@ -11,6 +11,7 @@ import { LastCallsDrawerTable } from './LastCallsDrawerTable' import { startOfDay, subDays } from 'date-fns' import { useSelector } from 'react-redux' import { RootState } from '../../store' +import { t } from 'i18next' export interface ShowHistoryDrawerContentProps extends ComponentPropsWithRef<'div'> { config: any @@ -24,7 +25,7 @@ function checkTitle(config: any) {
-

{config.name}

+

{config?.name}

) @@ -35,7 +36,7 @@ function checkTitle(config: any) {
-

{config.company}

+

{config?.company}

) @@ -46,7 +47,7 @@ function checkTitle(config: any) {
-

{config.number}

+

{config?.number}

) @@ -64,7 +65,7 @@ export const ShowHistoryDrawerContent = forwardRef<
- History details + {t('Common.History details')}
@@ -84,12 +85,12 @@ export const ShowHistoryDrawerContent = forwardRef<
- {!config.name && !config.company && ( + {!config?.name && !config?.company && ( )}
- {config.company && ( + {config?.company && (
{/* Company name */}
- Company name + {t('Common.Company name')}
- {config.company} + {config?.company}
{/* Phone number */}
- Phone number + {t('Common.Phone number')}
@@ -133,7 +134,7 @@ export const ShowHistoryDrawerContent = forwardRef< aria-hidden='true' /> - {config.number} + {config?.number}
@@ -141,13 +142,13 @@ export const ShowHistoryDrawerContent = forwardRef<
)} - {config.name && !config.company && config.number && ( + {config?.name && !config?.company && config?.number && (
{/* Phone number */}
- Phone number + {t('Common.Phone number')}
@@ -157,7 +158,7 @@ export const ShowHistoryDrawerContent = forwardRef< aria-hidden='true' /> - {config.number} + {config?.number}
@@ -168,12 +169,12 @@ export const ShowHistoryDrawerContent = forwardRef<
{/* last calls */} - {profile.macro_permissions?.cdr?.permissions?.ad_cdr?.value && ( + {profile?.macro_permissions?.cdr?.permissions?.ad_cdr?.value && ( )} diff --git a/lib/operators.ts b/lib/operators.ts index 03061de7..48d9386a 100644 --- a/lib/operators.ts +++ b/lib/operators.ts @@ -272,10 +272,16 @@ export const retrieveAvatars = async (authStore: any) => { export const retrieveFavoriteOperators = async (authStore: any, operatorObject: any) => { store.dispatch.operators.setFavoritesLoaded(false) const speedDials = await getSpeedDials() + + // Avoid to add a favorite operator if you add it in the speed dials form const speedDialMap: any = speedDials.reduce((acc: any, speedDial: any) => { - acc[speedDial?.name] = { id: speedDial?.id } + if (speedDial?.notes === 'speeddial-favorite') { + acc[speedDial?.name] = { id: speedDial?.id } + } return acc }, {}) + + // Retrieve the favorite operators from the speed dials Object store.dispatch.operators.setFavoritesObjectComplete(speedDialMap) const favoriteOperatorsLocalStorage = @@ -307,7 +313,9 @@ export const retrieveFavoriteOperators = async (authStore: any, operatorObject: clearPreference('favoriteOperators', authStore?.username) } - const speedDialOwners = speedDials.map((speedDial: any) => speedDial?.name) + const speedDialOwners = speedDials + .filter((speedDial: any) => speedDial?.notes === 'speeddial-favorite') + .map((speedDial: any) => speedDial?.name) store.dispatch.operators.setFavorites(speedDialOwners) store.dispatch.operators.setFavoritesLoaded(true) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index c4790917..e97a0cb5 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -13,6 +13,10 @@ "Save": "Save", "Try changing your search filters": "Try changing your search filters", "Phone number": "Phone number", + "Company name": "Company name", + "Call": "Call", + "History details": "History details", + "Add to phonebook": "Add to phonebook", "time_distance_ago": "{{ timeDistance }} ago", "0 minutes ago": "0 minutes ago", "Add to favorites": "Add to favorites", @@ -878,5 +882,21 @@ }, "Transfer": { "No users found": "No users found" + }, + "Errors": { + "browser_permissions": "Browser Permissions Error", + "user_permissions": "User Permissions Error", + "unknown_media_permissions": "Unknown Media Permissions Error", + "webrtc_down": "WebRTC Down", + "socket_down": "Socket Down", + "busy_camera": "Busy Camera", + "call_transfered": "Call Transferred Successfully", + "The browser doesn't have permission to access camera or microphone.": "The browser doesn't have permission to access camera or microphone.", + "You must accept audio and video permissions.": "You must accept audio and video permissions.", + "Web Phone can't access audio or camera on this device.": "Web Phone can't access audio or camera on this device.", + "Web Phone connection is down.": "Web Phone connection is down.", + "Server connection is down.": "Server connection is down.", + "Camera is used by another application.": "Camera is used by another application.", + "Call transferred successfully.": "Call transferred successfully." } } diff --git a/public/locales/it/translation.json b/public/locales/it/translation.json index 190290d8..5abeba1d 100644 --- a/public/locales/it/translation.json +++ b/public/locales/it/translation.json @@ -14,6 +14,10 @@ "Warning": "Attenzione", "Calling": "In chiamata", "Phone number": "Numero telefonico", + "Company name": "Nome azienda", + "Call": "Chiama", + "History details": "Dettagli storico", + "Add to phonebook": "Aggiungi alla rubrica", "Operators": "Operatori", "Phonebook": "Rubrica", "History": "Storico", @@ -855,5 +859,21 @@ }, "Transfer": { "No users found": "Nessun utente trovato" + }, + "Errors": { + "browser_permissions": "Errore di autorizzazione", + "user_permissions": "Errore di autorizzazione", + "unknown_media_permissions": "Errore di autorizzazione", + "webrtc_down": "WebRTC non disponibile", + "socket_down": "Socket non disponibile", + "busy_camera": "Camera occupata", + "call_transfered": "Chiamata trasferita con successo", + "The browser doesn't have permission to access camera or microphone.": "Il browser non ha il permesso di accedere alla fotocamera o al microfono.", + "You must accept audio and video permissions.": "Devi accettare i permessi audio e video.", + "Web Phone can't access audio or camera on this device.": "Il Web Phone non può accedere all'audio o alla fotocamera su questo dispositivo.", + "Web Phone connection is down.": "La connessione del Web Phone è interrotta.", + "Server connection is down.": "La connessione al server è interrotta.", + "Camera is used by another application.": "La fotocamera è utilizzata da un'altra applicazione.", + "Call transferred successfully.": "Chiamata trasferita con successo." } }