-- Add Incident Trends graph and modal
INSERT INTO graphs (name, config)
SELECT 'Incident Trends', '{"table":"ohs_incidents","x":"date","y":"id","type":"groupedBar","groupBy":"date,classification","aggregateFunc":"count","timeUnit":"year"}'
WHERE NOT EXISTS (SELECT 1 FROM graphs WHERE name = 'Incident Trends');

INSERT INTO ui_modals (name, config, tenant_id, branch_id, icon, aria_label, description)
SELECT 'Incident Trends', '{"title":"Incident Trends","body":[{"type":"graph-d3","graphId":2,"options":{"timeUnits":["day","week","month","year"]}}],"footer":[{"type":"button","label":"Close","onClick":"closeModal"}]}' , NULL, NULL, 'fa-chart-bar', 'Incident Trends', 'Incident Trends'
WHERE NOT EXISTS (SELECT 1 FROM ui_modals WHERE name = 'Incident Trends');
