-- Migration: Add filter-select-search to Clients module
-- Date: 2025-10-01

UPDATE modules
SET config = '{
  "title": "Clients",
  "header": [
    {
      "type": "filter-select",
      "options": {
        "source_table": "clients",
        "source_column": "client_id",
        "display_column": "name",
        "data_column": "name",
        "data_column_id": "selected_client_id",
        "placeholder": "Search clients by name...",
        "search_fields": ["name"],
        "max_results": 25,
        "debounce_ms": 250,
        "populateMode": "immediate",
        "filter_mode": "populate"
      }
    },
    {
      "type": "button",
      "label": "Add Client",
      "formName": "Client"
    },
    {
      "type": "button",
      "label": "Detail View",
      "onClick": "openSelectedDetail"
    }
  ],
  "body": [
    {
      "type": "table",
      "options": {
        "tableName": "clients",
        "showGlobalSearch": false,
        "columnsToShow": ["name", "counsel", "phone", "email"],
        "addButton": false,
        "rowClick": "selectRecord",
        "filterField": "name",
        "listenColumn": "name"
      }
    }
  ],
  "footer": [
    {
      "type": "button",
      "label": "Close",
      "onClick": "closeModal"
    }
  ]
}'::jsonb
WHERE name = 'Clients';
