From 164440b9172cb8f24a1bbb9a41e0b3ce3bcb12bc Mon Sep 17 00:00:00 2001 From: pooja-jaiswal_navi Date: Tue, 16 Jan 2024 15:02:35 +0530 Subject: [PATCH] TP-51166 | update details api call pushed to useteams api --- .../partials/SlackDetails/index.tsx | 59 ++++--------------- .../TeamMemberDetails.module.scss | 3 - src/Pages/TeamRevamp/useTeamApis.tsx | 41 ++++++++++++- 3 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/Pages/TeamRevamp/partials/SlackDetails/index.tsx b/src/Pages/TeamRevamp/partials/SlackDetails/index.tsx index a466847..36c85ed 100644 --- a/src/Pages/TeamRevamp/partials/SlackDetails/index.tsx +++ b/src/Pages/TeamRevamp/partials/SlackDetails/index.tsx @@ -1,11 +1,4 @@ -import { useDispatch, useSelector } from 'react-redux'; -import { - useEffect, - useState, - useRef, - MutableRefObject, - useReducer, -} from 'react'; +import { useEffect, useRef, MutableRefObject, useReducer } from 'react'; import { BorderedInput, Button, @@ -13,17 +6,13 @@ import { Typography, } from '@navi/web-ui/lib/primitives'; import { SelectPicker } from '@navi/web-ui/lib/components'; -import { toast } from '@navi/web-ui/lib/primitives/Toast'; import { AlertOutlineIcon } from '@navi/web-ui/lib/icons'; -import { fetchTeamDetails } from '@src/slices/team1Slice'; -import { AppDispatch } from '@src/store'; import useOutsideClick from '@src/services/hooks/useOustideClick'; import { useAuthData } from '@src/services/hooks/useAuth'; -import { ApiService } from '@src/services/api'; +import useTeamApis from '../../useTeamApis'; import { TeamsDetail, - UPDATE_TEAM_DATA, actionTypes, initialState, reducer, @@ -33,11 +22,10 @@ import useGetTeamDetailsConstants from '../../util'; import styles from './Slack.module.scss'; const TeamDetails: React.FC = () => { - const dispatch = useDispatch(); const [state, dispatchData] = useReducer(reducer, initialState); const Role = useAuthData(); + const { updateDetails } = useTeamApis(); const { - teamId, userEmail, managerEmail, teamDetails, @@ -74,7 +62,7 @@ const TeamDetails: React.FC = () => { type: actionTypes.SET_ONCALL, payload: { label: event.label, - value: event.value.toString(), + value: event.value, }, }); dispatchData({ @@ -91,7 +79,7 @@ const TeamDetails: React.FC = () => { type: actionTypes.SET_PSEC_ONCALL, payload: { label: event.label, - value: event.value.toString(), + value: event.value, }, }); dispatchData({ @@ -151,35 +139,6 @@ const TeamDetails: React.FC = () => { payload: e.target.value, }); }; - const updateDetails = (): void => { - const endPoint = UPDATE_TEAM_DATA(); - ApiService.post(endPoint, { - id: teamId, - webhook_slack_channel: state.slackChannelId, - on_call_handle: state.oncall.value, - pse_on_call_id: state.psecOncall.value, - }) - .then(response => { - toast.success(response?.data?.data); - dispatch(fetchTeamDetails(teamId?.toString() || '')); - dispatchData({ - type: actionTypes.SET_OPEN_ONCALL, - payload: false, - }); - dispatchData({ - type: actionTypes.SET_PSEC_OPEN_ONCALL, - payload: false, - }); - }) - .catch(error => { - const toastMessage = `${ - error?.response?.data?.error?.message - ? `${error?.response?.data?.error?.message}` - : 'Something went wrong,Pls try again later' - }`; - toast.error(toastMessage); - }); - }; const isUserParticipant = (teamDetails: TeamsDetail): boolean | undefined => { const participantEmails = teamDetails?.participants?.map( @@ -293,7 +252,13 @@ const TeamDetails: React.FC = () => { >