-- ============================================================================
-- Add Recent Legacy JavaScript Modules to modules Table
-- ============================================================================
-- Description: Register 5 legacy JavaScript modules (HRMS, Finance, Fleet, 
--              Packaging, QA) in the modules table for UI discovery
-- Date: 2025-11-22
-- ============================================================================

-- HRMS Recruitment Module
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
VALUES (
  '0194a8b2-1001-7123-8123-123456789abc'::uuid,
  'HRMSRecruitment',
  '{"title":"HRMS Recruitment","body":[{"type":"html","html":"HRMS Recruitment content"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}],"legacy":true}',
  NULL,
  NULL,
  'fa-users',
  'HRMS Recruitment',
  'HRMS Recruitment and hiring management'
)
ON CONFLICT (module_id) DO NOTHING;

-- Finance Management Module
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
VALUES (
  '0194a8b2-1002-7123-8123-123456789abc'::uuid,
  'FinanceManagement',
  '{"title":"Finance Management","body":[{"type":"html","html":"Finance Management content"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}],"legacy":true}',
  NULL,
  NULL,
  'fa-chart-line',
  'Finance Management',
  'Finance and accounting management'
)
ON CONFLICT (module_id) DO NOTHING;

-- Fleet Management Module
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
VALUES (
  '0194a8b2-1003-7123-8123-123456789abc'::uuid,
  'FleetManagement',
  '{"title":"Fleet Management","body":[{"type":"html","html":"Fleet Management content"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}],"legacy":true}',
  NULL,
  NULL,
  'fa-truck',
  'Fleet Management',
  'Vehicle fleet and GPS tracking management'
)
ON CONFLICT (module_id) DO NOTHING;

-- Packaging Module
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
VALUES (
  '0194a8b2-1004-7123-8123-123456789abc'::uuid,
  'Packaging',
  '{"title":"Packaging","body":[{"type":"html","html":"Packaging content"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}],"legacy":true}',
  NULL,
  NULL,
  'fa-box',
  'Packaging',
  'Packaging operations and materials management'
)
ON CONFLICT (module_id) DO NOTHING;

-- Quality Assurance Module
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
VALUES (
  '0194a8b2-1005-7123-8123-123456789abc'::uuid,
  'QualityAssurance',
  '{"title":"Quality Assurance","body":[{"type":"html","html":"Quality Assurance content"}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}],"legacy":true}',
  NULL,
  NULL,
  'fa-clipboard-check',
  'Quality Assurance',
  'Quality inspections and standards management'
)
ON CONFLICT (module_id) DO NOTHING;

-- Verification
SELECT 
  name,
  icon,
  description,
  config->>'legacy' as is_legacy
FROM modules
WHERE name IN ('HRMSRecruitment', 'FinanceManagement', 'FleetManagement', 'Packaging', 'QualityAssurance')
ORDER BY name;
