The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 59 lines 1.7 KB
Raw
1 import { T, useGT } from "gt-react";
2 import { CircleCheckIcon } from "lucide-react";
3 import type { ComponentProps, ReactNode } from "react";
4 import { Button } from "../ui/button";
5
6 export interface PermissionItem {
7 id: string;
8 icon: ReactNode;
9 title: string;
10 description: string;
11 granted: boolean;
12 onAllow: () => void;
13 }
14
15 export function PermissionChecklist({
16 permissions,
17 busy = false,
18 }: {
19 permissions: readonly PermissionItem[];
20 busy?: boolean;
21 }) {
22 return (
23 <div className="space-y-2">
24 {permissions.map((permission) => (
25 <div key={permission.id} className="flex items-center gap-3 rounded-lg border px-3 py-2">
26 {permission.icon}
27 <div className="min-w-0 flex-1">
28 <p className="font-medium">{permission.title}</p>
29 <p className="text-xs text-muted-foreground">{permission.description}</p>
30 </div>
31 {permission.granted ? (
32 <span role="status" className="flex items-center gap-1 text-xs text-success">
33 <CircleCheckIcon className="size-4" aria-hidden="true" />
34 <T context="permission status">Allowed</T>
35 </span>
36 ) : (
37 <Button size="xs" variant="outline" disabled={busy} onClick={permission.onAllow}>
38 <T context="verb, grant a permission">Allow</T>
39 </Button>
40 )}
41 </div>
42 ))}
43 </div>
44 );
45 }
46
47 export function PermissionContinueButton({
48 ready,
49 busy = false,
50 children,
51 ...props
52 }: Omit<ComponentProps<typeof Button>, "disabled"> & { ready: boolean; busy?: boolean }) {
53 const gt = useGT();
54 return (
55 <Button {...props} disabled={!ready || busy}>
56 {children ?? gt("Continue")}
57 </Button>
58 );
59 }