From 8b8510248283a692291fcfd3026854814bcdfb4b Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Tue, 28 Jan 2025 09:46:54 +0530 Subject: [PATCH] add logout dialog --- src/app/components/LogoutDialog.tsx | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/app/components/LogoutDialog.tsx diff --git a/src/app/components/LogoutDialog.tsx b/src/app/components/LogoutDialog.tsx new file mode 100644 index 00000000..d52e4647 --- /dev/null +++ b/src/app/components/LogoutDialog.tsx @@ -0,0 +1,60 @@ +import React, { forwardRef, useCallback } from 'react'; +import { Dialog, Header, config, Box, Text, Button, Spinner, color } from 'folds'; +import { AsyncStatus, useAsyncCallback } from '../hooks/useAsyncCallback'; +import { logoutClient } from '../../client/initMatrix'; +import { useMatrixClient } from '../hooks/useMatrixClient'; + +type LogoutDialogProps = { + handleClose: () => void; +}; +export const LogoutDialog = forwardRef( + ({ handleClose }, ref) => { + const mx = useMatrixClient(); + + const [logoutState, logout] = useAsyncCallback( + useCallback(async () => { + await logoutClient(mx); + }, [mx]) + ); + + const ongoingLogout = logoutState.status === AsyncStatus.Loading; + + return ( + +
+ + Logout + +
+ + You’re about to log out. Are you sure? + {logoutState.status === AsyncStatus.Error && ( + + Failed to logout! {logoutState.error.message} + + )} + + + + + +
+ ); + } +);