From b92a3c99d8b18e75746c0bc8ad012141eaacf6d1 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 20 Dec 2023 14:22:49 +0530 Subject: [PATCH 1/2] fix: Signout API removed. --- src/screens/HyperSwitch/APIUtils/APIUtils.res | 6 +++--- src/screens/HyperSwitch/Sidebar/Sidebar.res | 21 ++----------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res index 24960abf1..d19ec7ab4 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtils.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res @@ -234,7 +234,7 @@ let getURL = ( let sessionExpired = ref(false) let handleLogout = async ( - ~fetchApi: ( + ~fetchApi as _: ( Js.String2.t, ~bodyStr: string=?, ~headers: Js.Dict.t=?, @@ -249,8 +249,8 @@ let handleLogout = async ( ) => Promise.t, ~setAuthStatus, ) => { - let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ()) - let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ()) + // let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ()) + // let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ()) setAuthStatus(HyperSwitchAuthTypes.LoggedOut) LocalStorage.clear() RescriptReactRouter.push("/register") diff --git a/src/screens/HyperSwitch/Sidebar/Sidebar.res b/src/screens/HyperSwitch/Sidebar/Sidebar.res index 14f392d0c..7a8f4ee85 100644 --- a/src/screens/HyperSwitch/Sidebar/Sidebar.res +++ b/src/screens/HyperSwitch/Sidebar/Sidebar.res @@ -524,25 +524,8 @@ let make = ( let transformClass = "transform md:translate-x-0 transition" - let handleLogout = _ev => { - open Promise - fetchApi( - APIUtils.getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ()), - ~bodyStr=Js.Json.stringify(Js.Json.object_(Js.Dict.empty())), - ~method_=Fetch.Post, - (), - ) - ->then(Fetch.Response.text) - ->then(_ => { - setIsSidebarExpanded(_ => false) - LocalStorage.clear() - setAuthStatus(LoggedOut) - resolve() - }) - ->catch(_err => { - resolve() - }) - ->ignore + let handleLogout = _ => { + let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus) }
From 194a99eeb08dfd82c63d7930573ef61ea5ae0a80 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 20 Dec 2023 14:29:49 +0530 Subject: [PATCH 2/2] fix: setIsSidebarExpanded set to false --- src/screens/HyperSwitch/APIUtils/APIUtils.res | 8 ++++++-- src/screens/HyperSwitch/Home/HomeUtils.res | 3 ++- src/screens/HyperSwitch/Sidebar/Sidebar.res | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res index d19ec7ab4..b66e3f52d 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtils.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res @@ -248,10 +248,12 @@ let handleLogout = async ( unit, ) => Promise.t, ~setAuthStatus, + ~setIsSidebarExpanded, ) => { // let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ()) // let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ()) setAuthStatus(HyperSwitchAuthTypes.LoggedOut) + setIsSidebarExpanded(_ => false) LocalStorage.clear() RescriptReactRouter.push("/register") } @@ -376,6 +378,7 @@ let useGetMethod = (~showErrorToast=true, ()) => { let showToast = ToastState.useShowToast() let showPopUp = PopUpState.useShowPopUp() let (_authStatus, setAuthStatus) = React.useContext(AuthInfoProvider.authStatusContext) + let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext) let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage() let url = RescriptReactRouter.useUrl() let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_") @@ -393,7 +396,7 @@ let useGetMethod = (~showErrorToast=true, ()) => { _ => { hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ()) hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ()) - let _ = handleLogout(~fetchApi, ~setAuthStatus) + let _ = handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded) } }, }, @@ -440,6 +443,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage() let url = RescriptReactRouter.useUrl() let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_") + let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext) let popUpCallBack = () => showPopUp({ @@ -454,7 +458,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { _ => { hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ()) hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ()) - let _ = handleLogout(~fetchApi, ~setAuthStatus) + let _ = handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded) } }, }, diff --git a/src/screens/HyperSwitch/Home/HomeUtils.res b/src/screens/HyperSwitch/Home/HomeUtils.res index cf816991c..7eda29b8c 100644 --- a/src/screens/HyperSwitch/Home/HomeUtils.res +++ b/src/screens/HyperSwitch/Home/HomeUtils.res @@ -169,6 +169,7 @@ module CheckoutCard = { let showPopUp = PopUpState.useShowPopUp() let hyperswitchMixPanel = HSMixPanel.useSendEvent() let (_authStatus, setAuthStatus) = React.useContext(AuthInfoProvider.authStatusContext) + let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext) let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage() let isConfigureConnector = ListHooks.useListCount(~entityName=CONNECTOR) > 0 let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_") @@ -187,7 +188,7 @@ module CheckoutCard = { _ => { hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ()) hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ()) - let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus) + let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded) } }, }, diff --git a/src/screens/HyperSwitch/Sidebar/Sidebar.res b/src/screens/HyperSwitch/Sidebar/Sidebar.res index 7a8f4ee85..6767f8d19 100644 --- a/src/screens/HyperSwitch/Sidebar/Sidebar.res +++ b/src/screens/HyperSwitch/Sidebar/Sidebar.res @@ -525,7 +525,7 @@ let make = ( let transformClass = "transform md:translate-x-0 transition" let handleLogout = _ => { - let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus) + let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded) }