Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 82x 82x 9x 100x 80x 6x 88x 88x 88x 12x 88x 88x 118x 106x 80x 110x 1x 160x 82x 322x 322x 328x | import { useState } from "react";
import { Button } from "@/ahuora-design-system/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/ahuora-design-system/ui/dialog";
import { Input } from "@/ahuora-design-system/ui/input";
import { Label } from "@/ahuora-design-system/ui/label";
export function ProfileNameDialog({
title,
triggerLabel,
name,
busy,
disabled,
onNameChange,
onSubmit,
}: {
title: string;
triggerLabel: string;
name: string;
busy: boolean;
disabled: boolean;
onNameChange: (name: string) => void;
onSubmit: () => Promise<void>;
}) {
const [open, setOpen] = useState(false);
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button type="button" variant="outline" disabled={disabled}>
{triggerLabel}
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
<div className="space-y-1.5">
<Label htmlFor={`${triggerLabel.toLowerCase()}-profile-name`}>
Name
</Label>
<Input
id={`${triggerLabel.toLowerCase()}-profile-name`}
value={name}
onChange={(event) => onNameChange(event.target.value)}
/>
</div>
<DialogFooter>
<Button
type="button"
disabled={!name.trim() || busy}
onClick={() => {
void onSubmit().then(() => setOpen(false));
}}
>
{busy ? "Saving" : triggerLabel}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
|