-- Dashboard card and action for My Inspections
-- Insert UI action mapping the dashboard card to open the My Inspections modal
INSERT INTO ui_actions (page, action_key, button_label, button_id, target)
SELECT 'dashboard', 'my_inspections', 'My Inspections', 'MyInspections', 'My Inspections'
WHERE NOT EXISTS (
    SELECT 1 FROM ui_actions WHERE page='dashboard' AND action_key='my_inspections'
);

-- Add dashboard page config with My Inspections card if missing
INSERT INTO page_configs (page, header_title, cards, layout_type)
SELECT 'dashboard', 'Main Dashboard',
       '[{"text":"My Inspections","action":"my_inspections"}]', 'grid'
WHERE NOT EXISTS (
    SELECT 1 FROM page_configs WHERE page='dashboard' AND tenant_id IS NULL AND branch_id IS NULL
);
