diff --git a/.env b/.env index 0bd6ba3..688a65f 100644 --- a/.env +++ b/.env @@ -3,3 +3,15 @@ REACT_APP_AUTH_BASE_URL=http://localhost:3001 REACT_APP_REDIRECT_BASE_URL=http://localhost:3001 REACT_APP_RUUTER_V1_PRIVATE_API_URL=http://localhost:3001 REACT_APP_RUUTER_V2_PRIVATE_API_URL=http://localhost:3001 +REACT_APP_RUUTER_API_URL=http://localhost:8080 +REACT_APP_BUEROKRATT_CHATBOT_URL=http://buerokratt-chat:8080 +REACT_APP_MENU_URL=https://admin.dev.buerokratt.ee +REACT_APP_MENU_PATH=/chat/menu.json +REACT_APP_CUSTOMER_SERVICE_LOGIN=http://localhost:3004/et/dev-auth +REACT_APP_CONVERSATIONS_BASE_URL=http://localhost:8080/chat +REACT_APP_TRAINING_BASE_URL=http://localhost:8080/training +REACT_APP_ANALYTICS_BASE_URL=http://localhost:8080/analytics +REACT_APP_SERVICES_BASE_URL=http://localhost:8080/services +REACT_APP_SETTINGS_BASE_URL=http://localhost:8080/settings +REACT_APP_MONITORING_BASE_URL=http://localhost:8080/monitoring +REACT_APP_SERVICE_ID=conversations,settings,monitoring \ No newline at end of file diff --git a/i18n.ts b/i18n.ts index f007256..9e85e89 100644 --- a/i18n.ts +++ b/i18n.ts @@ -11,7 +11,7 @@ import commonET from './src/translations/et/common.json'; .init({ debug: import.meta.env.NODE_ENV === 'development', fallbackLng: 'et', - supportedLngs: ['et'], + supportedLngs: ['et','en'], resources: { en: { common: commonEN, diff --git a/src/App.tsx b/src/App.tsx index c42a28f..6d5c831 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,41 +2,33 @@ import { FC } from 'react'; import { Navigate, Route, Routes } from 'react-router-dom'; import Layout from './components/layout/layout.tsx'; import WelcomePage from './pages/info/welcome'; -import useUserInfoStore from "./exportcomponents/src/header/store/store"; +import useStore from "./exportcomponents/src/header/store/store"; import {useQuery} from "@tanstack/react-query"; import {UserInfo} from "./exportcomponents/src/header/types/userInfo"; import MainNavigationPage from "./pages/component/main-navigation"; const App: FC = () => { - console.log(import.meta.env.REACT_APP_BASE_URL) - // fetching initial person information - const store = useUserInfoStore(); - // const { data: userInfo } = useQuery<{ - // data: { custom_jwt_userinfo: UserInfo }; - // }>({ - // queryKey: ['cs-custom-jwt-userinfo'], - // onSuccess: (data: { data: { custom_jwt_userinfo: UserInfo } }) => - // store.setUserInfo(data.data.custom_jwt_userinfo), - // }); - // const { data: userInfo } = useQuery({ - // queryKey: ['mock-response', 'auth'], - // onSuccess: (data) => store.setUserInfo(data), - // }); - - const { data: userInfo } = useQuery({ - queryKey: ['steps/tim/mock-response', 'auth'], - onSuccess: (data) => { - console.log(data.response.body.displayName) - store.setUserInfo(data.response.body) + useQuery<{ + data: { custom_jwt_userinfo: UserInfo }; + }>({ + queryKey: ['mock-response'], + onSuccess: (data: { data: { custom_jwt_userinfo: UserInfo } }) => { + return useStore.getState().setUserInfo(data.data.custom_jwt_userinfo); }, }); + return ( }> } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> } /> + } /> ); diff --git a/src/components/layout/layout.tsx b/src/components/layout/layout.tsx index 774a124..b036bbc 100644 --- a/src/components/layout/layout.tsx +++ b/src/components/layout/layout.tsx @@ -1,17 +1,18 @@ import { FC, useState } from 'react'; import { Outlet } from 'react-router-dom'; -// import MainNavigation from 'components/main-navigation/main-navigation.tsx' import './layout.scss'; import { useQuery } from '@tanstack/react-query'; -import { Header, MainNavigation } from "../../exportcomponents/src/index"; +import { + Header, + MainNavigation +} from '../../exportcomponents/src/index.ts'; import useUserInfoStore from "../../exportcomponents/src/header/store/store"; const Layout: FC = () => { const CACHE_NAME = 'mainmenu-cache'; const [MainMenuItems, setMainMenuItems] = useState([]) - const {data, isLoading, status} = useQuery({ - queryKey: [import.meta.env.REACT_APP_MENU_PATH,import.meta.env.REACT_APP_MENU_URL], + queryKey: [import.meta.env.REACT_APP_MENU_URL + import.meta.env.REACT_APP_MENU_PATH], onSuccess: (res: any) => { try { setMainMenuItems(res); @@ -33,14 +34,16 @@ const Layout: FC = () => { return (
-
+
+ + {/**/} +
-
+
+
+
diff --git a/src/components/main-navigation/main-navigation.tsx b/src/components/main-navigation/main-navigation.tsx index 9e2664d..a45bc30 100644 --- a/src/components/main-navigation/main-navigation.tsx +++ b/src/components/main-navigation/main-navigation.tsx @@ -89,7 +89,7 @@ const MainNavigation: FC<{items: MenuItem[]}> = ({items}) => { <> + - - - - - - )} - - - - {showStatusConfirmationModal && ( - setShowStatusConfirmationModal((value) => !value)} - footer={ - <> - + + } - > - {t('global.cancel')} - - - - } - > -
-

