'use client'; import { useState, useEffect } from 'react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { Copy, X } from 'lucide-react'; import { useRegisterModal } from './modal/ModalStackProvider'; interface CloneCountInputModalProps { isOpen: boolean; onClose: () => void; onSubmit: (count: number) => void; storageName: string; } export function CloneCountInputModal({ isOpen, onClose, onSubmit, storageName }: CloneCountInputModalProps) { const [cloneCount, setCloneCount] = useState(1); useRegisterModal(isOpen, { id: 'clone-count-input-modal', allowEscape: true, onClose }); useEffect(() => { if (isOpen) { setCloneCount(1); // Reset to default when modal opens } }, [isOpen]); if (!isOpen) return null; const handleSubmit = () => { if (cloneCount >= 1) { onSubmit(cloneCount); setCloneCount(1); // Reset after submit } }; const handleClose = () => { setCloneCount(1); // Reset on close onClose(); }; return (
{/* Header */}

Clone Count

{/* Content */}

How many clones would you like to create?

{storageName && (

Storage:

{storageName}

)}
{ const value = parseInt(e.target.value, 10); if (!isNaN(value) && value >= 1 && value <= 100) { setCloneCount(value); } else if (e.target.value === '') { setCloneCount(1); } }} className="w-full" placeholder="1" />

Enter a number between 1 and 100

{/* Action Buttons */}
); }