Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

RemoveT3ConnectEnvironmentDialog.tsx

71 lines2.2 KB

1import { useState } from "react";
2​
3import {
4 AlertDialog,
5 AlertDialogClose,
6 AlertDialogDescription,
7 AlertDialogFooter,
8 AlertDialogHeader,
9 AlertDialogPopup,
10 AlertDialogTitle,
11} from "../ui/alert-dialog";
12import { Button, InlineButton } from "../ui/button";
13import { useT3ConnectAccountPage } from "./T3ConnectAccountPages";
14​
15export function RemoveT3ConnectEnvironmentDialog({
16 environmentLabel,
17 onCancel,
18 onConfirm,
19}: {
20 readonly environmentLabel: string | null;
21 readonly onCancel: () => void;
22 readonly onConfirm: () => void;
23}) {
24 const accountPage = useT3ConnectAccountPage();
25 const [shownLabel, setShownLabel] = useState(environmentLabel);
26 if (environmentLabel !== null && environmentLabel !== shownLabel) setShownLabel(environmentLabel);
27 const openAccountPage = accountPage.open;
28​
29 return (
30 <>
31 <AlertDialog
32 open={environmentLabel !== null}
33 onOpenChange={(open) => {
34 if (!open) onCancel();
35 }}
36 >
37 <AlertDialogPopup>
38 <AlertDialogHeader>
39 <AlertDialogTitle>Remove {shownLabel} from this device?</AlertDialogTitle>
40 <AlertDialogDescription>
41 This forgets its pairing, credentials, and cached threads here.
42 </AlertDialogDescription>
43 <AlertDialogDescription>
44 It stays on your T3 Connect account and keeps its host space. Deregister it in{" "}
45 {openAccountPage ? (
46 <InlineButton
47 onClick={() => {
48 onCancel();
49 openAccountPage();
50 }}
51 >
52 T3 Connect settings
53 </InlineButton>
54 ) : (
55 "T3 Connect settings"
56 )}{" "}
57 to free it.
58 </AlertDialogDescription>
59 </AlertDialogHeader>
60 <AlertDialogFooter>
61 <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
62 <Button variant="destructive" onClick={onConfirm}>
63 Remove from this device
64 </Button>
65 </AlertDialogFooter>
66 </AlertDialogPopup>
67 </AlertDialog>
68 {accountPage.portals}
69 </>
70 );