-- Donor Approval Module
-- Module for reviewing and approving/rejecting donor registrations

INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description) VALUES (
  '0194a8b2-da01-7123-8123-123456789def'::uuid,
  'donor_approvals',
  '{
    "title": "Donor Approvals",
    "modulePath": "modules/blood_donation/donor_approvals",
    
    "header": [
      {
        "type": "filter-select",
        "options": {
          "data_column": "blood_type",
          "options": [
            {"label": "All Blood Types", "value": ""},
            {"label": "A+", "value": "A+"},
            {"label": "A-", "value": "A-"},
            {"label": "B+", "value": "B+"},
            {"label": "B-", "value": "B-"},
            {"label": "AB+", "value": "AB+"},
            {"label": "AB-", "value": "AB-"},
            {"label": "O+", "value": "O+"},
            {"label": "O-", "value": "O-"}
          ]
        }
      },
      {
        "type": "filter-select",
        "options": {
          "data_column": "registration_source",
          "options": [
            {"label": "All Sources", "value": ""},
            {"label": "Mobile App", "value": "mobile_app"},
            {"label": "Web Portal", "value": "web"},
            {"label": "Walk-in", "value": "walk_in"}
          ]
        }
      },
      {
        "type": "filter-date-range",
        "options": {
          "data_column": "created_at"
        }
      }
    ],
    
    "body": [
      {
        "type": "table",
        "id": "donorApprovalsTable",
        "options": {
          "tableName": "donors",
          "columnsToShow": [
            "full_name",
            "email",
            "phone",
            "blood_type",
            "date_of_birth",
            "registration_source",
            "created_at"
          ],
          "columnLabels": {
            "full_name": "Full Name",
            "email": "Email",
            "phone": "Phone",
            "blood_type": "Blood Type",
            "date_of_birth": "DOB",
            "registration_source": "Source",
            "created_at": "Registered"
          },
          "filters": {
            "verification_status": "pending"
          },
          "showGlobalSearch": true,
          "rowClick": "selectRecord",
          "rowActions": [
            {
              "label": "Approve",
              "type": "Confirm",
              "prompt": "Approve this donor and create user account?",
              "icon": "fa-check",
              "class": "btn-success btn-sm",
              "columns": {
                "verification_status": "approved"
              }
            },
            {
              "label": "Reject",
              "type": "Confirm",
              "prompt": "Reject this donor registration?",
              "icon": "fa-times",
              "class": "btn-danger btn-sm",
              "columns": {
                "verification_status": "rejected"
              }
            }
          ]
        }
      }
    ],
    
    "footer": [
      {
        "type": "button",
        "label": "Close",
        "onClick": "closeModal"
      }
    ]
  }'::jsonb,
  NULL,
  NULL,
  'fa-user-check',
  'Donor Approvals',
  'Review and approve or reject donor registrations from mobile app'
);;
