diff --git a/src/Pages/Dashboard/index.tsx b/src/Pages/Dashboard/index.tsx index 5abb050..93422d2 100644 --- a/src/Pages/Dashboard/index.tsx +++ b/src/Pages/Dashboard/index.tsx @@ -57,12 +57,16 @@ const Dashboard: FC = () => { pageNumber - 1 }&page_size=${currentPageSize}`; setPageNumber(pageNumber - 1); + pageNumberRef.current = `page_number=${ + pageNumber - 1 + }&page_size=${currentPageSize}`; startIncidentSearch(`${searchParamRef.current}${finalParams}`); }; const handlePageSize = (pageSize: number): void => { const finalParams = `page_number=${currentPageNumber}&page_size=${pageSize}`; setPageSize(pageSize); + pageNumberRef.current = `page_number=${currentPageNumber}&page_size=${pageSize}`; startIncidentSearch(`${searchParamRef.current}${finalParams}`); }; @@ -86,6 +90,7 @@ const Dashboard: FC = () => { pageDetails={pageDetails} handlePageNumberChange={handlePageNumber} handlePageSizeChange={handlePageSize} + fetchIncidentData={fetchIncidentData} /> ); diff --git a/src/Pages/Dashboard/partials/SearchResultsTable.tsx b/src/Pages/Dashboard/partials/SearchResultsTable.tsx index fa75199..3201719 100644 --- a/src/Pages/Dashboard/partials/SearchResultsTable.tsx +++ b/src/Pages/Dashboard/partials/SearchResultsTable.tsx @@ -17,6 +17,7 @@ interface SearchResultTableProps { currentPageSize: number; handlePageNumberChange: (pageNumber: number) => void; handlePageSizeChange: (pageSize: number) => void; + fetchIncidentData: (props: any) => void; } const defaultColDef = { @@ -31,6 +32,7 @@ const SearchResultsTable: FC = ({ currentPageSize, handlePageNumberChange, handlePageSizeChange, + fetchIncidentData, }) => { const { pageNumber, totalElements } = pageDetails; const [drawerState, setDrawerState] = useState(false); @@ -135,6 +137,7 @@ const SearchResultsTable: FC = ({ const handleCloseDrawer = () => { incidentData.current = {}; + fetchIncidentData({}); setDrawerState(false); }; diff --git a/src/Pages/Incidents/DrawerMode/index.tsx b/src/Pages/Incidents/DrawerMode/index.tsx index 363d7f3..f406c87 100644 --- a/src/Pages/Incidents/DrawerMode/index.tsx +++ b/src/Pages/Incidents/DrawerMode/index.tsx @@ -114,14 +114,9 @@ const DrawerMode: FC = ({ incidentId, slackChannel }) => { } }, [headerData, incidentDetails, incidentParticipants]); - const updateIncident = () => { + const updateIncident = payload => { const endPoint = UPDATE_INCIDENT; - ApiService.post(endPoint, { - id: incidentId, - teamId: `${team?.value}`, - status: `${status?.value}`, - severityId: `${severity?.value}`, - }) + ApiService.post(endPoint, payload) .then(response => { toast.success('Incident Updated Successfully'); }) @@ -146,7 +141,14 @@ const DrawerMode: FC = ({ incidentId, slackChannel }) => { options={headerData?.severities} onSelectionChange={val => { setSeverity(val); - updateIncident(); + updateIncident({ + id: incidentId, + teamId: `${team?.value}`, + status: `${status?.value}`, + severityId: !Array.isArray(val) + ? `${val?.value}` + : val?.[0]?.value, + }); }} isSingleSelect filterClass={styles['filter-wrapper']} @@ -159,7 +161,12 @@ const DrawerMode: FC = ({ incidentId, slackChannel }) => { options={headerData?.incidentStatuses} onSelectionChange={val => { setStatus(val); - updateIncident(); + updateIncident({ + id: incidentId, + teamId: `${team?.value}`, + status: !Array.isArray(val) ? `${val?.value}` : val?.[0]?.value, + severityId: `${severity?.value}`, + }); }} isSingleSelect filterClass={styles['filter-wrapper']} @@ -172,7 +179,12 @@ const DrawerMode: FC = ({ incidentId, slackChannel }) => { options={headerData?.teams} onSelectionChange={val => { setTeam(val); - updateIncident(); + updateIncident({ + id: incidentId, + teamId: !Array.isArray(val) ? `${val?.value}` : val?.[0]?.value, + status: `${status?.value}`, + severityId: `${team?.value}`, + }); }} isSingleSelect filterClass={styles['filter-wrapper']}