refactor: alert close button

This commit is contained in:
Aman Harwara
2023-01-17 00:33:20 +05:30
parent 029c74cc1f
commit 11dde8d03d
5 changed files with 81 additions and 49 deletions

View File

@@ -4,6 +4,7 @@ import { WebApplication } from '@/Application/Application'
import { ViewControllerManager } from '@/Controllers/ViewControllerManager'
import { observer } from 'mobx-react-lite'
import Button from '@/Components/Button/Button'
import Icon from '../Icon/Icon'
type Props = {
application: WebApplication
@@ -17,6 +18,14 @@ const ConfirmOtherSessionsSignOut = observer(({ application, viewControllerManag
viewControllerManager.accountMenuController.setOtherSessionsSignOut(false)
}, [viewControllerManager])
const confirm = useCallback(() => {
application.revokeAllOtherSessions().catch(console.error)
closeDialog()
application.alertService
.alert('You have successfully revoked your sessions from other devices.', undefined, 'Finish')
.catch(console.error)
}, [application, closeDialog])
return (
<AlertDialog onDismiss={closeDialog} leastDestructiveRef={cancelRef} className="max-w-[600px] p-0">
<div className="sk-modal-content">
@@ -24,7 +33,12 @@ const ConfirmOtherSessionsSignOut = observer(({ application, viewControllerManag
<div className="sk-panel">
<div className="sk-panel-content">
<div className="sk-panel-section">
<AlertDialogLabel className="text-lg font-bold capitalize">End all other sessions?</AlertDialogLabel>
<AlertDialogLabel className="flex items-center justify-between text-lg font-bold capitalize">
End all other sessions?
<button className="rounded p-1 font-bold hover:bg-contrast" onClick={closeDialog}>
<Icon type="close" />
</button>
</AlertDialogLabel>
<AlertDialogDescription className="sk-panel-row">
<p className="text-base text-foreground lg:text-sm">
This action will sign out all other devices signed into your account, and remove your data from
@@ -36,17 +50,7 @@ const ConfirmOtherSessionsSignOut = observer(({ application, viewControllerManag
<Button ref={cancelRef} onClick={closeDialog}>
Cancel
</Button>
<Button
primary
colorStyle="danger"
onClick={() => {
application.revokeAllOtherSessions().catch(console.error)
closeDialog()
application.alertService
.alert('You have successfully revoked your sessions from other devices.', undefined, 'Finish')
.catch(console.error)
}}
>
<Button primary colorStyle="danger" onClick={confirm}>
End Sessions
</Button>
</div>