All files / src/ahuora-design-system/ui rename-dialog.tsx

40% Statements 2/5
100% Branches 0/0
25% Functions 1/4
40% Lines 2/5

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                                                  216x   216x                                                                                
import { Dispatch, SetStateAction, useState } from "react";
import { Button } from "@/ahuora-design-system/ui/button";
import {
  Dialog,
  DialogContent,
  DialogHeader,
  DialogTitle,
} from "@/ahuora-design-system/ui/dialog";
import { Input } from "@/ahuora-design-system/ui/input";
 
interface RenameDialogProps {
  projectName: string;
  isOpen: boolean;
  onOpenChange: Dispatch<SetStateAction<boolean>>;
  onRename: (string) => void;
  onCancel: () => void;
}
 
export default function RenameDialog({
  projectName,
  isOpen,
  onOpenChange,
  onRename,
  onCancel,
}: RenameDialogProps) {
  const [newProjectName, setNewProjectName] = useState("");
 
  return (
    <Dialog open={isOpen} onOpenChange={onOpenChange}>
      <DialogContent
        className="w-1/4 gap-8"
        onClick={(e) => e.stopPropagation()}
      >
        <DialogHeader>
          <DialogTitle>Rename Project</DialogTitle>
        </DialogHeader>
        <div className="flex flex-col gap-2">
          <p className="font-light">New Project Name</p>
          <Input
            id="new-project-name"
            placeholder={projectName}
            className="flex rounded-md border h-9"
            onChange={(e) => setNewProjectName(e.target.value)}
            value={newProjectName}
            aria-label="Rename Project Name Input"
          />
        </div>
        <div className="flex flex-row justify-end gap-2">
          <Button
            variant="outline"
            onClick={onCancel}
            aria-label="Cancel Rename Project Button"
          >
            Cancel
          </Button>
          <Button
            variant="default"
            onClick={() => onRename(newProjectName)}
            aria-label="Rename Project Button"
          >
            Rename
          </Button>
        </div>
      </DialogContent>
    </Dialog>
  );
}