export function csatDetailed(form: FormTs) {
// CSAT Comprehensive Survey - Multi-dimensional customer satisfaction
// Demonstrates: MatrixQuestion, StarRating x6, RatingScale, EmojiRating, SuggestionChips, conditional sections
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Customer Satisfaction Survey',
computedValue: () => 'Help us serve you better by sharing your experience',
customStyles: {
backgroundColor: '#0ea5e9',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Overall Satisfaction
// ============================================
const overallSection = form.addSubform('overallSection', {
title: 'Overall Satisfaction',
customStyles: () => {
const rating = overallSection.starRating('overallSatisfaction')?.value();
if (rating !== null && rating !== undefined) {
if (rating >= 4) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (rating >= 3) return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
}
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
overallSection.addRow(row => {
row.addStarRating('overallSatisfaction', {
label: 'How satisfied are you with your overall experience?',
maxStars: 5,
size: 'xl',
alignment: 'center',
showConfettiOnMax: true
});
});
overallSection.addRow(row => {
row.addEmojiRating('experienceMood', {
label: 'How would you describe your experience in one word?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// SECTION 2: Service Quality Matrix
// ============================================
const serviceSection = form.addSubform('serviceSection', {
title: 'Service Quality',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null,
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
serviceSection.addRow(row => {
row.addMatrixQuestion('serviceRatings', {
label: 'Please rate the following aspects of our service:',
rows: [
{ id: 'response', label: 'Response Time', description: 'How quickly we addressed your needs', isRequired: true },
{ id: 'knowledge', label: 'Staff Knowledge', description: 'Expertise and ability to help', isRequired: true },
{ id: 'courtesy', label: 'Courtesy & Professionalism', description: 'How you were treated', isRequired: true },
{ id: 'communication', label: 'Communication', description: 'Clarity and timeliness of updates', isRequired: false },
{ id: 'followup', label: 'Follow-up', description: 'Post-service care and attention', isRequired: false }
],
columns: [
{ id: '1', label: 'Very Poor' },
{ id: '2', label: 'Poor' },
{ id: '3', label: 'Average' },
{ id: '4', label: 'Good' },
{ id: '5', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 3: Product/Service Satisfaction
// ============================================
const productSection = form.addSubform('productSection', {
title: 'Product/Service Experience',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
productSection.addRow(row => {
row.addStarRating('productQuality', {
label: 'Product/Service Quality',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
row.addStarRating('easeOfUse', {
label: 'Ease of Use',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
});
productSection.addRow(row => {
row.addStarRating('reliability', {
label: 'Reliability & Consistency',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
row.addStarRating('valueForMoney', {
label: 'Value for Money',
maxStars: 5,
size: 'lg',
alignment: 'center'
}, '1fr');
});
// ============================================
// SECTION 4: Support Experience
// ============================================
const supportSection = form.addSubform('supportSection', {
title: 'Support Experience',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
supportSection.addRow(row => {
row.addRadioButton('contactedSupport', {
label: 'Did you contact our support team during this experience?',
options: [
{ id: 'yes', name: 'Yes, I contacted support' },
{ id: 'no', name: 'No, I did not need support' }
],
orientation: 'horizontal'
});
});
// Conditional support details
const supportDetails = supportSection.addSubform('supportDetails', {
isVisible: () => supportSection.radioButton('contactedSupport')?.value() === 'yes',
customStyles: { backgroundColor: '#f8fafc', padding: '16px', borderRadius: '8px', marginTop: '12px' }
});
supportDetails.addRow(row => {
row.addDropdown('supportChannel', {
label: 'How did you contact support?',
options: [
{ id: 'phone', name: 'Phone' },
{ id: 'email', name: 'Email' },
{ id: 'chat', name: 'Live Chat' },
{ id: 'social', name: 'Social Media' },
{ id: 'inperson', name: 'In-Person' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select channel'
}, '1fr');
row.addDropdown('issueResolved', {
label: 'Was your issue resolved?',
options: [
{ id: 'yes-first', name: 'Yes, on first contact' },
{ id: 'yes-multiple', name: 'Yes, after multiple contacts' },
{ id: 'partially', name: 'Partially resolved' },
{ id: 'no', name: 'No, still unresolved' }
],
placeholder: 'Select'
}, '1fr');
});
supportDetails.addRow(row => {
row.addRatingScale('supportEffort', {
preset: 'ces',
label: 'How easy was it to get the help you needed?',
lowLabel: 'Very Difficult',
highLabel: 'Very Easy',
alignment: 'center'
});
});
supportDetails.addRow(row => {
row.addStarRating('supportRating', {
label: 'Overall support experience rating',
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
// ============================================
// SECTION 5: Strengths & Improvements
// ============================================
const feedbackSection = form.addSubform('feedbackSection', {
title: 'Strengths & Areas for Improvement',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
// Show strengths for satisfied customers (4-5 stars)
const strengthsSubform = feedbackSection.addSubform('strengthsSubform', {
isVisible: () => {
const rating = overallSection.starRating('overallSatisfaction')?.value();
return rating !== null && rating !== undefined && rating >= 4;
},
customStyles: { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px' }
});
strengthsSubform.addRow(row => {
row.addSuggestionChips('strengths', {
label: 'What did we do well? (select up to 4)',
suggestions: [
{ id: 'quality', name: 'Quality' },
{ id: 'speed', name: 'Speed' },
{ id: 'price', name: 'Fair Pricing' },
{ id: 'support', name: 'Great Support' },
{ id: 'communication', name: 'Communication' },
{ id: 'reliability', name: 'Reliability' },
{ id: 'innovation', name: 'Innovation' },
{ id: 'convenience', name: 'Convenience' }
],
max: 4,
alignment: 'center'
});
});
// Show improvements for less satisfied customers (1-3 stars)
const improvementsSubform = feedbackSection.addSubform('improvementsSubform', {
isVisible: () => {
const rating = overallSection.starRating('overallSatisfaction')?.value();
return rating !== null && rating !== undefined && rating <= 3;
},
customStyles: { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' }
});
improvementsSubform.addRow(row => {
row.addSuggestionChips('improvements', {
label: 'What could we improve? (select all that apply)',
suggestions: [
{ id: 'quality', name: 'Product Quality' },
{ id: 'speed', name: 'Response Time' },
{ id: 'price', name: 'Pricing' },
{ id: 'support', name: 'Support Quality' },
{ id: 'communication', name: 'Communication' },
{ id: 'reliability', name: 'Reliability' },
{ id: 'usability', name: 'Ease of Use' },
{ id: 'availability', name: 'Availability' }
],
alignment: 'center'
});
});
feedbackSection.addSpacer();
feedbackSection.addRow(row => {
row.addTextarea('additionalComments', {
label: () => {
const rating = overallSection.starRating('overallSatisfaction')?.value();
if (rating !== null && rating !== undefined && rating >= 4) {
return 'Is there anything else you loved about your experience?';
}
return 'Please share more details about how we can improve';
},
placeholder: 'Your feedback helps us improve...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 6: Future Intent
// ============================================
const intentSection = form.addSubform('intentSection', {
title: 'Looking Forward',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
intentSection.addRow(row => {
row.addThumbRating('wouldReturn', {
label: 'Would you use our services again?',
showLabels: true,
upLabel: 'Yes, definitely',
downLabel: 'Probably not',
alignment: 'center',
size: 'lg'
}, '1fr');
row.addThumbRating('wouldRecommend', {
label: 'Would you recommend us to others?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center',
size: 'lg'
}, '1fr');
});
// ============================================
// SECTION 7: Contact Permission
// ============================================
const contactSection = form.addSubform('contactSection', {
title: 'Stay Connected',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
contactSection.addRow(row => {
row.addCheckbox('allowFollowup', {
label: 'You may contact me to discuss my feedback'
});
});
contactSection.addRow(row => {
row.addEmail('email', {
label: 'Email address',
placeholder: 'your@email.com',
isVisible: () => contactSection.checkbox('allowFollowup')?.value() === true,
isRequired: () => contactSection.checkbox('allowFollowup')?.value() === true
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Feedback Summary',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summary', {
computedValue: () => {
const overall = overallSection.starRating('overallSatisfaction')?.value();
const mood = overallSection.emojiRating('experienceMood')?.value();
const productQuality = productSection.starRating('productQuality')?.value();
const easeOfUse = productSection.starRating('easeOfUse')?.value();
const reliability = productSection.starRating('reliability')?.value();
const valueForMoney = productSection.starRating('valueForMoney')?.value();
const wouldReturn = intentSection.thumbRating('wouldReturn')?.value();
const wouldRecommend = intentSection.thumbRating('wouldRecommend')?.value();
const strengths = strengthsSubform.suggestionChips('strengths')?.value() || [];
const improvements = improvementsSubform.suggestionChips('improvements')?.value() || [];
if (overall === null || overall === undefined) return '';
const moodLabels: Record<string, string> = {
'very-bad': 'Very Unhappy',
'bad': 'Unhappy',
'neutral': 'Neutral',
'good': 'Happy',
'excellent': 'Very Happy'
};
let emoji = '';
if (overall >= 4) emoji = '🎉';
else if (overall >= 3) emoji = '🤔';
else emoji = '😟';
let summary = `${emoji} SATISFACTION SUMMARY\n`;
summary += `${'═'.repeat(28)}\n\n`;
summary += `Overall: ${'★'.repeat(overall)}${'☆'.repeat(5 - overall)} (${overall}/5)\n`;
if (mood) {
summary += `Mood: ${moodLabels[mood] || mood}\n`;
}
// Product ratings average
const productRatings = [productQuality, easeOfUse, reliability, valueForMoney].filter(r => r !== null && r !== undefined) as number[];
if (productRatings.length > 0) {
const avg = productRatings.reduce((a, b) => a + b, 0) / productRatings.length;
summary += `\nProduct Score: ${avg.toFixed(1)}/5\n`;
}
if (strengths.length > 0) {
summary += `\n✨ Strengths: ${strengths.length} selected`;
}
if (improvements.length > 0) {
summary += `\n⚠️ Improvements: ${improvements.length} selected`;
}
if (wouldReturn !== null || wouldRecommend !== null) {
summary += '\n\n';
if (wouldReturn) {
summary += `Return: ${wouldReturn === 'up' ? '👍 Yes' : '👎 No'}\n`;
}
if (wouldRecommend) {
summary += `Recommend: ${wouldRecommend === 'up' ? '👍 Yes' : '👎 No'}`;
}
}
return summary;
},
customStyles: () => {
const overall = overallSection.starRating('overallSatisfaction')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px'
};
if (overall !== null && overall !== undefined) {
if (overall >= 4) {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (overall >= 3) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
} else {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #0ea5e9' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => overallSection.starRating('overallSatisfaction')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback!',
message: 'Your detailed feedback helps us continuously improve our products and services. We truly appreciate you taking the time to share your experience with us.'
});
}