added loader for logout all session button
This commit is contained in:
parent
fb2f966dfe
commit
680e08cc68
@ -1,3 +1,4 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import { observer, inject } from "mobx-react";
|
import { observer, inject } from "mobx-react";
|
||||||
import { Text } from "@docspace/shared/components/text";
|
import { Text } from "@docspace/shared/components/text";
|
||||||
import { Button } from "@docspace/shared/components/button";
|
import { Button } from "@docspace/shared/components/button";
|
||||||
@ -29,16 +30,20 @@ const AllSessionsBlock = (props) => {
|
|||||||
removeAllActiveSessionsById,
|
removeAllActiveSessionsById,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const isDisabled = connections.length > 0;
|
const isDisabled = connections.length > 0;
|
||||||
|
|
||||||
const onLogoutClick = async () => {
|
const onLogoutClick = async () => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
await removeAllActiveSessionsById(connections[0]?.userId);
|
await removeAllActiveSessionsById(connections[0]?.userId);
|
||||||
fetchData();
|
fetchData();
|
||||||
setConnections([]);
|
setConnections([]);
|
||||||
toastr.success("Successfully logout all sessions");
|
toastr.success("Successfully logout all sessions");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastr.error(error);
|
toastr.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +57,7 @@ const AllSessionsBlock = (props) => {
|
|||||||
size="small"
|
size="small"
|
||||||
onClick={onLogoutClick}
|
onClick={onLogoutClick}
|
||||||
scale={true}
|
scale={true}
|
||||||
isLoading={false}
|
isLoading={isLoading}
|
||||||
isDisabled={!isDisabled}
|
isDisabled={!isDisabled}
|
||||||
/>
|
/>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user