export function communityPartnerSurvey(form: FormTs) {
// Community Partner Feedback Survey
// Demonstrates: NPS, MatrixQuestion, StarRating, EmojiRating, dynamic styling, conditional visibility
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Community Partner Feedback Survey',
computedValue: () => 'Your partnership matters. Help us strengthen our collaboration.',
customStyles: {
backgroundColor: '#059669',
color: 'white',
padding: '28px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Partner Information
// ============================================
const partnerInfo = form.addSubform('partnerInfo', {
title: 'Partner Information'
});
partnerInfo.addRow(row => {
row.addTextbox('organizationName', {
label: 'Organization Name',
placeholder: 'Enter your organization name',
isRequired: true
}, '1fr');
row.addDropdown('partnershipType', {
label: 'Partnership Type',
options: [
{ id: 'funding', name: 'Funding Partner' },
{ id: 'program', name: 'Program Delivery Partner' },
{ id: 'advocacy', name: 'Advocacy Partner' },
{ id: 'resource', name: 'Resource Sharing Partner' },
{ id: 'strategic', name: 'Strategic Alliance' },
{ id: 'community', name: 'Community Organization' }
],
placeholder: 'Select partnership type',
isRequired: true
}, '1fr');
});
partnerInfo.addRow(row => {
row.addDropdown('partnershipDuration', {
label: 'How long have you been our partner?',
options: [
{ id: 'less-1', name: 'Less than 1 year' },
{ id: '1-2', name: '1-2 years' },
{ id: '3-5', name: '3-5 years' },
{ id: '5-plus', name: 'More than 5 years' }
],
isRequired: true
});
});
// ============================================
// SECTION 2: Partnership NPS
// ============================================
const npsSection = form.addSubform('npsSection', {
title: 'Partnership Recommendation',
customStyles: () => {
const category = npsSection.ratingScale('partnerNps')?.npsCategory();
if (category === 'promoter') return { backgroundColor: '#d1fae5', padding: '20px', borderRadius: '10px' };
if (category === 'passive') return { backgroundColor: '#fef3c7', padding: '20px', borderRadius: '10px' };
if (category === 'detractor') return { backgroundColor: '#fee2e2', padding: '20px', borderRadius: '10px' };
return { padding: '20px', borderRadius: '10px', border: '1px dashed #d1d5db' };
}
});
npsSection.addRow(row => {
row.addRatingScale('partnerNps', {
preset: 'nps',
label: 'How likely are you to recommend partnering with us to other organizations?',
showCategoryLabel: true,
showSegmentColors: true,
showConfettiOnPromoter: true,
isRequired: true
});
});
npsSection.addSpacer({ height: '15px' });
npsSection.addRow(row => {
row.addTextarea('npsReason', {
label: () => {
const category = npsSection.ratingScale('partnerNps')?.npsCategory();
if (category === 'promoter') return 'What makes our partnership valuable to recommend?';
if (category === 'passive') return 'What would make you more enthusiastic about our partnership?';
if (category === 'detractor') return 'What concerns would you share with others about our partnership?';
return 'Please share your thoughts';
},
placeholder: () => {
const category = npsSection.ratingScale('partnerNps')?.npsCategory();
if (category === 'promoter') return 'Share what makes our collaboration stand out...';
if (category === 'passive') return 'What improvements would elevate our partnership...';
if (category === 'detractor') return 'Help us understand the challenges you face...';
return 'Your feedback helps us improve...';
},
rows: 3,
autoExpand: true,
isVisible: () => npsSection.ratingScale('partnerNps')?.value() !== null && npsSection.ratingScale('partnerNps')?.value() !== undefined
});
});
// ============================================
// SECTION 3: Partnership Aspects Matrix
// ============================================
const aspectsSection = form.addSubform('aspectsSection', {
title: 'Partnership Aspects Evaluation',
isVisible: () => npsSection.ratingScale('partnerNps')?.value() !== null && npsSection.ratingScale('partnerNps')?.value() !== undefined
});
aspectsSection.addRow(row => {
row.addMatrixQuestion('partnershipMatrix', {
label: 'Please rate the following aspects of our partnership:',
rows: [
{ id: 'communication', label: 'Communication Quality', description: 'Clarity, timeliness, responsiveness', isRequired: true },
{ id: 'alignment', label: 'Goal Alignment', description: 'Shared objectives and vision', isRequired: true },
{ id: 'resources', label: 'Resource Sharing', description: 'Sharing of tools, expertise, and assets', isRequired: true },
{ id: 'support', label: 'Mutual Support', description: 'Assistance during challenges', isRequired: true },
{ id: 'impact', label: 'Collective Impact', description: 'Joint achievements and outcomes', isRequired: true },
{ id: 'trust', label: 'Trust & Transparency', description: 'Openness and reliability', isRequired: true }
],
columns: [
{ id: '1', label: 'Poor' },
{ id: '2', label: 'Fair' },
{ id: '3', label: 'Good' },
{ id: '4', label: 'Very Good' },
{ id: '5', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 4: Relationship Quality
// ============================================
const relationshipSection = form.addSubform('relationshipSection', {
title: 'Relationship Quality',
isVisible: () => aspectsSection.matrixQuestion('partnershipMatrix')?.areAllRequiredRowsAnswered() === true,
customStyles: { backgroundColor: '#f0fdf4', padding: '20px', borderRadius: '10px' }
});
relationshipSection.addRow(row => {
row.addEmojiRating('relationshipFeel', {
label: 'How would you describe your overall feeling about this partnership?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
relationshipSection.addRow(row => {
row.addStarRating('overallRating', {
label: 'Overall Partnership Rating',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'center',
showConfettiOnMax: true
}, '1fr');
row.addStarRating('valueDelivered', {
label: 'Value Delivered to Your Organization',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'center'
}, '1fr');
});
// ============================================
// SECTION 5: Improvement Areas (for lower scores)
// ============================================
const improvementSection = form.addSubform('improvementSection', {
title: 'Areas for Improvement',
isVisible: () => {
const nps = npsSection.ratingScale('partnerNps')?.value();
return nps !== null && nps !== undefined && nps <= 7;
},
customStyles: { backgroundColor: '#fefce8', padding: '20px', borderRadius: '10px' }
});
improvementSection.addRow(row => {
row.addCheckboxList('improvementAreas', {
label: 'Which areas need the most improvement? (Select all that apply)',
options: [
{ id: 'communication', name: 'Communication frequency and quality' },
{ id: 'response', name: 'Response time to inquiries' },
{ id: 'resources', name: 'Resource and information sharing' },
{ id: 'coordination', name: 'Project coordination' },
{ id: 'recognition', name: 'Partner recognition and visibility' },
{ id: 'reporting', name: 'Progress reporting and transparency' },
{ id: 'support', name: 'Support during challenges' },
{ id: 'alignment', name: 'Strategic alignment' }
],
orientation: 'vertical'
});
});
improvementSection.addSpacer({ height: '15px' });
improvementSection.addRow(row => {
row.addTextarea('improvementDetails', {
label: 'Please share specific suggestions for improvement:',
placeholder: 'Your detailed feedback helps us create actionable improvements...',
rows: 4,
autoExpand: true
});
});
// ============================================
// SECTION 6: Strengths (for promoters)
// ============================================
const strengthsSection = form.addSubform('strengthsSection', {
title: 'Partnership Strengths',
isVisible: () => {
const nps = npsSection.ratingScale('partnerNps')?.value();
return nps !== null && nps !== undefined && nps >= 8;
},
customStyles: { backgroundColor: '#ecfdf5', padding: '20px', borderRadius: '10px' }
});
strengthsSection.addRow(row => {
row.addCheckboxList('strengthAreas', {
label: 'What do you value most about this partnership? (Select all that apply)',
options: [
{ id: 'mission', name: 'Shared mission and values' },
{ id: 'impact', name: 'Measurable community impact' },
{ id: 'collaboration', name: 'Collaborative approach' },
{ id: 'innovation', name: 'Innovation and creativity' },
{ id: 'reliability', name: 'Reliability and follow-through' },
{ id: 'flexibility', name: 'Flexibility and adaptability' },
{ id: 'expertise', name: 'Expertise and knowledge sharing' },
{ id: 'network', name: 'Network and connections' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 7: Future Collaboration
// ============================================
const futureSection = form.addSubform('futureSection', {
title: 'Future Collaboration',
isVisible: () => relationshipSection.emojiRating('relationshipFeel')?.value() !== null && relationshipSection.emojiRating('relationshipFeel')?.value() !== undefined
});
futureSection.addRow(row => {
row.addThumbRating('continuePartnership', {
label: 'Would you like to continue this partnership?',
showLabels: true,
upLabel: 'Yes, definitely',
downLabel: 'Not sure / No',
size: 'lg',
alignment: 'center'
});
});
futureSection.addRow(row => {
row.addCheckboxList('futureInterests', {
label: 'What future collaboration opportunities interest you?',
options: [
{ id: 'joint-programs', name: 'Joint program development' },
{ id: 'co-funding', name: 'Co-funding opportunities' },
{ id: 'advocacy', name: 'Advocacy campaigns' },
{ id: 'research', name: 'Research collaborations' },
{ id: 'events', name: 'Co-hosted events' },
{ id: 'training', name: 'Capacity building & training' }
],
orientation: 'vertical',
isVisible: () => futureSection.thumbRating('continuePartnership')?.value() === 'up'
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Feedback Summary',
isVisible: () => relationshipSection.starRating('overallRating')?.value() !== null && relationshipSection.starRating('overallRating')?.value() !== undefined
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const orgName = partnerInfo.textbox('organizationName')?.value() || 'Your Organization';
const partnerType = partnerInfo.dropdown('partnershipType')?.value();
const nps = npsSection.ratingScale('partnerNps')?.value();
const category = npsSection.ratingScale('partnerNps')?.npsCategory();
const overall = relationshipSection.starRating('overallRating')?.value();
const feeling = relationshipSection.emojiRating('relationshipFeel')?.value();
const continueChoice = futureSection.thumbRating('continuePartnership')?.value();
if (nps === null || nps === undefined) return '';
const partnerTypeLabels: Record<string, string> = {
'funding': 'Funding Partner',
'program': 'Program Delivery Partner',
'advocacy': 'Advocacy Partner',
'resource': 'Resource Sharing Partner',
'strategic': 'Strategic Alliance',
'community': 'Community Organization'
};
const feelingLabels: Record<string, string> = {
'very-bad': 'Very Dissatisfied',
'bad': 'Dissatisfied',
'neutral': 'Neutral',
'good': 'Satisfied',
'excellent': 'Very Satisfied'
};
let emoji = category === 'promoter' ? '🤝' : category === 'passive' ? '🤔' : '⚠️';
let summary = `${emoji} Partnership Feedback Summary\n`;
summary += `${'═'.repeat(35)}\n\n`;
summary += `🏢 Organization: ${orgName}\n`;
if (partnerType) summary += `📋 Type: ${partnerTypeLabels[partnerType] || partnerType}\n`;
summary += `\n📊 NPS Score: ${nps}/10 (${category?.charAt(0).toUpperCase()}${category?.slice(1)})\n`;
if (overall) summary += `⭐ Overall Rating: ${overall}/5 stars\n`;
if (feeling) summary += `💭 Feeling: ${feelingLabels[feeling] || feeling}\n`;
if (continueChoice) summary += `\n🔮 Continue Partnership: ${continueChoice === 'up' ? 'Yes' : 'Uncertain'}\n`;
return summary;
},
customStyles: () => {
const category = npsSection.ratingScale('partnerNps')?.npsCategory();
const baseStyles = {
padding: '20px',
borderRadius: '10px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (category === 'promoter') {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #059669' };
} else if (category === 'passive') {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
} else if (category === 'detractor') {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
return baseStyles;
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Partnership Feedback',
isVisible: () => relationshipSection.starRating('overallRating')?.value() !== null && relationshipSection.starRating('overallRating')?.value() !== undefined
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Partnership!',
message: 'Your feedback is invaluable in strengthening our collaboration. We review every response and are committed to making our partnership even more impactful. Together, we create lasting community change.'
});
}