BEGIN;

-- Align the Employee Management module with the users table while preserving array field views
UPDATE modules
SET config = $module$ {
      "title": "Employee Management",
      "header": [
        {
          "type": "filter-select",
          "options": {
            "source_table": "users",
            "source_column": "user_id",
            "display_column": "full_name",
            "data_column": "full_name",
            "data_column_id": "selected_user_id",
            "placeholder": "Search employees by name...",
            "search_fields": ["full_name"],
            "max_results": 25,
            "debounce_ms": 250,
            "populateMode": "immediate"
          }
        },
        { "type": "button", "label": "Add Employee", "formName": "Employee Account" }
      ],
      "body": [
        {
          "type": "table",
          "options": {
            "tableName": "users",
            "showGlobalSearch": false,
            "addButton": false,
            "filterField": "full_name",
            "listenColumn": "full_name",
            "columnsToShow": ["full_name", "status", "user_emails", "phones"],
            "arrayFieldViews": {
              "user_emails": ["email"],
              "phones": ["phone_number"]
            },
            "columnLabels": {
              "user_emails": "Emails",
              "phones": "Phones"
            }
          }
        }
      ],
      "footer": [
        { "type": "button", "label": "Close", "onClick": "closeModal" }
      ]
    } $module$::jsonb,
    name = 'Employees',
    icon = 'fa-users',
    aria_label = 'Employees',
    description = 'Manage employees, rates, and types'
WHERE module_id = '0194a8b2-7777-7123-8123-123456789ac6'::uuid;

COMMIT;
