TP-49977 | api integerated

This commit is contained in:
AyushRanjan
2023-12-06 12:01:01 +05:30
parent 2cb51d5cc0
commit fa748c6ed5
3 changed files with 30 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -32,6 +32,7 @@ import {
LINK_JIRA_INCIDENT,
UNLINK_JIRA_INCIDENT,
FETCH_INCIDENT_DATA,
FETCH_RCA_LINK,
} from '../constants';
const DescriptionContent: React.FC<DescriptionContentProps> = ({
@@ -50,6 +51,27 @@ const DescriptionContent: React.FC<DescriptionContentProps> = ({
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.';

View File

@@ -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;
}