Fix broken validation

This commit is contained in:
Delta6626 2026-05-02 02:05:00 +04:00
parent 6ec818fc11
commit 89677d9cc9
1 changed files with 10 additions and 3 deletions

View File

@ -10,6 +10,9 @@ import {
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { useState } from "react";
const REQUIRED_CONFIRMATION_TEXT = "DELETE";
export function DeleteProjectDialog({ export function DeleteProjectDialog({
isOpen, isOpen,
@ -25,6 +28,8 @@ export function DeleteProjectDialog({
const count = projectNames.length; const count = projectNames.length;
const isSingle = count === 1; const isSingle = count === 1;
const singleName = isSingle ? projectNames[0] : null; const singleName = isSingle ? projectNames[0] : null;
const [confirmationInput, setConfirmationInput] = useState<string>("");
return ( return (
<Dialog open={isOpen} onOpenChange={onOpenChange}> <Dialog open={isOpen} onOpenChange={onOpenChange}>
@ -60,11 +65,13 @@ export function DeleteProjectDialog({
</Alert> </Alert>
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-3">
<Label className="text-xs font-semibold text-slate-500"> <Label className="text-xs font-semibold text-slate-500">
Type "DELETE" to confirm {`Type "${REQUIRED_CONFIRMATION_TEXT}" to confirm`}
</Label> </Label>
<Input <Input
onChange={(e) => {setConfirmationInput(e.target.value)}}
value={confirmationInput}
type="text" type="text"
placeholder="DELETE" placeholder={REQUIRED_CONFIRMATION_TEXT}
size="lg" size="lg"
variant="destructive" variant="destructive"
/> />
@ -74,7 +81,7 @@ export function DeleteProjectDialog({
<Button variant="outline" onClick={() => onOpenChange(false)}> <Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel Cancel
</Button> </Button>
<Button variant="destructive" onClick={onConfirm}> <Button variant="destructive" onClick={onConfirm} disabled={confirmationInput != REQUIRED_CONFIRMATION_TEXT}>
Delete project Delete project
</Button> </Button>
</DialogFooter> </DialogFooter>