mirror of
https://github.com/meshtastic/web.git
synced 2026-04-23 23:38:04 -04:00
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { useAppStore } from "../../core/stores/appStore.ts";
|
|
import { useDevice } from "@core/stores/deviceStore.ts";
|
|
import { Button } from "@components/UI/Button.tsx";
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@components/UI/Dialog.tsx";
|
|
import { Label } from "@components/UI/Label.tsx";
|
|
|
|
export interface RemoveNodeDialogProps {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
}
|
|
|
|
export const RemoveNodeDialog = ({
|
|
open,
|
|
onOpenChange,
|
|
}: RemoveNodeDialogProps) => {
|
|
const { connection, nodes, removeNode } = useDevice();
|
|
const { nodeNumToBeRemoved } = useAppStore();
|
|
|
|
const onSubmit = () => {
|
|
connection?.removeNodeByNum(nodeNumToBeRemoved);
|
|
removeNode(nodeNumToBeRemoved);
|
|
onOpenChange(false);
|
|
};
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent>
|
|
<DialogClose />
|
|
<DialogHeader>
|
|
<DialogTitle>Remove Node?</DialogTitle>
|
|
<DialogDescription>
|
|
Are you sure you want to remove this Node?
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="gap-4">
|
|
<form onSubmit={onSubmit}>
|
|
<Label>{nodes.get(nodeNumToBeRemoved)?.user?.longName}</Label>
|
|
</form>
|
|
</div>
|
|
<DialogFooter>
|
|
<Button variant="destructive" onClick={() => onSubmit()}>
|
|
Remove
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|