Files
meshtastic-web/src/components/Dialog/ShutdownDialog.tsx
T
Dan DitomasoandGitHub eb2a2717b1 Internationalization (i18n) (#627)
* `feat: added internationalization lib, added english labels`
* `fixes from code review`
* `feat: add crowdin github actions`
* `fix: added support for i18n in testing. Fixed broken tests`
* `fix: missing translations`
* `removed unneded import`
* `more components updated with missing translations`
* `fixed lint issue`
* `Refactor: updated how translations are scoped, updated all references`
* `fixing broken tests`
* `feat: added language switcher, updated some translations`
* `fixed linting issues`
* `reverting vite config`
* `add english group id's to command palette`
* `updated PR template for i18n`
2025-05-27 08:33:43 -04:00

73 lines
1.9 KiB
TypeScript

import { Button } from "@components/UI/Button.tsx";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@components/UI/Dialog.tsx";
import { Input } from "@components/UI/Input.tsx";
import { useDevice } from "@core/stores/deviceStore.ts";
import { ClockIcon, PowerIcon } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useState } from "react";
export interface ShutdownDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
export const ShutdownDialog = ({
open,
onOpenChange,
}: ShutdownDialogProps) => {
const { t } = useTranslation("dialog");
const { connection } = useDevice();
const [time, setTime] = useState<number>(5);
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogClose />
<DialogHeader>
<DialogTitle>
{t("shutdown.title")}
</DialogTitle>
<DialogDescription>
{t("shutdown.description")}
</DialogDescription>
</DialogHeader>
<div className="flex gap-2 p-4">
<Input
type="number"
value={time}
onChange={(e) => setTime(Number.parseInt(e.target.value))}
suffix={t("unit.minute.plural")}
/>
<Button
className="w-24"
onClick={() => {
connection?.shutdown(time * 60).then(() => onOpenChange(false));
}}
>
<ClockIcon size={16} />
</Button>
<Button
className="w-24"
name="now"
onClick={() => {
connection?.shutdown(2).then(() => () => onOpenChange(false));
}}
>
<PowerIcon className="mr-2" size={16} />
{t("button.now")}
</Button>
</div>
</DialogContent>
</Dialog>
);
};