export function skincareRoutineQuiz(form: FormTs) {
form.setTitle(() => '✨ Find Your Perfect Skincare Routine');
// ============ RECOMMENDATION SYSTEM ============
const answers = form.state<Record<string, string | string[]>>({});
const setAnswer = (key: string, value: string | string[]) => {
answers.update(current => ({ ...current, [key]: value }));
};
type SkinType = 'oily' | 'dry' | 'combination' | 'sensitive' | 'normal';
type Concern = 'acne' | 'aging' | 'dullness' | 'hyperpigmentation' | 'redness' | 'dehydration';
const getSkinType = (): SkinType => (answers()['skinType'] as SkinType) || 'normal';
const getRecommendedRoutine = () => {
const skinType = getSkinType();
const concerns = (answers()['concerns'] as string[]) || [];
const budget = answers()['budget'] as string;
const time = answers()['routineTime'] as string;
const routines: Record<SkinType, { cleanser: string; toner: string; serum: string; moisturizer: string; spf: string }> = {
oily: {
cleanser: 'Gel or foam cleanser with salicylic acid',
toner: 'Niacinamide toner for pore control',
serum: 'Lightweight hyaluronic acid serum',
moisturizer: 'Oil-free gel moisturizer',
spf: 'Mattifying SPF 50'
},
dry: {
cleanser: 'Cream or milk cleanser',
toner: 'Hydrating essence with ceramides',
serum: 'Rich hyaluronic acid + vitamin E serum',
moisturizer: 'Rich cream with shea butter',
spf: 'Moisturizing SPF 50'
},
combination: {
cleanser: 'Gentle gel cleanser',
toner: 'Balancing toner with witch hazel',
serum: 'Multi-action serum with niacinamide',
moisturizer: 'Lightweight lotion',
spf: 'Hydrating SPF 50'
},
sensitive: {
cleanser: 'Micellar water or gentle milk cleanser',
toner: 'Alcohol-free soothing toner',
serum: 'Centella asiatica calming serum',
moisturizer: 'Fragrance-free barrier cream',
spf: 'Mineral SPF 50 (zinc oxide)'
},
normal: {
cleanser: 'Gentle foaming cleanser',
toner: 'Hydrating toner with antioxidants',
serum: 'Vitamin C serum',
moisturizer: 'Balanced daily moisturizer',
spf: 'Broad-spectrum SPF 50'
}
};
return routines[skinType];
};
const getTargetedTreatments = () => {
const concerns = (answers()['concerns'] as string[]) || [];
const treatments: Record<string, string> = {
acne: 'Benzoyl peroxide or retinoid treatment',
aging: 'Retinol night cream + peptide serum',
dullness: 'AHA/BHA exfoliant (2-3x weekly)',
hyperpigmentation: 'Vitamin C + alpha arbutin serum',
redness: 'Azelaic acid + niacinamide',
dehydration: 'Hyaluronic acid layering technique'
};
return concerns.map(c => treatments[c]).filter(Boolean);
};
const getBudgetRange = () => {
const budget = answers()['budget'] as string;
const ranges: Record<string, string> = {
budget: '$50-100/month - Focus on core products',
moderate: '$100-200/month - Add targeted treatments',
premium: '$200-400/month - Full professional routine',
luxury: '$400+/month - Spa-quality at home'
};
return ranges[budget] || ranges['moderate'];
};
// ============ COMPLETION SCREEN ============
form.configureCompletionScreen({
type: 'text',
title: () => `✨ Your Personalized Skincare Routine`,
message: () => {
const routine = getRecommendedRoutine();
return `Based on your ${getSkinType()} skin type, we've created a customized routine. Download your complete skincare guide with product recommendations and application tips!`;
}
});
// ============ PAGES SETUP ============
const pages = form.addPages('quiz-pages', {
heightMode: 'current-page'
});
// ============ PAGE 1: Skin Profile ============
const page1 = pages.addPage('skin-profile', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 6: Your Skin Profile',
computedValue: () => 'Let\'s understand your unique skin characteristics',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addRadioButton('skinType', {
label: 'What\'s your skin type?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'oily', name: '💧 Oily - Shiny T-zone, enlarged pores, prone to breakouts' },
{ id: 'dry', name: '🏜️ Dry - Tight feeling, flaky patches, dull appearance' },
{ id: 'combination', name: '⚖️ Combination - Oily T-zone, dry cheeks' },
{ id: 'sensitive', name: '🌸 Sensitive - Easily irritated, redness, reactions' },
{ id: 'normal', name: '✨ Normal - Balanced, few imperfections' }
],
onValueChange: (val) => setAnswer('skinType', val || '')
});
});
page1.addRow(row => {
row.addDropdown('age', {
label: 'What\'s your age range?',
isRequired: true,
options: [
{ id: 'teens', name: 'Under 20' },
{ id: '20s', name: '20-29' },
{ id: '30s', name: '30-39' },
{ id: '40s', name: '40-49' },
{ id: '50plus', name: '50+' }
],
placeholder: 'Select age range',
onValueChange: (val) => setAnswer('age', val || '')
});
});
// ============ PAGE 2: Skin Concerns ============
const page2 = pages.addPage('concerns', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 6: Your Skin Concerns',
computedValue: () => 'What issues would you like to address?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addSuggestionChips('concerns', {
label: 'Select your top skin concerns (up to 3)',
isRequired: true,
max: 3,
suggestions: [
{ id: 'acne', name: '🔴 Acne & Breakouts' },
{ id: 'aging', name: '⏳ Fine Lines & Wrinkles' },
{ id: 'dullness', name: '😶 Dullness & Uneven Tone' },
{ id: 'hyperpigmentation', name: '🌓 Dark Spots & Pigmentation' },
{ id: 'redness', name: '🌡️ Redness & Rosacea' },
{ id: 'dehydration', name: '💦 Dehydration' }
],
alignment: 'left',
onValueChange: (val) => setAnswer('concerns', val || [])
});
});
page2.addRow(row => {
row.addRadioButton('acneSeverity', {
label: 'If you have acne, how severe is it?',
orientation: 'horizontal',
isVisible: () => {
const concerns = (answers()['concerns'] as string[]) || [];
return concerns.includes('acne');
},
options: [
{ id: 'mild', name: 'Mild (occasional)' },
{ id: 'moderate', name: 'Moderate (regular)' },
{ id: 'severe', name: 'Severe (cystic)' }
],
onValueChange: (val) => setAnswer('acneSeverity', val || '')
});
});
// ============ PAGE 3: Current Routine ============
const page3 = pages.addPage('current-routine', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 6: Your Current Routine',
computedValue: () => 'Tell us about your existing skincare habits',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addMatrixQuestion('currentProducts', {
label: 'Which products do you currently use?',
rows: [
{ id: 'cleanser', label: 'Cleanser' },
{ id: 'toner', label: 'Toner/Essence' },
{ id: 'serum', label: 'Serum' },
{ id: 'moisturizer', label: 'Moisturizer' },
{ id: 'sunscreen', label: 'Sunscreen' },
{ id: 'exfoliant', label: 'Exfoliant' }
],
columns: [
{ id: 'never', label: 'Never' },
{ id: 'sometimes', label: 'Sometimes' },
{ id: 'daily', label: 'Daily' }
],
selectionMode: 'single',
striped: true,
fullWidth: true
});
});
page3.addRow(row => {
row.addRadioButton('routineTime', {
label: 'How much time can you dedicate to skincare?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'minimal', name: '⚡ 2-3 minutes (essentials only)' },
{ id: 'moderate', name: '🕐 5-10 minutes (standard routine)' },
{ id: 'thorough', name: '🧖 15-20 minutes (comprehensive)' },
{ id: 'extensive', name: '💆 20+ minutes (spa-level)' }
],
onValueChange: (val) => setAnswer('routineTime', val || '')
});
});
// ============ PAGE 4: Lifestyle & Environment ============
const page4 = pages.addPage('lifestyle', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 6: Lifestyle Factors',
computedValue: () => 'Environmental and lifestyle factors affect your skin',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addDropdown('climate', {
label: 'What\'s your climate like?',
isRequired: true,
options: [
{ id: 'humid-hot', name: '🌴 Hot & Humid' },
{ id: 'dry-hot', name: '🏜️ Hot & Dry' },
{ id: 'temperate', name: '🌤️ Temperate/Moderate' },
{ id: 'cold-dry', name: '❄️ Cold & Dry' },
{ id: 'varies', name: '🔄 Varies by Season' }
],
placeholder: 'Select your climate',
onValueChange: (val) => setAnswer('climate', val || '')
}, '1fr');
row.addDropdown('sunExposure', {
label: 'Daily sun exposure?',
isRequired: true,
options: [
{ id: 'minimal', name: 'Minimal (mostly indoors)' },
{ id: 'moderate', name: 'Moderate (some outdoor time)' },
{ id: 'high', name: 'High (work/exercise outdoors)' }
],
placeholder: 'Select exposure level',
onValueChange: (val) => setAnswer('sunExposure', val || '')
}, '1fr');
});
page4.addRow(row => {
row.addSuggestionChips('lifestyleFactors', {
label: 'Which apply to you?',
suggestions: [
{ id: 'stress', name: '😰 High stress' },
{ id: 'sleep', name: '😴 Poor sleep' },
{ id: 'diet', name: '🍕 Irregular diet' },
{ id: 'water', name: '💧 Low water intake' },
{ id: 'exercise', name: '🏃 Regular exercise' },
{ id: 'smoking', name: '🚬 Smoking' },
{ id: 'alcohol', name: '🍷 Frequent alcohol' },
{ id: 'makeup', name: '💄 Daily makeup' }
],
alignment: 'left',
onValueChange: (val) => setAnswer('lifestyleFactors', val || [])
});
});
// ============ PAGE 5: Budget & Preferences ============
const page5 = pages.addPage('preferences', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 6: Your Preferences',
computedValue: () => 'Help us match products to your budget and values',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addRadioButton('budget', {
label: 'What\'s your monthly skincare budget?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'budget', name: '💵 $50-100 (drugstore favorites)' },
{ id: 'moderate', name: '💰 $100-200 (mid-range brands)' },
{ id: 'premium', name: '💎 $200-400 (premium brands)' },
{ id: 'luxury', name: '👑 $400+ (luxury/professional)' }
],
onValueChange: (val) => setAnswer('budget', val || '')
});
});
page5.addRow(row => {
row.addSuggestionChips('preferences', {
label: 'Product preferences (select all that apply)',
suggestions: [
{ id: 'vegan', name: '🌱 Vegan' },
{ id: 'crueltyfree', name: '🐰 Cruelty-free' },
{ id: 'organic', name: '🍃 Organic' },
{ id: 'fragrance-free', name: '🚫 Fragrance-free' },
{ id: 'korean', name: '🇰🇷 K-beauty' },
{ id: 'clean', name: '✨ Clean beauty' }
],
alignment: 'left',
onValueChange: (val) => setAnswer('preferences', val || [])
});
});
// ============ PAGE 6: Results ============
const page6 = pages.addPage('results', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Step 6 of 6: Your Skincare Routine',
computedValue: () => 'Your personalized skincare recommendations',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addTextPanel('skinTypeResult', {
computedValue: () => `Your Skin Type: ${getSkinType().charAt(0).toUpperCase() + getSkinType().slice(1)}`,
customStyles: {
fontSize: '1.3rem',
fontWeight: '700',
textAlign: 'center',
color: '#ec4899',
padding: '15px',
background: 'linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%)',
borderRadius: '12px',
border: '2px solid #f9a8d4'
}
});
});
// Morning Routine
const morningSection = page6.addSubform('morningRoutine', {
title: '🌅 Morning Routine',
isCollapsible: true,
customStyles: {
marginTop: '1rem',
background: '#fffbeb',
borderRadius: '8px'
}
});
morningSection.addRow(row => {
row.addTextPanel('morningSteps', {
computedValue: () => {
const routine = getRecommendedRoutine();
return `1. Cleanser: ${routine.cleanser}\n2. Toner: ${routine.toner}\n3. Serum: ${routine.serum}\n4. Moisturizer: ${routine.moisturizer}\n5. Sunscreen: ${routine.spf}`;
},
customStyles: {
fontSize: '0.9rem',
whiteSpace: 'pre-line',
lineHeight: '1.8'
}
});
});
// Evening Routine
const eveningSection = page6.addSubform('eveningRoutine', {
title: '🌙 Evening Routine',
isCollapsible: true,
customStyles: {
marginTop: '1rem',
background: '#f0f9ff',
borderRadius: '8px'
}
});
eveningSection.addRow(row => {
row.addTextPanel('eveningSteps', {
computedValue: () => {
const routine = getRecommendedRoutine();
const treatments = getTargetedTreatments();
let steps = `1. Double cleanse (oil + ${routine.cleanser})\n2. Toner: ${routine.toner}\n3. Serum: ${routine.serum}\n4. Moisturizer: ${routine.moisturizer}`;
if (treatments.length > 0) {
steps += `\n\n💊 Targeted treatments:\n${treatments.map((t, i) => `• ${t}`).join('\n')}`;
}
return steps;
},
customStyles: {
fontSize: '0.9rem',
whiteSpace: 'pre-line',
lineHeight: '1.8'
}
});
});
// Budget estimate
page6.addRow(row => {
row.addTextPanel('budgetEstimate', {
label: '💰 Budget Estimate',
computedValue: () => getBudgetRange(),
customStyles: {
fontSize: '0.9rem',
textAlign: 'center',
padding: '12px',
background: '#ecfdf5',
borderRadius: '8px',
marginTop: '1rem'
}
});
});
// ============ PAGE 7: Lead Capture ============
const page7 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page7.addRow(row => {
row.addTextPanel('header7', {
label: 'Get Your Complete Skincare Guide',
computedValue: () => 'Receive your personalized routine with specific product recommendations',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page7.addSpacer({ height: '24px' });
page7.addRow(row => {
row.addTextbox('name', {
label: 'Your Name',
isRequired: true,
placeholder: 'Sarah Johnson'
}, '1fr');
row.addEmail('email', {
label: 'Email Address',
isRequired: true,
placeholder: 'sarah@email.com'
}, '1fr');
});
page7.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'guide', name: '📧 Send me my personalized skincare guide (PDF)', isRequired: true },
{ id: 'tips', name: '💡 Weekly skincare tips and product reviews' },
{ id: 'deals', name: '🏷️ Exclusive deals from partner brands' }
],
defaultValue: ['guide'],
orientation: 'vertical'
});
});
// ============ PDF REPORT ============
form.configurePdf('skincare-report', pdf => {
pdf.configure({
filename: 'your-skincare-routine.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '📄 Download Skincare Guide',
header: {
title: 'Your Personalized Skincare Routine',
subtitle: 'Custom recommendations for your unique skin'
},
footer: {
text: 'Generated by FormTs Skincare Quiz',
showPageNumbers: true
}
});
pdf.addSection('Your Skin Profile', section => {
section.addRow(row => {
row.addField('Skin Type', getSkinType().charAt(0).toUpperCase() + getSkinType().slice(1));
row.addField('Age Range', (answers()['age'] as string) || 'Not specified');
});
const concerns = (answers()['concerns'] as string[]) || [];
section.addRow(row => {
row.addField('Primary Concerns', concerns.join(', ') || 'None specified');
});
});
pdf.addSection('Morning Routine', section => {
const routine = getRecommendedRoutine();
section.addTable(
['Step', 'Product Type', 'Recommendation'],
[
['1', 'Cleanser', routine.cleanser],
['2', 'Toner', routine.toner],
['3', 'Serum', routine.serum],
['4', 'Moisturizer', routine.moisturizer],
['5', 'Sunscreen', routine.spf]
]
);
});
pdf.addSection('Evening Routine', section => {
const routine = getRecommendedRoutine();
section.addTable(
['Step', 'Product Type', 'Recommendation'],
[
['1', 'Oil Cleanser', 'Any oil-based cleanser for makeup removal'],
['2', 'Cleanser', routine.cleanser],
['3', 'Toner', routine.toner],
['4', 'Serum', routine.serum],
['5', 'Moisturizer', routine.moisturizer]
]
);
});
const treatments = getTargetedTreatments();
if (treatments.length > 0) {
pdf.addSection('Targeted Treatments', section => {
treatments.forEach(t => section.addText(`• ${t}`));
});
}
pdf.addSection('Weekly Extras', section => {
section.addText('• Exfoliate 2-3 times per week');
section.addText('• Face mask 1-2 times per week');
section.addText('• Eye cream morning and night');
});
});
// ============ SUBMIT BUTTON ============
form.configureSubmitButton({
label: () => '✨ Get My Skincare Guide'
});
form.configureSubmitBehavior({
sendToServer: true
});
}