@@ -6,6 +6,7 @@ import {useDispatch} from 'react-redux'
66import {
77 getOperatorOrgsLimits ,
88 getOperatorOrg ,
9+ postOperatorOrgsReactivate ,
910 putOperatorOrgsLimits ,
1011} from 'src/client/unityRoutes'
1112import { notify } from 'src/shared/actions/notifications'
@@ -14,6 +15,8 @@ import {
1415 getLimitsError ,
1516 updateLimitsError ,
1617 updateLimitsSuccess ,
18+ reactivateOrgError ,
19+ reactivateOrgSuccess ,
1720} from 'src/shared/copy/notifications'
1821import { toDisplayLimits } from 'src/operator/utils'
1922
@@ -30,21 +33,25 @@ export interface OverlayContextType {
3033 limitsStatus : RemoteDataState
3134 handleGetLimits : ( id : string ) => void
3235 handleGetOrg : ( id : string ) => void
36+ handleReactivateOrg : ( id : string ) => void
3337 handleUpdateLimits : ( id : string , limits : OperatorOrgLimits ) => void
3438 organization : OperatorOrg
3539 orgStatus : RemoteDataState
40+ reactivateOrgStatus : RemoteDataState
3641 setLimits : ( _ : OperatorOrgLimits ) => void
3742 updateLimitStatus : RemoteDataState
3843}
3944
4045export const DEFAULT_CONTEXT : OverlayContextType = {
4146 handleGetLimits : ( _ : string ) => { } ,
4247 handleGetOrg : ( _ : string ) => { } ,
48+ handleReactivateOrg : ( _id : string ) => { } ,
4349 handleUpdateLimits : ( _id : string , _limits : OperatorOrgLimits ) => { } ,
4450 limits : null ,
4551 limitsStatus : RemoteDataState . NotStarted ,
4652 organization : null ,
4753 orgStatus : RemoteDataState . NotStarted ,
54+ reactivateOrgStatus : RemoteDataState . NotStarted ,
4855 setLimits : ( _ : OperatorOrgLimits ) => { } ,
4956 updateLimitStatus : RemoteDataState . NotStarted ,
5057}
@@ -55,6 +62,9 @@ export const OverlayContext =
5562export const OverlayProvider : FC < Props > = React . memo ( ( { children} ) => {
5663 const [ limits , setLimits ] = useState ( null )
5764 const [ limitsStatus , setLimitsStatus ] = useState ( RemoteDataState . NotStarted )
65+ const [ reactivateOrgStatus , setReactivateOrgStatus ] = useState (
66+ RemoteDataState . NotStarted
67+ )
5868 const [ updateLimitStatus , setUpdateLimitStatus ] = useState (
5969 RemoteDataState . NotStarted
6070 )
@@ -109,6 +119,21 @@ export const OverlayProvider: FC<Props> = React.memo(({children}) => {
109119 [ dispatch ]
110120 )
111121
122+ const handleReactivateOrg = useCallback (
123+ async ( id : string ) => {
124+ try {
125+ setReactivateOrgStatus ( RemoteDataState . Loading )
126+ await postOperatorOrgsReactivate ( { orgId : id } )
127+ setReactivateOrgStatus ( RemoteDataState . Done )
128+ dispatch ( notify ( reactivateOrgSuccess ( id ) ) )
129+ } catch ( error ) {
130+ console . error ( error )
131+ dispatch ( notify ( reactivateOrgError ( id ) ) )
132+ }
133+ } ,
134+ [ dispatch ]
135+ )
136+
112137 const handleUpdateLimits = useCallback (
113138 async ( id : string , updatedLimits : OperatorOrgLimits ) => {
114139 try {
@@ -129,11 +154,13 @@ export const OverlayProvider: FC<Props> = React.memo(({children}) => {
129154 value = { {
130155 handleGetLimits,
131156 handleGetOrg,
157+ handleReactivateOrg,
132158 handleUpdateLimits,
133159 limits,
134160 limitsStatus,
135161 organization,
136162 orgStatus,
163+ reactivateOrgStatus,
137164 setLimits,
138165 updateLimitStatus,
139166 } }
0 commit comments