import React, { useState } from 'react';

const AddUserForm = ({ onAdd }) => {
    const [id, setId] = useState('');
    const [name, setName] = useState('');

    const handleSubmit = (e) => {
        e.preventDefault();
        if (id && name) {
            onAdd(id, name);
            setId('');
            setName('');
        }
    };

    return (
        <form onSubmit={handleSubmit} className="add-user-form">
            <div>
                <label>ID:</label>
                <input
                    type="text"
                    value={id}
                    onChange={(e) => setId(e.target.value)}
                />
            </div>
            <div>
                <label>Name:</label>
                <input
                    type="text"
                    value={name}
                    onChange={(e) => setName(e.target.value)}
                />
            </div>
            <button type="submit">Add User</button>
        </form>
    );
};

export default AddUserForm;
