-- =========================================================
-- 029_agent_permissions.sql
-- Sprint 10: agent module permissions seed
-- =========================================================

INSERT IGNORE INTO permissions (code, name, module, created_at) VALUES
('agents.view','Lihat Daftar Agen','agents',NOW()),
('agents.pos','Akses Pos Agen','agents',NOW()),
('agents.recap','Akses Rekap Agen','agents',NOW()),
('agents.manage','Kelola Modul Agen','agents',NOW());

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id, p.id
FROM roles r
JOIN permissions p ON p.code IN (
  'agents.view',
  'agents.pos',
  'agents.recap',
  'agents.manage'
)
WHERE r.code IN ('owner','admin','kepala_toko');
