From fa748c6ed5a245f78bdd957351be6a77f681de8b Mon Sep 17 00:00:00 2001 From: AyushRanjan Date: Wed, 6 Dec 2023 12:01:01 +0530 Subject: [PATCH] TP-49977 | api integerated --- .../DescriptionContentProps.ts | 4 ++++ .../Incidents/DescriptionContent/index.tsx | 22 +++++++++++++++++++ src/Pages/Incidents/constants.ts | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/src/Pages/Incidents/DescriptionContent/DescriptionContentProps.ts b/src/Pages/Incidents/DescriptionContent/DescriptionContentProps.ts index 1498865..ff43c60 100644 --- a/src/Pages/Incidents/DescriptionContent/DescriptionContentProps.ts +++ b/src/Pages/Incidents/DescriptionContent/DescriptionContentProps.ts @@ -16,6 +16,7 @@ export const initialState = { errorText: '', helperText: '', jiraLinks: [], + rcaLinks: '', }; export const ActionType = { @@ -25,6 +26,7 @@ export const ActionType = { SET_ERROR_TEXT: 'SET_ERROR_TEXT', SET_HELPER_TEXT: 'SET_HELPER_TEXT', SET_JIRA_LINKS: 'SET_JIRA_LINKS', + SET_RCA_LINKS: 'SET_RCA_LINKS', }; export const reducer = (state, action) => { @@ -41,6 +43,8 @@ export const reducer = (state, action) => { return { ...state, helperText: action.payload }; case ActionType.SET_JIRA_LINKS: return { ...state, jiraLinks: action.payload }; + case ActionType.SET_RCA_LINKS: + return { ...state, rcaLinks: action.payload }; default: return state; } diff --git a/src/Pages/Incidents/DescriptionContent/index.tsx b/src/Pages/Incidents/DescriptionContent/index.tsx index fc97077..b493349 100644 --- a/src/Pages/Incidents/DescriptionContent/index.tsx +++ b/src/Pages/Incidents/DescriptionContent/index.tsx @@ -32,6 +32,7 @@ import { LINK_JIRA_INCIDENT, UNLINK_JIRA_INCIDENT, FETCH_INCIDENT_DATA, + FETCH_RCA_LINK, } from '../constants'; const DescriptionContent: React.FC = ({ @@ -50,6 +51,27 @@ const DescriptionContent: React.FC = ({ dispatch({ type: ActionType.SET_JIRA_LINKS, payload: jiraIds || [] }); }, [jiraIds]); + useEffect(() => { + startRcaLinkSearch(); + }, []); + + const startRcaLinkSearch = (): void => { + const endPoint = FETCH_RCA_LINK(id.toString()); + ApiService.get(endPoint) + .then(response => { + console.log(response); + dispatch({ type: ActionType.SET_RCA_LINKS, payload: response?.data }); + }) + .catch(error => { + const toastMessage = `${ + error?.response?.data?.error?.message + ? `${error?.response?.data?.error?.message},` + : '' + }`; + toast.error(toastMessage); + }); + }; + const handleApiError = (error: any): void => { const errorMessage = error?.response?.data?.error?.message || 'An error occurred.'; diff --git a/src/Pages/Incidents/constants.ts b/src/Pages/Incidents/constants.ts index 91a6ce5..5fd4031 100644 --- a/src/Pages/Incidents/constants.ts +++ b/src/Pages/Incidents/constants.ts @@ -38,6 +38,10 @@ export const FETCH_AUDIT_LOG = (incidentId: string): string => { return `${URL_PREFIX}/logs/incident/${incidentId}`; }; +export const FETCH_RCA_LINK = (incidentId: string): string => { + return `${URL_PREFIX}/getRCALinkForIncident/${incidentId}`; +}; + export interface ContentProps { incidentData: any; }