- {t('global.statusChangeQuestion')} -

-
-
- )} - - {userInfo && userProfileSettings && userDrawerOpen && ( - {setUserDrawerOpen(false)}} - baseUrlV2={baseUrlV2} - user={user} - /> - )} - +
+

+ {t('global.statusChangeQuestion')} +

+
+ + )} + + {userInfo && userProfileSettings && userDrawerOpen && ( + setUserDrawerOpen(false)} + style={{ width: 400 }} + > +
+ + {[ + { + label: t('settings.users.displayName'), + value: userInfo.displayName, + }, + { + label: t('settings.users.userRoles'), + value: userInfo.authorities + .map((r) => t(`roles.${r}`)) + .join(', '), + }, + { + label: t('settings.users.userTitle'), + value: userInfo.csaTitle?.replaceAll(' ', '\xa0'), + }, + { label: t('settings.users.email'), value: userInfo.csaEmail }, + ].map((meta, index) => ( + +

{meta.label}:

+

{meta.value}

+ + ))} + +
+ {[ + AUTHORITY.ADMINISTRATOR, + AUTHORITY.CUSTOMER_SUPPORT_AGENT, + AUTHORITY.SERVICE_MANAGER, + ].some((auth) => userInfo.authorities.includes(auth)) && ( + <> +
+ +

{t('settings.users.autoCorrector')}

+ + handleUserProfileSettingsChange('useAutocorrect', checked) + } + /> + +
+
+ +

{t('settings.users.emailNotifications')}

+ + handleUserProfileSettingsChange( + 'forwardedChatEmailNotifications', + checked + ) + } + /> + + handleUserProfileSettingsChange( + 'newChatEmailNotifications', + checked + ) + } + /> + +
+
+ +

{t('settings.users.soundNotifications')}

+ + handleUserProfileSettingsChange( + 'forwardedChatSoundNotifications', + checked + ) + } + /> + + handleUserProfileSettingsChange( + 'newChatSoundNotifications', + checked + ) + } + /> + +
+
+ +

{t('settings.users.popupNotifications')}

