export function garageDoorInstallationCalculator(form: FormTs) {
// Pricing data
const doorTypePrices: Record<string, number> = {
'single-steel': 800,
'double-steel': 1400,
'single-wood': 1500,
'double-wood': 2800,
'single-aluminum': 1200,
'double-aluminum': 2200,
'single-fiberglass': 1100,
'double-fiberglass': 2000,
'single-composite': 1800,
'double-composite': 3400,
'single-glass': 2500,
'double-glass': 4500
};
const insulationPrices: Record<string, number> = {
'none': 0,
'polystyrene': 200,
'polyurethane': 400
};
const windowPrices: Record<string, number> = {
'none': 0,
'single-row': 150,
'double-row': 280,
'full-view': 500
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Garage Door Installation Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Service Location Section
const locationSection = form.addSubform('serviceLocation', { title: '📍 Installation Location' });
locationSection.addRow(row => {
row.addAddress('propertyAddress', {
label: 'Property Address',
placeholder: 'Enter your property address...',
showMap: true,
showDistance: true,
referenceAddress: {
formattedAddress: 'Service Center, Denver, CO',
coordinates: { lat: 39.7392, lng: -104.9903 }
},
restrictToCountries: ['US', 'CA'],
distanceUnit: 'miles',
isRequired: true
});
});
locationSection.addRow(row => {
row.addTextPanel('serviceAreaInfo', {
computedValue: () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null) return '📍 Enter address to check service area';
if (miles <= 20) return '📍 Within service area - No travel fee';
if (miles <= 40) return '📍 Extended area - $50 travel fee';
if (miles <= 60) return '📍 Remote area - $100 travel fee';
return '📍 Outside service area - Please call for availability';
},
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
// Door Selection Section
const doorSection = form.addSubform('door', { title: '🚗 Door Selection' });
doorSection.addRow(row => {
row.addDropdown('doorSize', {
label: 'Door Size',
options: [
{ id: 'single', name: 'Single Door (8-10 ft wide)' },
{ id: 'double', name: 'Double Door (16-18 ft wide)' }
],
defaultValue: 'single',
isRequired: true
}, '1fr');
row.addDropdown('doorMaterial', {
label: 'Door Material',
options: [
{ id: 'steel', name: 'Steel' },
{ id: 'wood', name: 'Wood' },
{ id: 'aluminum', name: 'Aluminum' },
{ id: 'fiberglass', name: 'Fiberglass' },
{ id: 'composite', name: 'Composite' },
{ id: 'glass', name: 'Glass/Contemporary' }
],
defaultValue: 'steel',
isRequired: true
}, '1fr');
});
doorSection.addRow(row => {
row.addDropdown('insulation', {
label: 'Insulation Type',
options: [
{ id: 'none', name: 'No Insulation' },
{ id: 'polystyrene', name: 'Polystyrene (R-value 6-9)' },
{ id: 'polyurethane', name: 'Polyurethane (R-value 12-18)' }
],
defaultValue: 'polystyrene',
tooltip: 'Higher R-value means better insulation'
}, '1fr');
row.addDropdown('windows', {
label: 'Window Style',
options: [
{ id: 'none', name: 'No Windows' },
{ id: 'single-row', name: 'Single Row' },
{ id: 'double-row', name: 'Double Row' },
{ id: 'full-view', name: 'Full View Panels' }
],
defaultValue: 'single-row'
}, '1fr');
});
// Installation Details
const installSection = form.addSubform('install', { title: '🔧 Installation Details' });
installSection.addRow(row => {
row.addDropdown('existingDoor', {
label: 'Existing Door Removal',
options: [
{ id: 'none', name: 'No Existing Door' },
{ id: 'remove', name: 'Remove & Dispose Old Door' },
{ id: 'keep', name: 'Remove Only (I\'ll Keep It)' }
],
defaultValue: 'remove',
isRequired: true
}, '1fr');
row.addDropdown('opener', {
label: 'Garage Door Opener',
options: [
{ id: 'none', name: 'No Opener Needed' },
{ id: 'chain', name: 'Chain Drive ($250)' },
{ id: 'belt', name: 'Belt Drive - Quiet ($400)' },
{ id: 'screw', name: 'Screw Drive ($350)' },
{ id: 'wall-mount', name: 'Wall Mount - Premium ($600)' },
{ id: 'smart', name: 'Smart Opener - WiFi ($550)' }
],
defaultValue: 'belt'
}, '1fr');
});
installSection.addRow(row => {
row.addCheckbox('reinforcement', {
label: 'Strut/Reinforcement Kit',
defaultValue: false,
tooltip: 'Recommended for high wind areas (+$150)'
}, '1fr');
row.addCheckbox('weatherSealing', {
label: 'Premium Weather Sealing',
defaultValue: true,
tooltip: 'Bottom seal, threshold, and side seals (+$120)'
}, '1fr');
});
installSection.addRow(row => {
row.addCheckbox('newTracks', {
label: 'New Track System',
defaultValue: false,
tooltip: 'Needed if current tracks are damaged (+$200)'
}, '1fr');
row.addCheckbox('smartFeatures', {
label: 'Smart Home Integration',
defaultValue: false,
tooltip: 'MyQ or similar smart home connectivity (+$100)'
}, '1fr');
});
// Additional Options
const optionsSection = form.addSubform('options', { title: '✨ Additional Options' });
optionsSection.addRow(row => {
row.addDropdown('color', {
label: 'Door Color',
options: [
{ id: 'standard', name: 'Standard White/Brown' },
{ id: 'custom', name: 'Custom Color (+$200)' },
{ id: 'woodgrain', name: 'Woodgrain Finish (+$350)' }
],
defaultValue: 'standard'
}, '1fr');
row.addDropdown('hardware', {
label: 'Decorative Hardware',
options: [
{ id: 'none', name: 'None' },
{ id: 'basic', name: 'Basic Handles & Hinges (+$80)' },
{ id: 'premium', name: 'Premium Carriage Style (+$200)' }
],
defaultValue: 'none'
}, '1fr');
});
optionsSection.addRow(row => {
row.addCheckbox('warranty', {
label: 'Extended Warranty (5 years)',
defaultValue: false,
tooltip: 'Covers parts and labor beyond manufacturer warranty (+$250)'
}, '1fr');
row.addCheckbox('maintenancePlan', {
label: 'Annual Maintenance Plan',
defaultValue: false,
tooltip: 'Yearly inspection and tune-up for 3 years (+$200)'
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Helper to calculate travel fee
const getTravelFee = () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null || miles <= 20) return 0;
if (miles <= 40) return 50;
if (miles <= 60) return 100;
return 150;
};
// Cost Breakdown
const breakdownSection = form.addSubform('breakdown', { title: '📊 Cost Breakdown', isCollapsible: false });
breakdownSection.addRow(row => {
row.addPriceDisplay('doorCost', {
label: 'Door & Materials',
computedValue: () => {
const size = doorSection.dropdown('doorSize')?.value() || 'single';
const material = doorSection.dropdown('doorMaterial')?.value() || 'steel';
const insulation = doorSection.dropdown('insulation')?.value() || 'polystyrene';
const windows = doorSection.dropdown('windows')?.value() || 'single-row';
const doorKey = `${size}-${material}`;
let cost = doorTypePrices[doorKey] || 800;
cost += insulationPrices[insulation] || 0;
cost += windowPrices[windows] || 0;
return cost;
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('openerCost', {
label: 'Opener & Smart Features',
computedValue: () => {
const opener = installSection.dropdown('opener')?.value() || 'belt';
const openerPrices: Record<string, number> = {
'none': 0,
'chain': 250,
'belt': 400,
'screw': 350,
'wall-mount': 600,
'smart': 550
};
let cost = openerPrices[opener] || 0;
if (installSection.checkbox('smartFeatures')?.value()) cost += 100;
return cost;
},
variant: 'default'
}, '1fr');
});
breakdownSection.addRow(row => {
row.addPriceDisplay('installCost', {
label: 'Installation & Removal',
computedValue: () => {
let cost = 350; // Base installation
const removal = installSection.dropdown('existingDoor')?.value() || 'remove';
if (removal === 'remove') cost += 150;
else if (removal === 'keep') cost += 75;
if (installSection.checkbox('newTracks')?.value()) cost += 200;
return cost;
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('addonsCost', {
label: 'Add-ons & Options',
computedValue: () => {
let cost = 0;
if (installSection.checkbox('reinforcement')?.value()) cost += 150;
if (installSection.checkbox('weatherSealing')?.value()) cost += 120;
const color = optionsSection.dropdown('color')?.value() || 'standard';
if (color === 'custom') cost += 200;
if (color === 'woodgrain') cost += 350;
const hardware = optionsSection.dropdown('hardware')?.value() || 'none';
if (hardware === 'basic') cost += 80;
if (hardware === 'premium') cost += 200;
if (optionsSection.checkbox('warranty')?.value()) cost += 250;
if (optionsSection.checkbox('maintenancePlan')?.value()) cost += 200;
return cost;
},
variant: 'default'
}, '1fr');
});
breakdownSection.addRow(row => {
row.addPriceDisplay('travelFee', {
label: 'Travel Fee',
computedValue: () => getTravelFee(),
variant: 'default',
prefix: '+',
isVisible: () => getTravelFee() > 0
});
});
// Summary Section
const summarySection = form.addSubform('summary', {
title: '💰 Your Estimate',
isCollapsible: false,
sticky: 'bottom'
});
summarySection.addRow(row => {
row.addPriceDisplay('totalCost', {
label: 'Total Estimated Cost',
computedValue: () => {
const size = doorSection.dropdown('doorSize')?.value() || 'single';
const material = doorSection.dropdown('doorMaterial')?.value() || 'steel';
const insulation = doorSection.dropdown('insulation')?.value() || 'polystyrene';
const windows = doorSection.dropdown('windows')?.value() || 'single-row';
const opener = installSection.dropdown('opener')?.value() || 'belt';
const removal = installSection.dropdown('existingDoor')?.value() || 'remove';
const color = optionsSection.dropdown('color')?.value() || 'standard';
const hardware = optionsSection.dropdown('hardware')?.value() || 'none';
// Door cost
const doorKey = `${size}-${material}`;
let total = doorTypePrices[doorKey] || 800;
total += insulationPrices[insulation] || 0;
total += windowPrices[windows] || 0;
// Opener
const openerPrices: Record<string, number> = {
'none': 0,
'chain': 250,
'belt': 400,
'screw': 350,
'wall-mount': 600,
'smart': 550
};
total += openerPrices[opener] || 0;
// Installation
total += 350;
if (removal === 'remove') total += 150;
else if (removal === 'keep') total += 75;
// Add-ons
if (installSection.checkbox('reinforcement')?.value()) total += 150;
if (installSection.checkbox('weatherSealing')?.value()) total += 120;
if (installSection.checkbox('newTracks')?.value()) total += 200;
if (installSection.checkbox('smartFeatures')?.value()) total += 100;
if (color === 'custom') total += 200;
if (color === 'woodgrain') total += 350;
if (hardware === 'basic') total += 80;
if (hardware === 'premium') total += 200;
if (optionsSection.checkbox('warranty')?.value()) total += 250;
if (optionsSection.checkbox('maintenancePlan')?.value()) total += 200;
const travelFee = getTravelFee();
return total + travelFee;
},
variant: 'large'
});
});
summarySection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'Prices are estimates. Actual costs may vary based on location, specific door dimensions, and structural requirements. Contact us for a precise quote.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'text-align': 'center' }
});
});
form.configureSubmitButton({
label: 'Get Free Quote'
});
}