-- Migration: Add employee name search to Time Clocks module
-- Date: 2025-10-08
-- Description: Adds a filter-select search by employee full_name to the Time Clocks module

UPDATE modules 
SET config = $json$ {
  "title": "Time Clocks",
  "header": [
    {
      "type": "filter-select",
      "options": {
        "source_table": "users",
        "source_column": "user_id",
        "display_column": "full_name",
        "data_column": "name",
        "data_column_id": "user_id",
        "placeholder": "Search by employee name...",
        "search_fields": ["full_name"],
        "max_results": 25,
        "debounce_ms": 250,
        "populateMode": "immediate"
      }
    }
  ],
  "body": [
    {
      "type": "table",
      "options": {
        "tableName": "time_clocks",
        "showGlobalSearch": false,
        "addButton": false,
        "filterField": "name",
        "listenColumn": "name",
        "columnsToShow": ["name", "clock_type", "clocked_at"]
      }
    }
  ],
  "footer": [
    { "type": "button", "label": "Close", "onClick": "closeModal" }
  ]
} $json$::jsonb
WHERE module_id = '0194a8b2-7123-7123-8123-123456789abc'::uuid;
