Skip to content

Commit

Permalink
Removed MSW endpoints. (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoKull authored Oct 31, 2023
1 parent 95b7e07 commit a6d1470
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 14 deletions.
21 changes: 21 additions & 0 deletions DSL/Ruuter/GET/generic/cs-custom-jwt-userinfo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
step_1:
call: reflect.mock
args:
response:
firstName: null
lastName: null
idCode: 'EE60001019906'
displayName: 'Admin'
JWTCreated: 1674204041000
login: 'Admin'
authorities:
- 'ROLE_ADMINISTRATOR'
- 'ROLE_SERVICE_MANAGER'
- 'ROLE_CUSTOMER_SUPPORT_AGENT'
- 'ROLE_CHATBOT_TRAINER'
- 'ROLE_ANALYST'
JWTExpirationTimestamp: 1674232841000
result: reflected_request

step_2:
return: ${reflected_request.response.body}
66 changes: 66 additions & 0 deletions DSL/Ruuter/GET/generic/cs-get-all-active-chats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
step_1:
call: reflect.mock
args:
response:
data:
- id: '22fa5630-6f92-4d50-92ba-685c872383af'
customerSupportId: ''
customerSupportDisplayName: ''
endUserId: ''
endUserFirstName: ''
endUserLastName: ''
status: 'OPEN'
created: '2023-01-17T13:18:38.808+00:00'
updated: '2023-01-17T13:19:26.348+00:00'
ended: null
endUserOs: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
endUserUrl: 'https://test.buerokratt.ee/'
forwardedToName: null
forwardedByUser: ''
forwardedFromCsa: ''
forwardedToCsa: ''
lastMessage: 'Suunan teid klienditeenindajale. Varuge natukene kannatust.'
contactsMessage: null
lastMessageTimestamp: '2023-01-17T13:19:26.316+00:00'
- id: '5206b7bd-0812-40a8-ae1d-3774f07f06f0'
customerSupportId: ''
customerSupportDisplayName: ''
endUserId: ''
endUserFirstName: ''
endUserLastName: ''
status: 'OPEN'
created: '2023-01-19T13:38:32.421+00:00'
updated: '2023-01-19T13:38:32.430+00:00'
ended: null
endUserOs: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
endUserUrl: 'https://test.buerokratt.ee/'
forwardedToName: null
forwardedByUser: ''
forwardedFromCsa: ''
forwardedToCsa: ''
lastMessage: 'aitäh'
contactsMessage: null
lastMessageTimestamp: '2022-11-23T09:33:56.803+00:00'
- id: 'b7bba1c2-b7ab-4b17-825a-2d66a7d16fc4'
customerSupportId: ''
customerSupportDisplayName: ''
endUserId: ''
endUserFirstName: ''
endUserLastName: ''
status: 'OPEN'
created: '2023-01-19T13:38:32.421+00:00'
updated: '2023-01-19T13:38:32.430+00:00'
ended: null
endUserOs: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
endUserUrl: 'https://test.buerokratt.ee/'
forwardedToName: null
forwardedByUser: ''
forwardedFromCsa: ''
forwardedToCsa: ''
lastMessage: 'dasnhpwa'
contactsMessage: null
lastMessageTimestamp: '2023-01-18T12:24:54.557+00:00'
result: reflected_request

step_2:
return: ${reflected_request.response.body}
11 changes: 11 additions & 0 deletions DSL/Ruuter/GET/generic/cs-get-customer-support-activity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
step_1:
call: reflect.mock
args:
response:
idCode: 'EE49902216518'
active: 'true'
status: 'idle'
result: reflected_request

step_2:
return: ${reflected_request.response.body}
16 changes: 16 additions & 0 deletions DSL/Ruuter/GET/generic/cs-get-user-profile-settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
step_1:
call: reflect.mock
args:
response:
userId': 1
forwardedChatPopupNotifications: true
forwardedChatSoundNotifications: true
forwardedChatEmailNotifications: true
newChatPopupNotifications: true
newChatSoundNotifications: true
newChatEmailNotifications: true
useAutocorrect: false
result: reflected_request

step_2:
return: ${reflected_request.response.body}
12 changes: 12 additions & 0 deletions DSL/Ruuter/GET/generic/cs-get-user-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
step_1:
call: reflect.mock
args:
response:
data:
get_user:
- authorities:
- "ROLE_ADMINISTRATOR"
result: reflected_request

step_2:
return: ${reflected_request.response.body}
Binary file removed GUI/exirain-header-0.0.22.tgz
Binary file not shown.
Binary file added GUI/exirain-header-0.0.26.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion GUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"msw": "^0.49.2",
"react-cookie": "^4.1.1",
"axios-mock-adapter": "^1.21.5",
"@exirain/header": "file:exirain-header-0.0.22.tgz",
"@exirain/header": "file:exirain-header-0.0.26.tgz",
"@fontsource/roboto": "^4.5.8",
"@formkit/auto-animate": "^1.0.0-beta.6",
"@hookform/resolvers": "^2.9.11",
Expand Down
21 changes: 15 additions & 6 deletions GUI/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ import {UserInfo} from "./types/userInfo";

const App: React.FC = () => {
const store = useUserInfoStore();
const { data: userInfo } = useQuery<UserInfo>({
queryKey: [import.meta.env.REACT_APP_AUTH_PATH, 'auth'],
onSuccess: (data: { data: { custom_jwt_userinfo: UserInfo } }) =>
store.setUserInfo(data.data.custom_jwt_userinfo),
});
if(import.meta.env.REACT_APP_LOCAL === 'true') {

return (
const { data } = useQuery<UserInfo>({
queryKey: ['cs-custom-jwt-userinfo', 'prod'],
onSuccess: (res: any) => store.setUserInfo(res)
})
} else {
const { data: userInfo } = useQuery<UserInfo>({
queryKey: [import.meta.env.REACT_APP_AUTH_PATH, 'auth'],
onSuccess: (data: { data: { custom_jwt_userinfo: UserInfo } }) =>
store.setUserInfo(data.data.custom_jwt_userinfo),
});
}


return (
<Provider store={reducer}>
<BrowserRouter basename={import.meta.env.BASE_URL}>
<ToastProvider>
Expand Down
22 changes: 15 additions & 7 deletions GUI/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,31 @@ import {mockApi} from "./services/mock-apis";
import apiDev from "./services/api-dev";
import apiDevV2 from "./services/api-dev-v2";
import auth from "./services/auth";
import apigeneric from "./services/apigeneric";
import apiAn from './services/analytics-api';
import * as mocks from "./services/mockHandlers";

mocks

const defaultQueryFn: QueryFunction | undefined = async ({ queryKey }) => {
if (import.meta.env.REACT_APP_LOCAL === 'true' && (queryKey[0].includes('cs') || queryKey[0].includes('auth'))) {
const { data } = await mockApi.get(queryKey[0] as string);
return data;
}
if (queryKey.includes('prod')) {
const { data } = await apiDev.get(queryKey[0] as string);
return data;
if (import.meta.env.REACT_APP_LOCAL === 'true') {
if (queryKey.includes('prod')) {
const { data } = await apigeneric.get(queryKey[0] as string);
return data?.response;
}
}
if (queryKey.includes('user-profile-settings')) {
const { data } = await apiAn.get(queryKey[0] as string);
return data;
}
if (queryKey.includes('prod')) {
if (queryKey.includes('cs-get-all-active-chats')) {
const {data} = await apiDev.get('sse/'+queryKey[0] as string);
} else {
const {data} = await apiDev.get(queryKey[0] as string);
}
return data;
}
if (queryKey[1] === 'prod-2') {
const { data } = await apiDevV2.get(queryKey[0] as string);
return data?.response;
Expand Down
24 changes: 24 additions & 0 deletions GUI/src/services/analytics-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import axios, { AxiosError } from 'axios';

const instance = axios.create({
baseURL: import.meta.env.REACT_APP_RUUTER_V2_ANALYTICS_API_URL,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
withCredentials: true,
});

instance.interceptors.response.use(
(response) => {
return response;
},
(error: AxiosError) => {
if (error.response?.status === 401) {
//TODO: handle unauthorized requests
}
return Promise.reject(error);
}
);

export default instance;
31 changes: 31 additions & 0 deletions GUI/src/services/apigeneric.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import axios, {AxiosError} from 'axios';

const testCookie = 'bearer ' + (localStorage.getItem('token') || 'test');

const instance = axios.create({
baseURL: import.meta.env.REACT_APP_RUUTER_V1_PRIVATE_API_URL + '/generic/',
headers: {
Accept: 'application/json',
Testcookie: ''
},
withCredentials: false,
});

instance.interceptors.request.use((config) => {
config.headers['Testcookie'] = testCookie;
return config;
});

instance.interceptors.response.use(
(response) => {
return response;
},
(error: AxiosError) => {
if (error.response?.status === 401) {

}
return Promise.reject(error);
},
);

export default instance;

0 comments on commit a6d1470

Please sign in to comment.