export function customFurnitureCalculator(form: FormTs) {
// Base prices by furniture type
const furniturePrices: Record<string, number> = {
'dining-table': 1200,
'coffee-table': 450,
'bookshelf': 650,
'desk': 800,
'bed-frame': 1400,
'dresser': 950,
'cabinet': 1100,
'entertainment-center': 1300,
'bench': 350,
'nightstand': 280
};
// Wood type multipliers
const woodMultipliers: Record<string, number> = {
'pine': 0.7,
'oak': 1,
'walnut': 1.5,
'cherry': 1.4,
'maple': 1.2,
'mahogany': 1.8,
'reclaimed': 1.3,
'exotic': 2.2
};
// Size multipliers
const sizeMultipliers: Record<string, number> = {
'small': 0.75,
'standard': 1,
'large': 1.35,
'extra-large': 1.7
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Custom Furniture Quote Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Furniture Type Section
const furnitureSection = form.addSubform('furnitureType', { title: '๐ช Furniture Details' });
furnitureSection.addRow(row => {
row.addDropdown('pieceType', {
label: 'Furniture Type',
options: [
{ id: 'dining-table', name: 'Dining Table (from $1,200)' },
{ id: 'coffee-table', name: 'Coffee Table (from $450)' },
{ id: 'desk', name: 'Desk (from $800)' },
{ id: 'bookshelf', name: 'Bookshelf (from $650)' },
{ id: 'bed-frame', name: 'Bed Frame (from $1,400)' },
{ id: 'dresser', name: 'Dresser (from $950)' },
{ id: 'cabinet', name: 'Cabinet (from $1,100)' },
{ id: 'entertainment-center', name: 'Entertainment Center (from $1,300)' },
{ id: 'bench', name: 'Bench (from $350)' },
{ id: 'nightstand', name: 'Nightstand (from $280)' }
],
defaultValue: 'dining-table',
isRequired: true
}, '1fr');
row.addInteger('quantity', {
label: 'Quantity',
min: 1,
max: 10,
defaultValue: 1,
tooltip: '10% discount for 2+ identical pieces'
}, '1fr');
});
furnitureSection.addRow(row => {
row.addDropdown('size', {
label: 'Size',
options: [
{ id: 'small', name: 'Small (-25%)' },
{ id: 'standard', name: 'Standard' },
{ id: 'large', name: 'Large (+35%)' },
{ id: 'extra-large', name: 'Extra Large (+70%)' }
],
defaultValue: 'standard',
isRequired: true
}, '1fr');
row.addDropdown('complexity', {
label: 'Design Complexity',
options: [
{ id: 'simple', name: 'Simple (clean lines)' },
{ id: 'moderate', name: 'Moderate (some details) +20%' },
{ id: 'intricate', name: 'Intricate (carved details) +50%' },
{ id: 'heirloom', name: 'Heirloom Quality +100%' }
],
defaultValue: 'simple'
}, '1fr');
});
// Materials Section
const materialsSection = form.addSubform('materials', { title: '๐ณ Materials' });
materialsSection.addRow(row => {
row.addDropdown('woodType', {
label: 'Primary Wood',
options: [
{ id: 'pine', name: 'Pine (-30%)' },
{ id: 'oak', name: 'Oak (standard)' },
{ id: 'maple', name: 'Maple (+20%)' },
{ id: 'cherry', name: 'Cherry (+40%)' },
{ id: 'walnut', name: 'Walnut (+50%)' },
{ id: 'mahogany', name: 'Mahogany (+80%)' },
{ id: 'reclaimed', name: 'Reclaimed Wood (+30%)' },
{ id: 'exotic', name: 'Exotic Hardwood (+120%)' }
],
defaultValue: 'oak',
isRequired: true
}, '1fr');
row.addDropdown('finish', {
label: 'Finish',
options: [
{ id: 'natural', name: 'Natural Oil (+$50)' },
{ id: 'stained', name: 'Stained (+$100)' },
{ id: 'painted', name: 'Painted (+$150)' },
{ id: 'distressed', name: 'Distressed/Antiqued (+$200)' },
{ id: 'lacquer', name: 'High-Gloss Lacquer (+$300)' }
],
defaultValue: 'natural'
}, '1fr');
});
materialsSection.addRow(row => {
row.addCheckbox('liveedge', {
label: 'Live Edge (+$200)',
defaultValue: false,
tooltip: 'Natural wood edge preserved',
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type === 'dining-table' || type === 'coffee-table' || type === 'desk' || type === 'bench';
}
}, '1fr');
row.addCheckbox('inlays', {
label: 'Wood Inlays/Epoxy (+$350)',
defaultValue: false,
tooltip: 'Decorative inlays or river table style'
}, '1fr');
});
// Features Section
const featuresSection = form.addSubform('features', { title: 'โจ Features & Add-ons' });
featuresSection.addRow(row => {
row.addCheckbox('drawers', {
label: 'Drawers (+$75/drawer)',
defaultValue: false,
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type !== 'bench' && type !== 'bed-frame';
}
}, '1fr');
row.addCheckbox('shelves', {
label: 'Additional Shelves (+$50/shelf)',
defaultValue: false,
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type === 'bookshelf' || type === 'cabinet' || type === 'entertainment-center';
}
}, '1fr');
});
featuresSection.addRow(row => {
row.addInteger('drawerCount', {
label: 'Number of Drawers',
min: 1,
max: 12,
defaultValue: 2,
isVisible: () => featuresSection.checkbox('drawers')?.value() === true
}, '1fr');
row.addInteger('shelfCount', {
label: 'Additional Shelves',
min: 1,
max: 8,
defaultValue: 1,
isVisible: () => featuresSection.checkbox('shelves')?.value() === true
}, '1fr');
});
featuresSection.addRow(row => {
row.addCheckbox('customHardware', {
label: 'Premium Hardware (+$100)',
defaultValue: false,
tooltip: 'Upgraded handles, knobs, or hinges'
}, '1fr');
row.addCheckbox('softClose', {
label: 'Soft-Close Mechanisms (+$25/drawer)',
defaultValue: false,
isVisible: () => featuresSection.checkbox('drawers')?.value() === true
}, '1fr');
});
featuresSection.addRow(row => {
row.addCheckbox('glassInsert', {
label: 'Glass Door Inserts (+$150)',
defaultValue: false,
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type === 'cabinet' || type === 'bookshelf' || type === 'entertainment-center';
}
}, '1fr');
row.addCheckbox('lighting', {
label: 'LED Lighting (+$125)',
defaultValue: false,
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type === 'cabinet' || type === 'bookshelf' || type === 'entertainment-center';
}
}, '1fr');
});
featuresSection.addRow(row => {
row.addCheckbox('cableManagement', {
label: 'Cable Management (+$75)',
defaultValue: false,
isVisible: () => {
const type = furnitureSection.dropdown('pieceType')?.value();
return type === 'desk' || type === 'entertainment-center';
}
}, '1fr');
row.addCheckbox('adjustableLegs', {
label: 'Adjustable Leveling Feet (+$40)',
defaultValue: false
}, '1fr');
});
// Delivery Section
const deliverySection = form.addSubform('delivery', { title: '๐ Delivery & Timeline' });
deliverySection.addRow(row => {
row.addRadioButton('timeline', {
label: 'Production Timeline',
options: [
{ id: 'standard', name: 'Standard (8-12 weeks)' },
{ id: 'priority', name: 'Priority (6-8 weeks) +15%' },
{ id: 'rush', name: 'Rush (4-6 weeks) +30%' }
],
defaultValue: 'standard',
orientation: 'vertical'
});
});
deliverySection.addRow(row => {
row.addCheckbox('delivery', {
label: 'White Glove Delivery (+$150)',
defaultValue: false,
tooltip: 'Professional delivery and placement'
}, '1fr');
row.addCheckbox('assembly', {
label: 'On-Site Assembly (+$100)',
defaultValue: false,
tooltip: 'Required for larger pieces'
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Price Summary Section
const summarySection = form.addSubform('summary', { title: '๐ฐ Price Breakdown', isCollapsible: false });
summarySection.addRow(row => {
row.addPriceDisplay('basePrice', {
label: 'Base Price',
computedValue: () => {
const pieceType = furnitureSection.dropdown('pieceType')?.value() || 'dining-table';
const woodType = materialsSection.dropdown('woodType')?.value() || 'oak';
const size = furnitureSection.dropdown('size')?.value() || 'standard';
const complexity = furnitureSection.dropdown('complexity')?.value() || 'simple';
let price = furniturePrices[pieceType] || 1000;
price *= woodMultipliers[woodType] || 1;
price *= sizeMultipliers[size] || 1;
// Complexity
if (complexity === 'moderate') price *= 1.2;
if (complexity === 'intricate') price *= 1.5;
if (complexity === 'heirloom') price *= 2;
return Math.round(price);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('finishPrice', {
label: 'Finish',
computedValue: () => {
const finish = materialsSection.dropdown('finish')?.value() || 'natural';
if (finish === 'natural') return 50;
if (finish === 'stained') return 100;
if (finish === 'painted') return 150;
if (finish === 'distressed') return 200;
if (finish === 'lacquer') return 300;
return 0;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('materialUpgrades', {
label: 'Material Upgrades',
computedValue: () => {
let total = 0;
if (materialsSection.checkbox('liveedge')?.value()) total += 200;
if (materialsSection.checkbox('inlays')?.value()) total += 350;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('features', {
label: 'Features',
computedValue: () => {
let total = 0;
if (featuresSection.checkbox('drawers')?.value()) {
const count = featuresSection.integer('drawerCount')?.value() || 2;
total += count * 75;
if (featuresSection.checkbox('softClose')?.value()) {
total += count * 25;
}
}
if (featuresSection.checkbox('shelves')?.value()) {
const count = featuresSection.integer('shelfCount')?.value() || 1;
total += count * 50;
}
if (featuresSection.checkbox('customHardware')?.value()) total += 100;
if (featuresSection.checkbox('glassInsert')?.value()) total += 150;
if (featuresSection.checkbox('lighting')?.value()) total += 125;
if (featuresSection.checkbox('cableManagement')?.value()) total += 75;
if (featuresSection.checkbox('adjustableLegs')?.value()) total += 40;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('timelineUpcharge', {
label: 'Priority Production',
computedValue: () => {
const timeline = deliverySection.radioButton('timeline')?.value() || 'standard';
if (timeline === 'standard') return 0;
// Calculate base
const pieceType = furnitureSection.dropdown('pieceType')?.value() || 'dining-table';
const woodType = materialsSection.dropdown('woodType')?.value() || 'oak';
const size = furnitureSection.dropdown('size')?.value() || 'standard';
let base = furniturePrices[pieceType] || 1000;
base *= woodMultipliers[woodType] || 1;
base *= sizeMultipliers[size] || 1;
if (timeline === 'priority') return Math.round(base * 0.15);
if (timeline === 'rush') return Math.round(base * 0.30);
return 0;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('deliveryTotal', {
label: 'Delivery & Setup',
computedValue: () => {
let total = 0;
if (deliverySection.checkbox('delivery')?.value()) total += 150;
if (deliverySection.checkbox('assembly')?.value()) total += 100;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '๐งพ Summary',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('perPiecePrice', {
label: 'Per Piece',
computedValue: () => {
const pieceType = furnitureSection.dropdown('pieceType')?.value() || 'dining-table';
const woodType = materialsSection.dropdown('woodType')?.value() || 'oak';
const size = furnitureSection.dropdown('size')?.value() || 'standard';
const complexity = furnitureSection.dropdown('complexity')?.value() || 'simple';
const finish = materialsSection.dropdown('finish')?.value() || 'natural';
const timeline = deliverySection.radioButton('timeline')?.value() || 'standard';
let price = furniturePrices[pieceType] || 1000;
price *= woodMultipliers[woodType] || 1;
price *= sizeMultipliers[size] || 1;
if (complexity === 'moderate') price *= 1.2;
if (complexity === 'intricate') price *= 1.5;
if (complexity === 'heirloom') price *= 2;
// Finish
if (finish === 'natural') price += 50;
if (finish === 'stained') price += 100;
if (finish === 'painted') price += 150;
if (finish === 'distressed') price += 200;
if (finish === 'lacquer') price += 300;
// Material upgrades
if (materialsSection.checkbox('liveedge')?.value()) price += 200;
if (materialsSection.checkbox('inlays')?.value()) price += 350;
// Features
if (featuresSection.checkbox('drawers')?.value()) {
const count = featuresSection.integer('drawerCount')?.value() || 2;
price += count * 75;
if (featuresSection.checkbox('softClose')?.value()) price += count * 25;
}
if (featuresSection.checkbox('shelves')?.value()) {
const count = featuresSection.integer('shelfCount')?.value() || 1;
price += count * 50;
}
if (featuresSection.checkbox('customHardware')?.value()) price += 100;
if (featuresSection.checkbox('glassInsert')?.value()) price += 150;
if (featuresSection.checkbox('lighting')?.value()) price += 125;
if (featuresSection.checkbox('cableManagement')?.value()) price += 75;
if (featuresSection.checkbox('adjustableLegs')?.value()) price += 40;
// Timeline
if (timeline === 'priority') price *= 1.15;
if (timeline === 'rush') price *= 1.30;
return Math.round(price);
},
variant: 'default',
suffix: '/piece'
}, '1fr');
row.addPriceDisplay('totalPrice', {
label: 'Total Estimate',
computedValue: () => {
const pieceType = furnitureSection.dropdown('pieceType')?.value() || 'dining-table';
const woodType = materialsSection.dropdown('woodType')?.value() || 'oak';
const size = furnitureSection.dropdown('size')?.value() || 'standard';
const complexity = furnitureSection.dropdown('complexity')?.value() || 'simple';
const finish = materialsSection.dropdown('finish')?.value() || 'natural';
const timeline = deliverySection.radioButton('timeline')?.value() || 'standard';
const quantity = furnitureSection.integer('quantity')?.value() || 1;
let price = furniturePrices[pieceType] || 1000;
price *= woodMultipliers[woodType] || 1;
price *= sizeMultipliers[size] || 1;
if (complexity === 'moderate') price *= 1.2;
if (complexity === 'intricate') price *= 1.5;
if (complexity === 'heirloom') price *= 2;
if (finish === 'natural') price += 50;
if (finish === 'stained') price += 100;
if (finish === 'painted') price += 150;
if (finish === 'distressed') price += 200;
if (finish === 'lacquer') price += 300;
if (materialsSection.checkbox('liveedge')?.value()) price += 200;
if (materialsSection.checkbox('inlays')?.value()) price += 350;
if (featuresSection.checkbox('drawers')?.value()) {
const count = featuresSection.integer('drawerCount')?.value() || 2;
price += count * 75;
if (featuresSection.checkbox('softClose')?.value()) price += count * 25;
}
if (featuresSection.checkbox('shelves')?.value()) {
const count = featuresSection.integer('shelfCount')?.value() || 1;
price += count * 50;
}
if (featuresSection.checkbox('customHardware')?.value()) price += 100;
if (featuresSection.checkbox('glassInsert')?.value()) price += 150;
if (featuresSection.checkbox('lighting')?.value()) price += 125;
if (featuresSection.checkbox('cableManagement')?.value()) price += 75;
if (featuresSection.checkbox('adjustableLegs')?.value()) price += 40;
if (timeline === 'priority') price *= 1.15;
if (timeline === 'rush') price *= 1.30;
// Multi-piece discount
let total = price * quantity;
if (quantity >= 2) total *= 0.9; // 10% discount
// Delivery
if (deliverySection.checkbox('delivery')?.value()) total += 150;
if (deliverySection.checkbox('assembly')?.value()) total += 100;
return Math.round(total);
},
variant: 'large'
}, '1fr');
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => '50% deposit required. Final price confirmed after design consultation. Custom designs require detailed drawings.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Request Custom Quote'
});
}