-- Biometric Device Registration Form
-- Maps to biometric_devices table for device pre-registration
-- Type IDs: 1=text, 2=number, 3=date, 4=select, 5=checkbox, 8=textarea, 9=file

INSERT INTO forms (
    id,
    name,
    description,
    mapped_table,
    category_id,
    layout_type,
    columns,
    elements
) VALUES (
    631,
    'Biometric Device Registration',
    'Register new biometric attendance devices for WebSocket connection',
    'biometric_devices',
    NULL, -- No specific category
    'grid',
    1,
    '[
        {
            "label": "Device Serial Number",
            "type_id": 1,
            "required": true,
            "field_name": "device_sn",
            "placeholder": "Enter the device serial number (e.g., F500-12345)",
            "validation": {
                "pattern": "^[A-Z0-9-]+$",
                "message": "Serial number must contain only uppercase letters, numbers, and hyphens"
            }
        },
        {
            "label": "Device Name",
            "type_id": 1,
            "required": true,
            "field_name": "name",
            "placeholder": "Enter a friendly name (e.g., Main Entrance Scanner)",
            "maxlength": 100
        },
        {
            "label": "Device Type",
            "type_id": 4,
            "required": true,
            "field_name": "device_type",
            "options": [
                {
                    "label": "F500 - Facial Recognition Terminal",
                    "value": "F500"
                },
                {
                    "label": "M50 - Fingerprint Reader",
                    "value": "M50"
                },
                {
                    "label": "M91 - Multi-Modal Device",
                    "value": "M91"
                }
            ],
            "default_value": "F500"
        },
        {
            "label": "Branch/Location",
            "type_id": 4,
            "required": true,
            "field_name": "branch_id",
            "options_table": "branches",
            "options_label_column": "name",
            "options_value_column": "branch_id",
            "options_where": "isDeleted = false",
            "placeholder": "Select the branch where this device will be installed"
        },
        {
            "label": "Description/Location Details",
            "type_id": 8,
            "required": false,
            "field_name": "description",
            "placeholder": "Enter additional details about device location or purpose",
            "rows": 3
        },
        {
            "label": "Approved for Connection",
            "type_id": 5,
            "required": false,
            "field_name": "approved",
            "default_value": true,
            "help_text": "Only approved devices can connect via WebSocket"
        }
    ]'::jsonb
)
ON CONFLICT DO NOTHING;
