export function checkoutFeedback(form: FormTs) {
// Checkout Experience Feedback - E-commerce checkout optimization
// Demonstrates: RatingScale (CES), CheckboxList, RadioButton, StarRating, EmojiRating, Slider, MatrixQuestion, conditional sections
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Checkout Experience Feedback',
computedValue: () => 'Help us make checkout faster and easier',
customStyles: {
backgroundColor: '#059669',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Customer Effort Score
// ============================================
const cesSection = form.addSubform('cesSection', {
title: 'Checkout Effort',
customStyles: () => {
const score = cesSection.ratingScale('effortScore')?.value();
if (score && score >= 6) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (score && score >= 4) return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
if (score && score >= 1) return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
cesSection.addRow(row => {
row.addRatingScale('effortScore', {
preset: 'ces',
label: 'How easy was it to complete your checkout today?',
lowLabel: 'Very Difficult',
highLabel: 'Very Easy',
alignment: 'center',
isRequired: true
});
});
cesSection.addRow(row => {
row.addEmojiRating('checkoutMood', {
label: 'How did you feel during checkout?',
preset: 'effort',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// SECTION 2: Checkout Steps Rating
// ============================================
const stepsSection = form.addSubform('stepsSection', {
title: 'Checkout Steps',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null,
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
stepsSection.addRow(row => {
row.addMatrixQuestion('stepRatings', {
label: 'Rate each step of the checkout process:',
rows: [
{ id: 'cart', label: 'Shopping Cart Review', description: 'Reviewing items, quantities, prices', isRequired: true },
{ id: 'shipping', label: 'Shipping Information', description: 'Address entry, delivery options', isRequired: true },
{ id: 'payment', label: 'Payment', description: 'Payment method selection and entry', isRequired: true },
{ id: 'confirmation', label: 'Order Confirmation', description: 'Final review and placing order', isRequired: false }
],
columns: [
{ id: 'skip', label: 'N/A' },
{ id: '1', label: 'Frustrating' },
{ id: '2', label: 'Difficult' },
{ id: '3', label: 'OK' },
{ id: '4', label: 'Easy' },
{ id: '5', label: 'Seamless' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 3: Friction Points
// ============================================
const frictionSection = form.addSubform('frictionSection', {
title: 'Did You Experience Any Issues?',
isVisible: () => {
const score = cesSection.ratingScale('effortScore')?.value();
return score !== null && score !== undefined && score <= 5;
},
customStyles: { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' }
});
frictionSection.addRow(row => {
row.addCheckboxList('frictionPoints', {
label: 'What made checkout difficult? (select all that apply)',
options: [
{ id: 'too-many-steps', name: 'Too many steps/pages' },
{ id: 'slow-loading', name: 'Slow page loading' },
{ id: 'required-account', name: 'Required to create an account' },
{ id: 'form-errors', name: 'Confusing form validation errors' },
{ id: 'payment-failed', name: 'Payment method issues' },
{ id: 'shipping-options', name: 'Limited shipping options' },
{ id: 'shipping-cost', name: 'Unexpected shipping costs' },
{ id: 'promo-code', name: 'Promo code problems' },
{ id: 'mobile-issues', name: 'Mobile/touch issues' },
{ id: 'unclear-total', name: 'Unclear total price' },
{ id: 'security-concerns', name: 'Security concerns' },
{ id: 'address-issues', name: 'Address auto-fill problems' }
],
orientation: 'vertical'
});
});
frictionSection.addSpacer();
frictionSection.addRow(row => {
row.addTextarea('frictionDetails', {
label: 'Please describe any specific issues',
placeholder: 'Tell us what went wrong so we can fix it...',
rows: 2,
autoExpand: true
});
});
// ============================================
// SECTION 4: Smooth Experience (for high CES scores)
// ============================================
const smoothSection = form.addSubform('smoothSection', {
title: 'What Worked Well?',
isVisible: () => {
const score = cesSection.ratingScale('effortScore')?.value();
return score !== null && score !== undefined && score >= 5;
},
customStyles: { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' }
});
smoothSection.addRow(row => {
row.addCheckboxList('positivePoints', {
label: 'What made checkout easy? (select all that apply)',
options: [
{ id: 'fast', name: 'Fast and responsive' },
{ id: 'few-steps', name: 'Few steps to complete' },
{ id: 'guest-checkout', name: 'Guest checkout available' },
{ id: 'saved-info', name: 'Saved payment/address info' },
{ id: 'clear-progress', name: 'Clear progress indicator' },
{ id: 'multiple-payment', name: 'Multiple payment options' },
{ id: 'mobile-friendly', name: 'Mobile-friendly design' },
{ id: 'transparent-costs', name: 'Transparent pricing' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 5: Payment Experience
// ============================================
const paymentSection = form.addSubform('paymentSection', {
title: 'Payment Experience',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
paymentSection.addRow(row => {
row.addRadioButton('paymentMethod', {
label: 'Which payment method did you use?',
options: [
{ id: 'credit-card', name: 'Credit/Debit Card' },
{ id: 'paypal', name: 'PayPal' },
{ id: 'apple-pay', name: 'Apple Pay' },
{ id: 'google-pay', name: 'Google Pay' },
{ id: 'bank-transfer', name: 'Bank Transfer' },
{ id: 'buy-now-pay-later', name: 'Buy Now Pay Later' },
{ id: 'other', name: 'Other' }
],
orientation: 'vertical'
}, '1fr');
row.addStarRating('paymentEase', {
label: 'Payment process ease',
maxStars: 5,
size: 'lg',
alignment: 'left'
}, '1fr');
});
paymentSection.addRow(row => {
row.addThumbRating('paymentSecure', {
label: 'Did you feel the payment was secure?',
showLabels: true,
upLabel: 'Yes, felt secure',
downLabel: 'Had concerns',
alignment: 'center',
size: 'lg'
});
});
// ============================================
// SECTION 6: Speed & Performance
// ============================================
const speedSection = form.addSubform('speedSection', {
title: 'Speed & Performance',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
speedSection.addRow(row => {
row.addSlider('perceivedSpeed', {
label: 'How fast did checkout feel?',
min: 0,
max: 100,
step: 10,
unit: '',
showValue: true,
defaultValue: 50
});
});
speedSection.addRow(row => {
row.addTextPanel('speedLabels', {
computedValue: () => {
const speed = speedSection.slider('perceivedSpeed')?.value();
if (speed === null || speed === undefined) return 'Move the slider to rate speed';
if (speed <= 20) return 'Very Slow - significant wait times';
if (speed <= 40) return 'Slow - noticeable delays';
if (speed <= 60) return 'Average - acceptable speed';
if (speed <= 80) return 'Fast - smooth experience';
return 'Lightning Fast - instant responses';
},
customStyles: () => {
const speed = speedSection.slider('perceivedSpeed')?.value();
const baseStyles = {
textAlign: 'center',
padding: '8px 16px',
borderRadius: '4px',
fontSize: '14px'
};
if (speed && speed >= 60) return { ...baseStyles, backgroundColor: '#d1fae5', color: '#065f46' };
if (speed && speed >= 40) return { ...baseStyles, backgroundColor: '#fef3c7', color: '#92400e' };
if (speed && speed >= 1) return { ...baseStyles, backgroundColor: '#fee2e2', color: '#991b1b' };
return { ...baseStyles, backgroundColor: '#f1f5f9', color: '#475569' };
}
});
});
speedSection.addRow(row => {
row.addDropdown('device', {
label: 'Device used for checkout',
options: [
{ id: 'desktop', name: 'Desktop/Laptop' },
{ id: 'mobile', name: 'Mobile Phone' },
{ id: 'tablet', name: 'Tablet' }
],
placeholder: 'Select device'
}, '1fr');
row.addDropdown('checkoutTime', {
label: 'Approximate checkout time',
options: [
{ id: 'under-1', name: 'Under 1 minute' },
{ id: '1-3', name: '1-3 minutes' },
{ id: '3-5', name: '3-5 minutes' },
{ id: '5-10', name: '5-10 minutes' },
{ id: 'over-10', name: 'Over 10 minutes' }
],
placeholder: 'Select time'
}, '1fr');
});
// ============================================
// SECTION 7: Recommendations
// ============================================
const recommendSection = form.addSubform('recommendSection', {
title: 'Final Thoughts',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
recommendSection.addRow(row => {
row.addThumbRating('wouldShopAgain', {
label: 'Would the checkout experience encourage you to shop here again?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center',
size: 'lg'
});
});
recommendSection.addRow(row => {
row.addRatingScale('overallSatisfaction', {
preset: 'satisfaction',
label: 'Overall checkout satisfaction',
lowLabel: 'Very Dissatisfied',
highLabel: 'Very Satisfied',
alignment: 'center'
});
});
recommendSection.addSpacer();
recommendSection.addRow(row => {
row.addTextarea('suggestions', {
label: 'How could we improve checkout?',
placeholder: 'Share your ideas for making checkout better...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Feedback Summary',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const effortScore = cesSection.ratingScale('effortScore')?.value();
const mood = cesSection.emojiRating('checkoutMood')?.value();
const frictions = frictionSection.checkboxList('frictionPoints')?.value() || [];
const positives = smoothSection.checkboxList('positivePoints')?.value() || [];
const paymentEase = paymentSection.starRating('paymentEase')?.value();
const speed = speedSection.slider('perceivedSpeed')?.value();
const wouldShop = recommendSection.thumbRating('wouldShopAgain')?.value();
const satisfaction = recommendSection.ratingScale('overallSatisfaction')?.value();
if (!effortScore) return '';
const moodLabels: Record<string, string> = {
'very-hard': 'Frustrated',
'hard': 'Struggled',
'neutral': 'Neutral',
'easy': 'Comfortable',
'very-easy': 'Delighted'
};
let cesCategory = 'Difficult';
if (effortScore >= 6) cesCategory = 'Easy';
else if (effortScore >= 4) cesCategory = 'Moderate';
let summary = `CHECKOUT FEEDBACK\n`;
summary += `${'═'.repeat(25)}\n\n`;
summary += `Effort Score: ${effortScore}/7 (${cesCategory})\n`;
if (mood) {
summary += `Experience: ${moodLabels[mood] || mood}\n`;
}
if (paymentEase) {
summary += `Payment Ease: ${'★'.repeat(paymentEase)}${'☆'.repeat(5 - paymentEase)}\n`;
}
if (speed !== null && speed !== undefined) {
summary += `Perceived Speed: ${speed}%\n`;
}
if (frictions.length > 0) {
summary += `\n⚠️ Issues encountered: ${frictions.length}\n`;
}
if (positives.length > 0) {
summary += `✅ Positives noted: ${positives.length}\n`;
}
if (satisfaction) {
summary += `\nSatisfaction: ${satisfaction}/5\n`;
}
if (wouldShop) {
const emoji = wouldShop === 'up' ? '👍' : '👎';
summary += `${emoji} Shop again: ${wouldShop === 'up' ? 'Yes' : 'Unlikely'}`;
}
return summary;
},
customStyles: () => {
const score = cesSection.ratingScale('effortScore')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px'
};
if (score && score >= 6) {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (score && score >= 4) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
} else if (score && score >= 1) {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #059669' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback!',
message: 'Your input helps us create a smoother checkout experience for everyone. Happy shopping!'
});
}