Files
OmniRoute/bin/cli/tui-components/ConfirmDialog.jsx
diegosouzapw 59128b6742 feat(cli): TUI dashboard interativo e menu de interface (Fases 8.10+8.9)
Adiciona dashboard TUI com 7 abas (Overview, Combos, Providers, Keys, Logs, Health, Cost)
via Ink, 13 componentes reutilizáveis em tui-components/, menu interativo ao iniciar sem
subcomando, e flag --tui no comando dashboard.
2026-05-15 04:36:21 -03:00

41 lines
1.1 KiB
JavaScript

import React, { useState } from "react";
import { Box, Text, useInput } from "ink";
export function ConfirmDialog({ message, onConfirm, onCancel }) {
const [selected, setSelected] = useState(1); // 0=yes, 1=no (default no)
useInput((input, key) => {
if (key.leftArrow || input === "y") setSelected(0);
if (key.rightArrow || input === "n") setSelected(1);
if (key.return) {
if (selected === 0) onConfirm?.();
else onCancel?.();
}
if (key.escape) onCancel?.();
});
return (
<Box flexDirection="column" borderStyle="round" borderColor="yellow" padding={1}>
<Text bold color="yellow">
{message}
</Text>
<Box marginTop={1} gap={2}>
<Text
bold={selected === 0}
color={selected === 0 ? "green" : undefined}
inverse={selected === 0}
>
Yes
</Text>
<Text
bold={selected === 1}
color={selected === 1 ? "red" : undefined}
inverse={selected === 1}
>
No
</Text>
</Box>
</Box>
);
}