export function farmVisitFeedbackForm(form: FormTs) {
// Farm Visit/Agritourism Feedback - Visitor experience at farms and agricultural attractions
// Demonstrates: EmojiRating, StarRating, MatrixQuestion, CheckboxList, conditional sections
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Farm Visit Feedback',
computedValue: () => 'Thank you for visiting! We\'d love to hear about your farm experience.',
customStyles: {
backgroundColor: '#16a34a',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Visit Information
// ============================================
const visitSection = form.addSubform('visit', {
title: 'About Your Visit'
});
visitSection.addRow(row => {
row.addDropdown('visitType', {
label: 'What type of visit was this?',
options: [
{ id: 'day-tour', name: 'Day Tour/Visit' },
{ id: 'upick', name: 'U-Pick/Pick-Your-Own' },
{ id: 'farm-stay', name: 'Farm Stay/Overnight' },
{ id: 'event', name: 'Special Event (wedding, festival, etc.)' },
{ id: 'educational', name: 'Educational Program/School Trip' },
{ id: 'dining', name: 'Farm-to-Table Dining' },
{ id: 'tasting', name: 'Wine/Cider Tasting' },
{ id: 'petting-zoo', name: 'Petting Zoo/Animal Experience' },
{ id: 'other', name: 'Other' }
],
isRequired: true,
placeholder: 'Select visit type'
}, '1fr');
row.addDatepicker('visitDate', {
label: 'Date of Visit',
maxDate: () => new Date().toISOString()
}, '200px');
});
visitSection.addRow(row => {
row.addDropdown('groupType', {
label: 'Who did you visit with?',
options: [
{ id: 'solo', name: 'Solo' },
{ id: 'couple', name: 'Couple' },
{ id: 'family-kids', name: 'Family with children' },
{ id: 'family-adults', name: 'Family (adults only)' },
{ id: 'friends', name: 'Friends group' },
{ id: 'school', name: 'School group' },
{ id: 'corporate', name: 'Corporate/Team event' },
{ id: 'other', name: 'Other' }
]
}, '1fr');
row.addInteger('groupSize', {
label: 'Group Size',
min: 1,
max: 100,
placeholder: 'Number of people'
}, '150px');
});
visitSection.addRow(row => {
row.addRadioButton('firstVisit', {
label: 'Is this your first visit to our farm?',
options: [
{ id: 'yes', name: 'Yes, first time' },
{ id: 'no', name: 'No, I\'ve been before' }
],
orientation: 'horizontal'
});
});
// ============================================
// SECTION 2: Activities
// ============================================
const activitiesSection = form.addSubform('activities', {
title: 'Activities & Experiences',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null
});
activitiesSection.addRow(row => {
row.addCheckboxList('activitiesEnjoyed', {
label: 'Which activities did you participate in?',
options: () => {
const visitType = visitSection.dropdown('visitType')?.value();
const baseActivities = [
{ id: 'tour', name: 'Farm tour' },
{ id: 'animals', name: 'Animal encounters' },
{ id: 'hayride', name: 'Hayride/Wagon ride' },
{ id: 'shopping', name: 'Farm store shopping' },
{ id: 'cafe', name: 'Cafe/Restaurant' }
];
if (visitType === 'upick') {
return [
{ id: 'picking', name: 'Fruit/vegetable picking' },
...baseActivities,
{ id: 'weighing', name: 'Weighing & checkout' }
];
} else if (visitType === 'tasting') {
return [
{ id: 'tasting', name: 'Wine/cider tasting' },
{ id: 'tour', name: 'Cellar/production tour' },
{ id: 'pairing', name: 'Food pairing' },
{ id: 'shopping', name: 'Shop/purchasing' },
{ id: 'outdoor', name: 'Outdoor seating area' }
];
} else if (visitType === 'educational') {
return [
{ id: 'tour', name: 'Educational tour' },
{ id: 'demo', name: 'Farming demonstration' },
{ id: 'hands-on', name: 'Hands-on activities' },
{ id: 'animals', name: 'Animal education' },
{ id: 'crafts', name: 'Crafts/Activities' }
];
} else if (visitType === 'petting-zoo') {
return [
{ id: 'feeding', name: 'Animal feeding' },
{ id: 'petting', name: 'Animal petting/interaction' },
{ id: 'tour', name: 'Guided tour' },
{ id: 'playground', name: 'Play area' },
{ id: 'photos', name: 'Photo opportunities' }
];
}
return baseActivities;
},
orientation: 'vertical'
}, '1fr');
row.addStarRating('activityRating', {
label: 'Overall Activity Rating',
tooltip: 'How would you rate the activities you participated in?',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'center'
}, '1fr');
});
// ============================================
// SECTION 3: Overall Experience Ratings
// ============================================
const ratingsSection = form.addSubform('ratings', {
title: 'Rate Your Experience',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null,
customStyles: { backgroundColor: '#f0fdf4', padding: '16px', borderRadius: '8px' }
});
ratingsSection.addRow(row => {
row.addEmojiRating('overallSatisfaction', {
label: 'How satisfied are you with your overall farm experience?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
ratingsSection.addSpacer({ height: '20px' });
ratingsSection.addRow(row => {
row.addMatrixQuestion('experienceRatings', {
label: 'Please rate the following aspects of your visit:',
rows: () => {
const visitType = visitSection.dropdown('visitType')?.value();
const baseRows = [
{ id: 'staff', label: 'Staff friendliness & helpfulness', isRequired: true },
{ id: 'cleanliness', label: 'Cleanliness of facilities' },
{ id: 'safety', label: 'Safety and signage' },
{ id: 'value', label: 'Value for money' }
];
if (visitType === 'upick') {
return [
{ id: 'produce', label: 'Quality of produce', isRequired: true },
{ id: 'availability', label: 'Produce availability' },
{ id: 'access', label: 'Field accessibility' },
...baseRows
];
} else if (visitType === 'farm-stay') {
return [
{ id: 'accommodation', label: 'Accommodation quality', isRequired: true },
{ id: 'breakfast', label: 'Breakfast/meals' },
{ id: 'amenities', label: 'Amenities provided' },
{ id: 'quiet', label: 'Peacefulness/ambiance' },
...baseRows
];
} else if (visitType === 'tasting') {
return [
{ id: 'quality', label: 'Product quality', isRequired: true },
{ id: 'variety', label: 'Variety of offerings' },
{ id: 'knowledge', label: 'Staff knowledge' },
{ id: 'atmosphere', label: 'Atmosphere & setting' },
...baseRows
];
} else if (visitType === 'petting-zoo') {
return [
{ id: 'animals', label: 'Animal variety & health', isRequired: true },
{ id: 'interaction', label: 'Interaction opportunities' },
{ id: 'kid-friendly', label: 'Kid-friendliness' },
...baseRows
];
}
return [
{ id: 'experience', label: 'Overall experience quality', isRequired: true },
{ id: 'educational', label: 'Educational value' },
...baseRows
];
},
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
alignment: 'center',
fullWidth: true,
striped: true
});
});
// ============================================
// SECTION 4: Products & Purchases
// ============================================
const productsSection = form.addSubform('products', {
title: 'Products & Purchases',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null
});
productsSection.addRow(row => {
row.addRadioButton('madePurchase', {
label: 'Did you purchase any farm products?',
options: [
{ id: 'yes', name: 'Yes' },
{ id: 'no', name: 'No' }
],
orientation: 'horizontal'
});
});
productsSection.addRow(row => {
row.addCheckboxList('productTypes', {
label: 'What did you purchase?',
options: [
{ id: 'produce', name: 'Fresh produce' },
{ id: 'eggs', name: 'Eggs' },
{ id: 'dairy', name: 'Dairy products' },
{ id: 'meat', name: 'Meat products' },
{ id: 'honey', name: 'Honey' },
{ id: 'preserves', name: 'Jams/Preserves' },
{ id: 'baked', name: 'Baked goods' },
{ id: 'wine', name: 'Wine/Cider' },
{ id: 'crafts', name: 'Crafts/Souvenirs' },
{ id: 'plants', name: 'Plants/Seeds' }
],
orientation: 'vertical',
isVisible: () => productsSection.radioButton('madePurchase')?.value() === 'yes'
}, '1fr');
row.addStarRating('productQuality', {
label: 'Product Quality',
maxStars: 5,
size: 'lg',
showCounter: true,
isVisible: () => productsSection.radioButton('madePurchase')?.value() === 'yes'
}, '1fr');
});
// ============================================
// SECTION 5: Recommendations
// ============================================
const recommendSection = form.addSubform('recommend', {
title: 'Would You Recommend Us?',
isVisible: () => ratingsSection.emojiRating('overallSatisfaction')?.value() !== null
});
recommendSection.addRow(row => {
row.addRatingScale('npsScore', {
label: 'How likely are you to recommend our farm to friends and family?',
preset: 'nps',
showSegmentColors: true,
showCategoryLabel: true,
alignment: 'center'
});
});
recommendSection.addRow(row => {
row.addRadioButton('returnIntent', {
label: 'Do you plan to visit again?',
options: [
{ id: 'definitely', name: 'Definitely!' },
{ id: 'probably', name: 'Probably' },
{ id: 'maybe', name: 'Maybe' },
{ id: 'unlikely', name: 'Unlikely' },
{ id: 'no', name: 'No' }
],
orientation: 'horizontal'
});
});
// ============================================
// SECTION 6: Comments & Suggestions
// ============================================
const commentsSection = form.addSubform('comments', {
title: 'Your Comments',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null
});
commentsSection.addRow(row => {
row.addSuggestionChips('bestParts', {
label: 'What was the best part of your visit?',
suggestions: [
{ id: 'animals', name: 'Animals' },
{ id: 'scenery', name: 'Beautiful scenery' },
{ id: 'fresh-air', name: 'Fresh air' },
{ id: 'staff', name: 'Friendly staff' },
{ id: 'products', name: 'Great products' },
{ id: 'activities', name: 'Fun activities' },
{ id: 'food', name: 'Delicious food' },
{ id: 'peaceful', name: 'Peaceful atmosphere' }
],
alignment: 'center'
});
});
commentsSection.addSpacer({ height: '20px' });
commentsSection.addRow(row => {
row.addTextarea('highlights', {
label: 'What made your visit special?',
placeholder: 'Share your favorite moments or experiences...',
rows: 3
});
});
commentsSection.addSpacer({ height: '20px' });
commentsSection.addRow(row => {
row.addTextarea('suggestions', {
label: 'Any suggestions for improvement?',
placeholder: 'How can we make future visits even better?',
rows: 3
});
});
// ============================================
// SECTION 7: Discovery & Contact
// ============================================
const discoverySection = form.addSubform('discovery', {
title: 'How Did You Find Us?',
isVisible: () => visitSection.radioButton('firstVisit')?.value() === 'yes'
});
discoverySection.addRow(row => {
row.addRadioButton('howFound', {
label: 'How did you hear about our farm?',
options: [
{ id: 'word-of-mouth', name: 'Word of mouth' },
{ id: 'social-media', name: 'Social media' },
{ id: 'search', name: 'Internet search' },
{ id: 'local-ad', name: 'Local advertising' },
{ id: 'tourism-site', name: 'Tourism website/app' },
{ id: 'drive-by', name: 'Drove by / Saw signs' },
{ id: 'event', name: 'At an event' },
{ id: 'other', name: 'Other' }
],
orientation: 'vertical'
});
});
// Contact for follow-up
const contactSection = form.addSubform('contact', {
title: 'Stay Connected (Optional)',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null
});
contactSection.addRow(row => {
row.addCheckbox('joinMailingList', {
label: 'Join our mailing list for seasonal updates and special offers'
});
});
contactSection.addRow(row => {
row.addEmail('email', {
label: 'Email Address',
placeholder: 'your@email.com',
isVisible: () => contactSection.checkbox('joinMailingList')?.value() === true
}, '1fr');
row.addTextbox('name', {
label: 'Your Name',
placeholder: 'First name',
isVisible: () => contactSection.checkbox('joinMailingList')?.value() === true
}, '1fr');
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Visit Summary',
isVisible: () => {
const satisfaction = ratingsSection.emojiRating('overallSatisfaction')?.value();
return satisfaction !== null;
}
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const visitType = visitSection.dropdown('visitType')?.value();
const satisfaction = ratingsSection.emojiRating('overallSatisfaction')?.value();
const activityRating = activitiesSection.starRating('activityRating')?.value();
const nps = recommendSection.ratingScale('npsScore')?.value();
const returnIntent = recommendSection.radioButton('returnIntent')?.value();
const bestParts = commentsSection.suggestionChips('bestParts')?.value() || [];
const visitLabels: Record<string, string> = {
'day-tour': 'Day Tour',
'upick': 'U-Pick Experience',
'farm-stay': 'Farm Stay',
'event': 'Special Event',
'educational': 'Educational Visit',
'dining': 'Farm Dining',
'tasting': 'Tasting Experience',
'petting-zoo': 'Animal Experience',
'other': 'Farm Visit'
};
const satisfactionLabels: Record<string, string> = {
'very-bad': 'Very Dissatisfied',
'bad': 'Dissatisfied',
'neutral': 'Neutral',
'good': 'Satisfied',
'excellent': 'Very Satisfied'
};
let summary = 'VISIT FEEDBACK SUMMARY\n';
summary += `${'═'.repeat(30)}\n\n`;
summary += `Visit Type: ${visitLabels[visitType || ''] || 'Not specified'}\n`;
summary += `Satisfaction: ${satisfactionLabels[satisfaction || ''] || 'Not rated'}\n`;
if (activityRating) {
summary += `Activity Rating: ${'★'.repeat(activityRating)}${'☆'.repeat(5 - activityRating)}\n`;
}
if (nps !== null && nps !== undefined) {
const npsCategory = nps >= 9 ? 'Promoter' : nps >= 7 ? 'Passive' : 'Detractor';
summary += `NPS Score: ${nps}/10 (${npsCategory})\n`;
}
if (returnIntent) {
const returnLabels: Record<string, string> = {
'definitely': 'Definitely returning!',
'probably': 'Probably returning',
'maybe': 'Might return',
'unlikely': 'Unlikely to return',
'no': 'Not returning'
};
summary += `\n${returnLabels[returnIntent]}`;
}
if (bestParts.length > 0) {
summary += `\n\nBest parts: ${bestParts.length} highlights noted`;
}
return summary;
},
customStyles: () => {
const satisfaction = ratingsSection.emojiRating('overallSatisfaction')?.value();
let bgColor = '#f0fdf4';
let borderColor = '#16a34a';
if (satisfaction === 'very-bad' || satisfaction === 'bad') {
bgColor = '#fee2e2';
borderColor = '#ef4444';
} else if (satisfaction === 'neutral') {
bgColor = '#fef3c7';
borderColor = '#f59e0b';
}
return {
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px',
padding: '16px',
backgroundColor: bgColor,
borderRadius: '8px',
borderLeft: `4px solid ${borderColor}`
};
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => visitSection.dropdown('visitType')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback!',
message: 'We appreciate you taking the time to share your experience. Your feedback helps us continue to provide authentic farm experiences. We hope to welcome you back soon!'
});
}