+ + handleUserProfileSettingsChange( + 'forwardedChatPopupNotifications', + checked + ) + } + /> + + handleUserProfileSettingsChange( + 'newChatPopupNotifications', + checked + ) + } + /> + +
+ + )} +
+ )} + ); }; diff --git a/src/exportcomponents/src/header/store/store.ts b/src/exportcomponents/src/header/store/store.ts index 1a8414d..6030a99 100644 --- a/src/exportcomponents/src/header/store/store.ts +++ b/src/exportcomponents/src/header/store/store.ts @@ -1,15 +1,50 @@ import { create } from 'zustand'; import { UserInfo } from '../types/userInfo'; +import { CHAT_STATUS, Chat as ChatType } from '../types/chat'; interface StoreState { userInfo: UserInfo | null; - setUserInfo: (data: UserInfo) => void; + userId: string; + activeChats: ChatType[]; + selectedChatId: string | null; + chatCsaActive: boolean; + setActiveChats: (chats: ChatType[]) => void; + setUserInfo: (info: UserInfo) => void; + setSelectedChatId: (id: string | null) => void; + setChatCsaActive: (active: boolean) => void; + selectedChat: () => ChatType | null | undefined; + unansweredChats: () => ChatType[]; + forwordedChats: () => ChatType[]; + unansweredChatsLength: () => number; + forwordedChatsLength: () => number; } -const useUserInfoStore = create((set) => ({ +const useStore = create((set, get, store) => ({ userInfo: null, - setUserInfo: (data: UserInfo) => set({ userInfo: data }), -})); + userId: '', + activeChats: [], + selectedChatId: null, + chatCsaActive: false, + setActiveChats: (chats) => set({ activeChats: chats }), + setUserInfo: (data) => set({ userInfo: data, userId: data?.idCode || '' }), + setSelectedChatId: (id) => set({ selectedChatId: id }), + setChatCsaActive: (active) => set({ chatCsaActive: active }), + selectedChat: () => { + const selectedChatId = get().selectedChatId; + return get().activeChats.find(c => c.id === selectedChatId); + }, + unansweredChats: () => { + return get().activeChats.filter(c => c.customerSupportId === ''); + }, + forwordedChats: () => { + const userId = get().userId; + return get().activeChats.filter(c => + c.status === CHAT_STATUS.REDIRECTED && c.customerSupportId === userId + ) || []; + }, + unansweredChatsLength: () => get().unansweredChats().length, + forwordedChatsLength: () => get().forwordedChats().length, +})); -export default useUserInfoStore; +export default useStore; diff --git a/src/exportcomponents/src/header/types/storeState.ts b/src/exportcomponents/src/header/types/storeState.ts deleted file mode 100644 index 0c0450c..0000000 --- a/src/exportcomponents/src/header/types/storeState.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface UserInfo { - JWTCreated: string; - JWTExpirationTimestamp: string; - firstName: string; - lastName: string; - loggedInDate: string; - loginExpireDate: string; - authMethod: string; - fullName: string; - authorities: string[]; - displayName: string; - idCode: string; - email: string; -} - -export interface StoreState { - userInfo: UserInfo | null; - setUserInfo: (data: UserInfo) => void; -} diff --git a/src/exportcomponents/src/header/utils/generateUEID.ts b/src/exportcomponents/src/header/utils/generateUEID.ts new file mode 100644 index 0000000..b2f2def --- /dev/null +++ b/src/exportcomponents/src/header/utils/generateUEID.ts @@ -0,0 +1,6 @@ +export const generateUEID = () => { + const [first, second] = [(Math.random() * 46656) | 0, (Math.random() * 46656) | 0] + .map((value) => ('000' + value.toString(36)).slice(-3)); + + return first + second; +}; diff --git a/src/exportcomponents/src/menu/data/menu-structure.json b/src/exportcomponents/src/menu/data/menu-structure.json index e7cd235..babeda7 100644 --- a/src/exportcomponents/src/menu/data/menu-structure.json +++ b/src/exportcomponents/src/menu/data/menu-structure.json @@ -12,21 +12,21 @@ "et": "Vastamata", "en": "Unanswered" }, - "path": "/chat/chat/unanswered" + "path": "/unanswered" }, { "label": { "et": "Aktiivsed", "en": "Active" }, - "path": "/chat/chat/active" + "path": "/active" }, { "label": { "et": "Ajalugu", "en": "History" }, - "path": "/chat/chat/history" + "path": "/history" } ] }, @@ -50,56 +50,56 @@ "et": "Teemad", "en": "Themes" }, - "path": "/training/training/intents" + "path": "/training/intents" }, { "label": { "et": "Avalikud teemad", "en": "Public themes" }, - "path": "/training/training/common-intents" + "path": "/training/common-intents" }, { "label": { "et": "Teemade järeltreenimine", "en": "Post training themes" }, - "path": "/training/training/intents-followup-training" + "path": "/training/intents-followup-training" }, { "label": { "et": "Vastused", "en": "Answers" }, - "path": "/training/training/responses" + "path": "/training/responses" }, { "label": { "et": "Kasutuslood", "en": "User Stories" }, - "path": "/training/training/stories" + "path": "/training/stories" }, { "label": { "et": "Konfiguratsioon", "en": "Configuration" }, - "path": "/training/training/configuration" + "path": "/training/configuration" }, { "label": { "et": "Vormid", "en": "Forms" }, - "path": "/training/training/forms" + "path": "/training/forms" }, { "label": { "et": "Mälukohad", "en": "Slots" }, - "path": "/training/training/slots" + "path": "/training/slots" } ] }, @@ -108,21 +108,21 @@ "et": "Ajaloolised vestlused", "en": "Historical conversations" }, - "path": "/training/history", + "path": "/history", "children": [ { "label": { "et": "Ajalugu", "en": "History" }, - "path": "/training/history/history" + "path": "/history/history" }, { "label": { "et": "Pöördumised", "en": "Appeals" }, - "path": "/training/history/appeal" + "path": "/history/appeal" } ] }, @@ -131,28 +131,28 @@ "et": "Mudelipank ja analüütika", "en": "Modelbank and analytics" }, - "path": "/training/analytics", + "path": "/analytics", "children": [ { "label": { "et": "Teemade ülevaade", "en": "Overview of topics" }, - "path": "/training/analytics/overview" + "path": "/analytics/overview" }, { "label": { "et": "Mudelite võrdlus", "en": "Comparison of models" }, - "path": "/training/analytics/models" + "path": "/analytics/models" }, { "label": { "et": "Testlood", "en": "testTracks" }, - "path": "/training/analytics/testcases" + "path": "/analytics/testcases" } ] }, @@ -178,42 +178,42 @@ "et": "Ülevaade", "en": "Overview" }, - "path": "/analytics/overview" + "path": "/overview" }, { "label": { "et": "Vestlused", "en": "Chats" }, - "path": "/analytics/chats" + "path": "/chats" }, { "label": { "et": "Bürokratt", "en": "Burokratt" }, - "path": "/analytics/burokratt" + "path": "/burokratt" }, { "label": { "et": "Tagasiside", "en": "Feedback" }, - "path": "/analytics/feedback" + "path": "/feedback" }, { "label": { "et": "Nõustajad", "en": "Advisors" }, - "path": "/analytics/advisors" + "path": "/advisors" }, { "label": { "et": "Avaandmed", "en": "Reports" }, - "path": "/analytics/reports" + "path": "/reports" } ] }, @@ -230,28 +230,28 @@ "et": "Ülevaade", "en": "Overview" }, - "path": "/services/overview" + "path": "/overview" }, { "label": { "et": "Uus teenus", "en": "New Service" }, - "path": "/services/newService" + "path": "/newService" }, { "label": { "et": "Teemade järeltreenimine", "en": "Followup Training" }, - "path": "/services/followupTraining" + "path": "/followupTraining" }, { "label": { "et": "Probleemsed teenused", "en": "Faulty Services" }, - "path": "/services/faultyServices" + "path": "/faultyServices" } ] }, @@ -268,42 +268,42 @@ "et": "Kasutajad", "en": "Users" }, - "path": "/chat/settings/users" + "path": "/users" }, { "label": { "et": "Vestlusbot", "en": "Chatbot" }, - "path": "/chat/settings/chatbot", + "path": "/chatbot", "children": [ { "label": { "et": "Seaded", "en": "Settings" }, - "path": "/chat/settings/chatbot/settings" + "path": "/chatbot/settings" }, { "label": { "et": "Tervitussõnum", "en": "Welcome message" }, - "path": "/chat/settings/chatbot/welcome-message" + "path": "/chatbot/welcome-message" }, { "label": { "et": "Välimus ja käitumine", "en": "Appearance and behavior" }, - "path": "/chat/settings/chatbot/appearance" + "path": "/chatbot/appearance" }, { "label": { "et": "Erakorralised teated", "en": "Emergency notices" }, - "path": "/chat/settings/chatbot/emergency-notices" + "path": "/chatbot/emergency-notices" } ] }, @@ -312,14 +312,14 @@ "et": "Asutuse tööaeg", "en": "Office opening hours" }, - "path": "/chat/settings/working-time" + "path": "/working-time" }, { "label": { "et": "Sessiooni pikkus", "en": "Session length" }, - "path": "/chat/settings/session-length" + "path": "/session-length" } ] }, @@ -336,7 +336,7 @@ "et": "Aktiivaeg", "en": "Working hours" }, - "path": "/chat/monitoring/uptime" + "path": "/uptime" } ] } diff --git a/src/exportcomponents/src/menu/index.tsx b/src/exportcomponents/src/menu/index.tsx index 3cb5114..18fc9da 100644 --- a/src/exportcomponents/src/menu/index.tsx +++ b/src/exportcomponents/src/menu/index.tsx @@ -1,6 +1,6 @@ -import React, { FC, MouseEvent, useEffect, useState } from 'react'; +import React, {FC, MouseEvent, useEffect, useState} from 'react'; -import { NavLink, useLocation } from 'react-router-dom'; +import {NavLink, useLocation} from 'react-router-dom'; import {MdClose, MdKeyboardArrowDown, MdMiscellaneousServices} from 'react-icons/md'; import clsx from 'clsx'; import { MdOutlineForum, MdOutlineAdb, MdOutlineEqualizer, MdSettings, MdOutlineMonitorWeight } from 'react-icons/md'; @@ -22,115 +22,132 @@ interface TranslatedLabel { [lang: string] : string; } -const MainNavigation: FC<{items: MenuItem[], baseUrl: string}> = ({items, baseUrl}) => { - if(items.length === 0) { - items = menuStructure; - } - const { t } = useTranslation(); - const [menuItems, setMenuItems] = useState([]); - const menuIcons = [ - { - id: 'conversations', - icon: , - }, - { - id: 'training', - icon: , - }, - { - id: 'analytics', - icon: , - }, - { - id: "services", - icon: , - }, - { - id: 'settings', - icon: , - }, - { - id: 'monitoring', - icon: , - }, - ]; - - - - const { data } = useQuery({ - queryKey: ['cs-get-user-role', 'prod'], - onSuccess: (res: any) => { - const filteredItems = items.filter((item) => { - const role = res.data.get_user[0].authorities[0] - switch (role) { - case 'ROLE_ADMINISTRATOR': return item.id - case 'ROLE_SERVICE_MANAGER': return item.id != 'settings' && item.id != 'training' - case 'ROLE_CUSTOMER_SUPPORT_AGENT': return item.id != 'settings' && item.id != 'analytics' - case 'ROLE_CHATBOT_TRAINER': return item.id != 'settings' && item.id != 'conversations' - case 'ROLE_ANALYST': return item.id == 'analytics' - case 'ROLE_UNAUTHENTICATED': return - default: return - } - }) ?? [] - setMenuItems(filteredItems) - } +const MainNavigation: FC<{items: MenuItem[], serviceId: string[]}> = ( {items, serviceId}) => { + if(!items.isArray || items.length === 0) { + items = menuStructure; + } + + const { t, i18n } = useTranslation(); + const currentlySelectedLanguage = i18n.language; + const [menuItems, setMenuItems] = useState([]); + const menuData = [ + { + id: 'conversations', + icon: , + url: import.meta.env.REACT_APP_CONVERSATIONS_BASE_URL, + }, + { + id: 'training', + icon: , + url: import.meta.env.REACT_APP_TRAINING_BASE_URL, + }, + { + id: 'analytics', + icon: , + url: import.meta.env.REACT_APP_ANALYTICS_BASE_URL, + }, + { + id: "services", + icon: , + url: import.meta.env.REACT_APP_SERVICES_BASE_URL, + }, + { + id: 'settings', + icon: , + url: import.meta.env.REACT_APP_SETTINGS_BASE_URL, + }, + { + id: 'monitoring', + icon: , + url: import.meta.env.REACT_APP_MONITORING_BASE_URL, + }, + ]; + + let activeMenuId; - }); - - const location = useLocation(); - const [navCollapsed, setNavCollapsed] = useState(false); - - const handleNavToggle = (event: MouseEvent) => { - const isExpanded = event.currentTarget.getAttribute('aria-expanded') === 'true'; - event.currentTarget.setAttribute('aria-expanded', isExpanded ? 'false' : 'true'); - }; - - const renderMenuTree = (menuItems: MenuItem[]) => { - const currentApp = location.pathname; - return menuItems.map((menuItem) => ( -
  • - {!!menuItem.children ? ( - <> - -
      - {renderMenuTree(menuItem.children)} -
    - - ) : ( - {menuItem.label['et']} - )} -
  • ), - ); - }; - - const checkRouting = (location, path) => { - return location.split('/')[1] === path.split('/')[1] + const { data } = useQuery({ + queryKey: ['cs-get-user-role', 'prod'], + onSuccess: (res: any) => { + const filteredItems = items.filter((item) => { + const role = res.data.get_user[0].authorities[0] + switch (role) { + case 'ROLE_ADMINISTRATOR': return item.id + case 'ROLE_SERVICE_MANAGER': return item.id != 'settings' && item.id != 'training' + case 'ROLE_CUSTOMER_SUPPORT_AGENT': return item.id != 'settings' && item.id != 'analytics' + case 'ROLE_CHATBOT_TRAINER': return item.id != 'settings' && item.id != 'conversations' + case 'ROLE_ANALYST': return item.id == 'analytics' + case 'ROLE_UNAUTHENTICATED': return + default: return + } + }) ?? [] + setMenuItems(filteredItems) } - if (!menuItems) return null; + }); + + const location = useLocation(); + const [navCollapsed, setNavCollapsed] = useState(false); + + const handleNavToggle = (event: MouseEvent) => { + const isExpanded = event.currentTarget.getAttribute('aria-expanded') === 'true'; + event.currentTarget.setAttribute('aria-expanded', isExpanded ? 'false' : 'true'); + }; - return ( - + + ) : ( + + (serviceId.includes(menuItem.id)) ? + {menuItem.label[currentlySelectedLanguage] } : + dataItem.id === menuItem.id)?.url + menuItem.path}>{menuItem.label[currentlySelectedLanguage]} + + )} + ), ); + }; + + const base = window.location.pathname.split("/")[1]; + const currentService = base === 'chat' ? serviceId : [base]; + const isSameRoot = (menuItem) => { + let result = false; + if(currentService.includes(menuItem.id)){ + result = menuItem.children.some((item: MenuItem) => item.path?.includes("/" + window.location.pathname.split("/")[2])); + } + return result; + } + + if (!menuItems) return null; + + return ( + + ); }; export default MainNavigation; diff --git a/src/exportcomponents/vite.config.ts b/src/exportcomponents/vite.config.ts index 2ce4a69..7921c70 100644 --- a/src/exportcomponents/vite.config.ts +++ b/src/exportcomponents/vite.config.ts @@ -23,10 +23,12 @@ export default defineConfig({ '~@fontsource': path.resolve(__dirname, 'node_modules/@fontsource'), }, }, - css: { - modules: { - scopeBehaviour: 'local', - } + css: { + preprocessorOptions: { + scss: { + additionalData: `@import "@/styles/main.scss";`, + }, + }, }, // Configuration for building your library. diff --git a/src/main.tsx b/src/main.tsx index e517cbc..4deeb6a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -13,6 +13,7 @@ import '../i18n'; import { mockApi } from "./components/services/mock-apis"; import * as mocks from "./mocks/mockHandlers"; import auth from "./exportcomponents/src/header/services/auth"; +import apiDev from "./exportcomponents/src/header/services/api-dev.ts"; // **** Query client **** // Query client part is not directly raleted to layout so it is optional diff --git a/src/mocks/mockHandlers.ts b/src/mocks/mockHandlers.ts index 9f98a09..027dc75 100644 --- a/src/mocks/mockHandlers.ts +++ b/src/mocks/mockHandlers.ts @@ -1,5 +1,4 @@ import { api } from '../components/services/mock-apis'; -import * as API_CONF from '../exportcomponents/src/header/services/api-conf'; import {CUSTOM_JWT_INFO} from '../exportcomponents/src/header/services/api-conf'; let stateSwitch = true; @@ -9,9 +8,16 @@ let currentState = { active: stateSwitch ? 'true' : 'false', status: stateSwitch ? 'online' : 'offline' } + +const str = '{"data":{"get_all_active_chats":[{"id":"3d14f0bb-5bb9-4ee0-b82f-ba7c08a0e854","customerSupportId":"EE30303039914","customerSupportDisplayName":"OK","csaTitle":"OG","endUserId":"","endUserFirstName":"","endUserLastName":"","status":"OPEN","created":"2023-10-11T09:01:06.529+00:00","updated":"2023-11-03T14:25:15.737+00:00","ended":null,"endUserEmail":"","endUserPhone":"","endUserOs":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36","endUserUrl":"https://dev.buerokratt.ee/","externalId":"","forwardedTo":"","forwardedToName":"","receivedFrom":"","receivedFromName":"","lastMessage":"klienditeenindaja","contactsMessage":null,"lastMessageTimestamp":"2023-10-11T09:01:06.520+00:00","lastMessageEvent":"greeting"},{"id":"da5d1716-df64-4a67-80ee-285132f6b6b0","customerSupportId":"EE30303039914","customerSupportDisplayName":"OK","csaTitle":"OG","endUserId":"","endUserFirstName":"","endUserLastName":"","status":"OPEN","created":"2023-10-11T11:18:48.421+00:00","updated":"2023-11-03T14:23:53.835+00:00","ended":null,"endUserEmail":"","endUserPhone":"","endUserOs":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0","endUserUrl":"https://dev.buerokratt.ee/","externalId":"","forwardedTo":"","forwardedToName":"","receivedFrom":"","receivedFromName":"","lastMessage":"tere","contactsMessage":null,"lastMessageTimestamp":"2023-10-11T11:18:48.413+00:00","lastMessageEvent":"greeting"},{"id":"58e12d9b-90f0-4494-8594-fc1dba5ec4dc","customerSupportId":"EE30303039914","customerSupportDisplayName":"OK","csaTitle":"OG","endUserId":"","endUserFirstName":"","endUserLastName":"","status":"OPEN","created":"2023-10-12T07:15:29.610+00:00","updated":"2023-11-03T09:18:23.735+00:00","ended":null,"endUserEmail":"","endUserPhone":"","endUserOs":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36","endUserUrl":"https://dev.buerokratt.ee/","externalId":"","forwardedTo":"","forwardedToName":"","receivedFrom":"","receivedFromName":"","lastMessage":"suuna","contactsMessage":null,"lastMessageTimestamp":"2023-10-12T07:15:29.528+00:00","lastMessageEvent":"greeting"},{"id":"308d710e-7c58-4ead-94ba-a63edbf96dcb","customerSupportId":"EE30303039816","customerSupportDisplayName":"Janina","csaTitle":"test","endUserId":"","endUserFirstName":"","endUserLastName":"","status":"OPEN","created":"2023-11-08T14:58:42.037+00:00","updated":"2023-11-08T14:58:48.997+00:00","ended":null,"endUserEmail":"","endUserPhone":"","endUserOs":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","endUserUrl":"https://dev.buerokratt.ee/","externalId":"","forwardedTo":"","forwardedToName":"","receivedFrom":"","receivedFromName":"","lastMessage":"suuna","contactsMessage":null,"lastMessageTimestamp":"2023-11-08T14:58:56.831+00:00","lastMessageEvent":"message-read"}]},"error":null}'; + +export const allChats = + api + .onGet('cs-get-all-active-chats') + .reply(200,JSON.parse(str)) export const customJwt = api - .onGet('/api' + CUSTOM_JWT_INFO) + .onGet('mock-response') .reply(200, { data: { custom_jwt_userinfo: { @@ -34,7 +40,7 @@ export const customJwt = export const getUserRole = api - .onGet('cs-get-user-role') + .onGet( 'cs-get-user-role') .reply(200, { data: { get_user: [ @@ -48,18 +54,34 @@ export const getUserRole = export const getProfieSettings = api - .onGet("/cs-get-user-profile-settings?userId=1") + .onGet("cs-get-user-profile-settings?userId=*") .reply(200, { response: null }) +export const getUserProfileSettings = + api + .onPost("cs-get-user-profile-settings") + .reply(200,{ + "response": { + "userId'": 1, + "forwardedChatPopupNotifications": true, + "forwardedChatSoundNotifications": true, + "forwardedChatEmailNotifications": true, + "newChatPopupNotifications": true, + "newChatSoundNotifications": true, + "newChatEmailNotifications": true, + "useAutocorrect": false + } + }) + export const setProfileSettings = api .onPost('/') .reply(200, {}) export const getCustomerSupportActivity = api - .onGet('/' + API_CONF.GET_CUSTOMER_SUPPORT_ACTIVITY) + .onGet('cs-get-customer-support-activity') .reply(200, { data: { get_customer_support_activity: [ @@ -75,7 +97,7 @@ export const getCustomerSupportActivity = export const setCustomerSupportActivity = api - .onPost('/' + API_CONF.SET_CUSTOMER_SUPPORT_ACTIVITY, { + .onPost('cs-set-customer-support-activity', { idCode: currentState.idCode, active: currentState.active, status: currentState.status