export function legalServicesFeedbackSurvey(form: FormTs) {
// Legal Services Feedback Form - Professional attorney/law firm rating
// Demonstrates: MatrixQuestion, StarRating, RatingScale (NPS), Slider, Dropdown, dynamic styling
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Legal Services Feedback',
computedValue: () => 'Your feedback helps us maintain the highest standards of legal service. All responses are confidential.',
customStyles: {
backgroundColor: '#1e3a5f',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Case Information
// ============================================
const caseSection = form.addSubform('caseSection', {
title: 'About Your Case'
});
caseSection.addRow(row => {
row.addDropdown('practiceArea', {
label: 'Practice Area',
options: [
{ id: 'corporate', name: 'Corporate & Business Law' },
{ id: 'litigation', name: 'Litigation & Disputes' },
{ id: 'real-estate', name: 'Real Estate' },
{ id: 'family', name: 'Family Law' },
{ id: 'estate', name: 'Estate Planning & Probate' },
{ id: 'employment', name: 'Employment Law' },
{ id: 'ip', name: 'Intellectual Property' },
{ id: 'criminal', name: 'Criminal Defense' },
{ id: 'immigration', name: 'Immigration' },
{ id: 'tax', name: 'Tax Law' },
{ id: 'other', name: 'Other' }
],
isRequired: true,
placeholder: 'Select practice area...'
}, '1fr');
row.addRadioButton('caseOutcome', {
label: 'Case Outcome',
options: [
{ id: 'favorable', name: 'Favorable' },
{ id: 'mixed', name: 'Mixed' },
{ id: 'unfavorable', name: 'Unfavorable' },
{ id: 'ongoing', name: 'Still ongoing' }
],
orientation: 'vertical',
isRequired: true
}, '1fr');
});
// ============================================
// SECTION 2: Attorney Expertise
// ============================================
const expertiseSection = form.addSubform('expertiseSection', {
title: 'Attorney Expertise',
customStyles: () => {
const matrix = expertiseSection.matrixQuestion('expertiseMatrix')?.value();
if (!matrix) return { backgroundColor: '#f8fafc', padding: '16px', borderRadius: '8px' };
const values = Object.values(matrix) as string[];
const avgScore = values.reduce((acc, val) => {
const scoreMap: Record<string, number> = { 'excellent': 5, 'good': 4, 'adequate': 3, 'poor': 2, 'very-poor': 1 };
return acc + (scoreMap[val] || 0);
}, 0) / (values.length || 1);
if (avgScore >= 4) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (avgScore <= 2.5) return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
}
});
expertiseSection.addRow(row => {
row.addMatrixQuestion('expertiseMatrix', {
label: 'Please rate your attorney on the following:',
rows: [
{ id: 'knowledge', label: 'Legal knowledge & expertise', isRequired: true },
{ id: 'strategy', label: 'Case strategy & advice', isRequired: true },
{ id: 'preparation', label: 'Preparation & attention to detail', isRequired: true },
{ id: 'courtroom', label: 'Courtroom/negotiation skills', isRequired: false },
{ id: 'outcomes', label: 'Ability to achieve results', isRequired: true }
],
columns: [
{ id: 'excellent', label: 'Excellent' },
{ id: 'good', label: 'Good' },
{ id: 'adequate', label: 'Adequate' },
{ id: 'poor', label: 'Poor' },
{ id: 'very-poor', label: 'Very Poor' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 3: Communication Quality
// ============================================
const communicationSection = form.addSubform('communicationSection', {
title: 'Communication & Responsiveness'
});
communicationSection.addRow(row => {
row.addStarRating('communicationRating', {
label: 'How would you rate overall communication quality?',
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
communicationSection.addSpacer({ height: '16px' });
communicationSection.addRow(row => {
row.addMatrixQuestion('communicationMatrix', {
label: 'Rate specific communication aspects:',
rows: [
{ id: 'responsiveness', label: 'Response time to calls/emails', isRequired: true },
{ id: 'clarity', label: 'Clarity of legal explanations', isRequired: true },
{ id: 'updates', label: 'Proactive case updates', isRequired: true },
{ id: 'availability', label: 'Availability for meetings', isRequired: false }
],
columns: [
{ id: 'excellent', label: 'Excellent' },
{ id: 'good', label: 'Good' },
{ id: 'adequate', label: 'Adequate' },
{ id: 'poor', label: 'Poor' }
],
striped: true,
fullWidth: true,
isVisible: () => (communicationSection.starRating('communicationRating')?.value() ?? 0) > 0
});
});
// ============================================
// SECTION 4: Billing & Value
// ============================================
const billingSection = form.addSubform('billingSection', {
title: 'Billing & Value',
isVisible: () => caseSection.radioButton('caseOutcome')?.value() !== null
});
billingSection.addRow(row => {
row.addSlider('valueForMoney', {
label: 'How would you rate the value for money?',
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5
}, '1fr');
row.addThumbRating('billingTransparency', {
label: 'Was billing transparent and predictable?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
size: 'lg',
alignment: 'center'
}, '1fr');
});
billingSection.addSpacer({ height: '16px' });
billingSection.addRow(row => {
row.addRadioButton('billingFormat', {
label: 'Which billing format did you use?',
options: [
{ id: 'hourly', name: 'Hourly billing' },
{ id: 'flat-fee', name: 'Flat fee' },
{ id: 'contingency', name: 'Contingency' },
{ id: 'retainer', name: 'Retainer' },
{ id: 'mixed', name: 'Mixed/Other' }
],
orientation: 'horizontal'
});
});
// Billing concerns follow-up
billingSection.addSpacer();
billingSection.addRow(row => {
row.addTextarea('billingConcerns', {
label: () => {
const transparency = billingSection.thumbRating('billingTransparency')?.value();
if (transparency === 'down') return "What billing issues did you experience?";
return 'Any comments on billing?';
},
placeholder: 'Share any billing feedback...',
rows: 2,
isVisible: () => {
const value = billingSection.slider('valueForMoney')?.value();
const transparency = billingSection.thumbRating('billingTransparency')?.value();
return (value !== null && value !== undefined && value < 6) || transparency === 'down';
}
});
});
// ============================================
// SECTION 5: Overall Satisfaction & NPS
// ============================================
const satisfactionSection = form.addSubform('satisfactionSection', {
title: 'Overall Satisfaction',
customStyles: () => {
const npsScore = satisfactionSection.ratingScale('npsScore')?.value();
const category = satisfactionSection.ratingScale('npsScore')?.npsCategory();
if (category === 'promoter') return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (category === 'detractor') return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
if (category === 'passive') return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
return { backgroundColor: '#f0f9ff', padding: '16px', borderRadius: '8px' };
}
});
satisfactionSection.addRow(row => {
row.addRatingScale('npsScore', {
preset: 'nps',
label: 'How likely are you to recommend our firm to others needing legal services?',
showCategoryLabel: true,
showSegmentColors: true,
showConfettiOnPromoter: true,
isRequired: true
});
});
satisfactionSection.addSpacer({ height: '20px' });
satisfactionSection.addRow(row => {
row.addEmojiRating('overallFeeling', {
label: 'How do you feel about your experience with our firm?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// SECTION 6: Detailed Feedback
// ============================================
const feedbackSection = form.addSubform('feedbackSection', {
title: 'Additional Feedback',
isVisible: () => satisfactionSection.ratingScale('npsScore')?.value() !== null
});
feedbackSection.addRow(row => {
row.addTextarea('npsReason', {
label: () => {
const category = satisfactionSection.ratingScale('npsScore')?.npsCategory();
switch (category) {
case 'promoter': return "Thank you! What made your experience exceptional?";
case 'passive': return "What could we have done to earn a higher rating?";
case 'detractor': return "We're sorry to hear that. What went wrong?";
default: return 'Please share your thoughts';
}
},
placeholder: 'Your detailed feedback helps us improve...',
rows: 3,
autoExpand: true
});
});
feedbackSection.addSpacer();
feedbackSection.addRow(row => {
row.addCheckbox('canUseAsTestimonial', {
label: 'You may use my feedback as a testimonial (with approval)',
isVisible: () => satisfactionSection.ratingScale('npsScore')?.npsCategory() === 'promoter'
});
});
// ============================================
// SECTION 7: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Feedback Summary',
isVisible: () => {
const nps = satisfactionSection.ratingScale('npsScore')?.value();
const practiceArea = caseSection.dropdown('practiceArea')?.value();
return nps !== null && practiceArea !== null;
}
});
summarySection.addRow(row => {
row.addTextPanel('summary', {
computedValue: () => {
const practiceArea = caseSection.dropdown('practiceArea')?.value();
const outcome = caseSection.radioButton('caseOutcome')?.value();
const commRating = communicationSection.starRating('communicationRating')?.value();
const nps = satisfactionSection.ratingScale('npsScore')?.value();
const category = satisfactionSection.ratingScale('npsScore')?.npsCategory();
const value = billingSection.slider('valueForMoney')?.value();
const feeling = satisfactionSection.emojiRating('overallFeeling')?.value();
if (!practiceArea || nps === null || nps === undefined) return '';
const practiceLabels: Record<string, string> = {
'corporate': 'Corporate & Business',
'litigation': 'Litigation',
'real-estate': 'Real Estate',
'family': 'Family Law',
'estate': 'Estate Planning',
'employment': 'Employment',
'ip': 'Intellectual Property',
'criminal': 'Criminal Defense',
'immigration': 'Immigration',
'tax': 'Tax Law',
'other': 'Other'
};
const outcomeLabels: Record<string, string> = {
'favorable': 'Favorable',
'mixed': 'Mixed',
'unfavorable': 'Unfavorable',
'ongoing': 'Ongoing'
};
const feelingLabels: Record<string, string> = {
'very-bad': 'Very Dissatisfied',
'bad': 'Dissatisfied',
'neutral': 'Neutral',
'good': 'Satisfied',
'excellent': 'Very Satisfied'
};
let emoji = '⚖️';
if (category === 'promoter') emoji = '🏆';
else if (category === 'detractor') emoji = '⚠️';
let summary = `${emoji} Legal Services Feedback\n`;
summary += `${'═'.repeat(30)}\n\n`;
summary += `Practice Area: ${practiceLabels[practiceArea] || practiceArea}\n`;
if (outcome) summary += `Case Outcome: ${outcomeLabels[outcome] || outcome}\n`;
summary += `\n`;
if (commRating) summary += `Communication: ${'★'.repeat(commRating)}${'☆'.repeat(5 - commRating)}\n`;
if (value) summary += `Value for Money: ${value}/10\n`;
summary += `NPS Score: ${nps}/10 (${category?.charAt(0).toUpperCase()}${category?.slice(1)})\n`;
if (feeling) summary += `Overall Feeling: ${feelingLabels[feeling] || feeling}`;
return summary;
},
customStyles: () => {
const category = satisfactionSection.ratingScale('npsScore')?.npsCategory();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (category === 'promoter') {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (category === 'detractor') {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => satisfactionSection.ratingScale('npsScore')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback',
message: 'Your insights help us maintain the highest standards of legal service. We appreciate your time and trust in our firm.'
});
}