-- Add Barcode and QR Code generation buttons to Products module
-- Migration: add_barcode_qrcode_buttons_products
-- Date: October 25, 2025
-- Description: Adds "Generate Barcode" and "Generate QR Code" buttons to the Products module header

DO $$
BEGIN
    -- Update Products module configuration to include barcode and QR code generation buttons
    UPDATE modules
    SET config = jsonb_set(
        config,
        '{header}',
        '[
            {"type":"button", "label":"Add Product", "formName":"Product"},
            {"type":"button", "label":"Auto Orders", "formName":"Auto Order"},
            {"type":"button", "label":"Generate Barcode", "action":"products:generate-barcode"},
            {"type":"button", "label":"Generate QR Code", "action":"products:generate-qrcode"},
            {"type":"button", "label":"Import Products", "onClick":"importProducts", "class":"btn-outline btn-info"},
            {"type":"button", "label":"Export Products", "onClick":"exportProducts", "class":"btn-outline btn-success"}
        ]'::jsonb
    )
    WHERE name = 'Products'
    AND module_id = '0194a8b2-c3f1-7123-8123-123456789ab1'::uuid;

    RAISE NOTICE 'Products module updated with barcode and QR code generation buttons';
END $$;

-- Verify the update
SELECT 
    name,
    config->'header' as header_buttons
FROM modules 
WHERE name = 'Products'
AND module_id = '0194a8b2-c3f1-7123-8123-123456789ab1'::uuid;
