import React, { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Monitor, MapPin, Lock } from 'lucide-react'; import Numpad from './Numpad.tsx'; interface AddTerminalModalProps { isOpen: boolean; onClose: () => void; onSuccess: () => void; } const AddTerminalModal: React.FC = ({ isOpen, onClose, onSuccess }) => { const [name, setName] = useState(''); const [location, setLocation] = useState(''); const [pin, setPin] = useState(''); const [step, setStep] = useState(1); // 1: Details, 2: PIN const [loading, setLoading] = useState(false); const handleSubmit = async () => { setLoading(true); try { const response = await fetch('/api/terminals', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, location, pin }), }); if (response.ok) { onSuccess(); reset(); onClose(); } } catch (error) { console.error('Failed to create terminal:', error); } finally { setLoading(false); } }; const reset = () => { setName(''); setLocation(''); setPin(''); setStep(1); }; if (!isOpen) return null; return (

Register New Terminal

{step === 1 ? (
setName(e.target.value)} placeholder="e.g. Counter 1" className="w-full h-12 px-4 bg-gray-50 border border-gray-200 rounded-xl focus:ring-2 focus:ring-[#231651]/20 focus:border-[#231651] outline-none transition-all" />
setLocation(e.target.value)} placeholder="e.g. Main Entrance" className="w-full h-12 px-4 bg-gray-50 border border-gray-200 rounded-xl focus:ring-2 focus:ring-[#231651]/20 focus:border-[#231651] outline-none transition-all" />
) : (

Create Security PIN

This PIN is required to access the API Key

)}
); }; export default AddTerminalModal;