export function tutoringRateForm(form: FormTs) {
form.setTitle(() => '📚 Tutoring Rate Calculator');
form.configureCompletionScreen({
type: 'text',
title: () => '🎓 Quote Ready!',
message: () => 'Your tutoring rate estimate is ready. Schedule a free consultation to get started!'
});
const subjectRates: Record<string, number> = {
'elementary': 30,
'middle': 40,
'high-school': 50,
'ap-honors': 65,
'college': 75,
'test-prep': 80
};
const subjectMultipliers: Record<string, number> = {
'math': 1.1,
'science': 1.15,
'english': 1.0,
'language': 1.1,
'cs': 1.2
};
const studentSection = form.addSubform('student', {
title: () => '👨🎓 Student Info',
mobileBreakpoint: 0
});
studentSection.addRow(row => {
row.addDropdown('level', {
label: 'Grade Level',
options: [
{ id: 'elementary', name: 'Elementary (K-5)' },
{ id: 'middle', name: 'Middle School (6-8)' },
{ id: 'high-school', name: 'High School (9-12)' },
{ id: 'ap-honors', name: 'AP/Honors' },
{ id: 'college', name: 'College' },
{ id: 'test-prep', name: 'Test Prep (SAT/ACT)' }
],
defaultValue: 'high-school',
isRequired: true
}, '1fr');
row.addDropdown('subject', {
label: 'Subject',
options: [
{ id: 'math', name: 'Math' },
{ id: 'science', name: 'Science' },
{ id: 'english', name: 'English' },
{ id: 'language', name: 'Foreign Language' },
{ id: 'cs', name: 'Computer Science' }
],
defaultValue: 'math',
isRequired: true
}, '1fr');
});
const sessionSection = form.addSubform('session', {
title: () => '📖 Session Details',
mobileBreakpoint: 0
});
sessionSection.addRow(row => {
row.addRadioButton('duration', {
label: 'Session Length',
options: [
{ id: '30', name: '30 min' },
{ id: '60', name: '60 min (Popular)' },
{ id: '90', name: '90 min (-5%)' },
{ id: '120', name: '2 hours (-10%)' }
],
defaultValue: '60',
orientation: 'horizontal'
}, '1fr');
row.addRadioButton('format', {
label: 'Format',
options: [
{ id: 'online', name: '💻 Online' },
{ id: 'in-person', name: '🏠 In-Person (+15%)' }
],
defaultValue: 'online',
orientation: 'horizontal'
}, '1fr');
});
const packageSection = form.addSubform('package', {
title: () => '📦 Package',
mobileBreakpoint: 0
});
packageSection.addRow(row => {
row.addRadioButton('packageType', {
label: 'Commitment',
options: [
{ id: 'single', name: 'Single Session' },
{ id: '4', name: '4 Sessions (-5%)' },
{ id: '8', name: '8 Sessions (-10%)' },
{ id: '12', name: '12 Sessions (-15%)' }
],
defaultValue: 'single',
orientation: 'vertical'
});
});
packageSection.addRow(row => {
row.addInteger('students', {
label: 'Number of Students',
min: 1,
max: 4,
defaultValue: 1,
tooltip: 'Group discount for 2+ students'
}, '1fr');
});
const addonsSection = form.addSubform('addons', {
title: () => '✨ Add-ons',
mobileBreakpoint: 0
});
addonsSection.addRow(row => {
row.addCheckboxList('addons', {
label: 'Select Add-ons',
options: [
{ id: 'homework', name: '📝 Homework Help (+$15/week)' },
{ id: 'reports', name: '📊 Progress Reports (+$10/week)' },
{ id: 'materials', name: '📚 Study Materials (+$20/week)' }
],
orientation: 'vertical'
});
});
const calculateRate = () => {
const level = studentSection.dropdown('level')?.value() || 'high-school';
const subject = studentSection.dropdown('subject')?.value() || 'math';
const duration = sessionSection.radioButton('duration')?.value() || '60';
const format = sessionSection.radioButton('format')?.value() || 'online';
const packageType = packageSection.radioButton('packageType')?.value() || 'single';
const students = packageSection.integer('students')?.value() || 1;
let hourlyRate = subjectRates[level] || 50;
hourlyRate *= subjectMultipliers[subject] || 1;
if (format === 'in-person') hourlyRate *= 1.15;
const durationMins = parseInt(duration);
const durationDiscount: Record<string, number> = { '30': 0, '60': 0, '90': 5, '120': 10 };
hourlyRate *= (1 - (durationDiscount[duration] || 0) / 100);
let sessionRate = hourlyRate * (durationMins / 60);
if (students > 1) {
sessionRate *= (1 - 0.15 * (students - 1) / students);
}
const packageDiscount: Record<string, number> = { single: 0, '4': 5, '8': 10, '12': 15 };
sessionRate *= (1 - (packageDiscount[packageType] || 0) / 100);
return Math.round(sessionRate);
};
const getTotalSessions = () => {
const packageType = packageSection.radioButton('packageType')?.value() || 'single';
const sessions: Record<string, number> = { single: 1, '4': 4, '8': 8, '12': 12 };
return sessions[packageType] || 1;
};
const getWeeklyAddons = () => {
const selected = addonsSection.checkboxList('addons')?.value() || [];
const prices: Record<string, number> = {
homework: 15,
reports: 10,
materials: 20
};
return selected.reduce((total, id) => total + (prices[id] || 0), 0);
};
const summary = form.addSubform('summary', {
title: () => '💰 Your Quote',
isCollapsible: false
});
summary.addRow(row => {
row.addPriceDisplay('sessionRate', {
label: 'Per Session',
computedValue: () => calculateRate(),
alignment: 'center',
variant: 'large',
suffix: '/session'
});
});
summary.addRow(row => {
row.addTextPanel('package', {
computedValue: () => {
const sessions = getTotalSessions();
const rate = calculateRate();
const total = sessions * rate;
const addons = getWeeklyAddons();
let text = '';
if (sessions > 1) {
text = `📦 ${sessions} sessions = $${total}`;
} else {
text = '💡 Tip: Package deals save up to 15%!';
}
if (addons > 0) {
text += ` | Add-ons: +$${addons}/week`;
}
return text;
},
customStyles: {
fontSize: '0.95rem',
color: '#059669',
textAlign: 'center',
fontWeight: '500'
}
});
});
summary.addRow(row => {
row.addTextPanel('note', {
computedValue: () => 'First session includes free 15-min assessment',
customStyles: {
fontSize: '0.85rem',
color: '#6b7280',
textAlign: 'center'
}
});
});
form.configureSubmitButton({
label: () => 'Book Free Consultation'
});
}