export function farmWorkerFeedback(form: FormTs) {
// Farm Worker Experience Survey - Agricultural employee feedback
// Demonstrates: MatrixQuestion, RatingScale, StarRating, EmojiRating, ThumbRating, CheckboxList, Slider, conditional visibility, dynamic styling
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Farm Worker Experience Survey',
computedValue: () => 'Your feedback helps us improve working conditions',
customStyles: {
backgroundColor: '#854d0e',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Employment Information
// ============================================
const employmentSection = form.addSubform('employment', {
title: 'Employment Information',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
employmentSection.addRow(row => {
row.addDropdown('employmentType', {
label: 'Employment Type',
options: [
{ id: 'seasonal', name: 'Seasonal Worker' },
{ id: 'temporary', name: 'Temporary Worker' },
{ id: 'permanent', name: 'Permanent/Year-round' },
{ id: 'contract', name: 'Contract Worker' }
],
placeholder: 'Select type',
isRequired: true
}, '1fr');
row.addDropdown('workDuration', {
label: 'How long have you worked here?',
options: [
{ id: 'less-1m', name: 'Less than 1 month' },
{ id: '1-3m', name: '1-3 months' },
{ id: '3-6m', name: '3-6 months' },
{ id: '6m-1y', name: '6 months - 1 year' },
{ id: '1-3y', name: '1-3 years' },
{ id: '3y+', name: 'More than 3 years' }
],
placeholder: 'Select duration',
isRequired: true
}, '1fr');
});
employmentSection.addRow(row => {
row.addDropdown('primaryWork', {
label: 'Primary Work Area',
options: [
{ id: 'field', name: 'Field Work/Harvesting' },
{ id: 'packing', name: 'Packing/Processing' },
{ id: 'equipment', name: 'Equipment Operation' },
{ id: 'irrigation', name: 'Irrigation/Maintenance' },
{ id: 'livestock', name: 'Livestock Care' },
{ id: 'greenhouse', name: 'Greenhouse Work' },
{ id: 'general', name: 'General Farm Labor' },
{ id: 'supervisor', name: 'Crew Leader/Supervisor' }
],
placeholder: 'Select work area'
}, '1fr');
row.addDropdown('hoursPerWeek', {
label: 'Average hours per week',
options: [
{ id: 'part', name: 'Less than 20 hours' },
{ id: 'half', name: '20-30 hours' },
{ id: 'full', name: '30-40 hours' },
{ id: 'over', name: '40-50 hours' },
{ id: 'extended', name: 'Over 50 hours' }
],
placeholder: 'Select hours'
}, '1fr');
});
// ============================================
// SECTION 2: Working Conditions
// ============================================
const conditionsSection = form.addSubform('conditions', {
title: 'Working Conditions',
isVisible: () => employmentSection.dropdown('employmentType')?.value() !== null
});
conditionsSection.addRow(row => {
row.addMatrixQuestion('conditionsMatrix', {
label: 'Rate your working conditions:',
rows: [
{ id: 'work-hours', label: 'Work hours are reasonable', isRequired: true },
{ id: 'breaks', label: 'Adequate rest breaks provided', isRequired: true },
{ id: 'water', label: 'Access to drinking water', isRequired: true },
{ id: 'restrooms', label: 'Access to clean restrooms', isRequired: true },
{ id: 'shade', label: 'Shade/shelter available', isRequired: false },
{ id: 'temperature', label: 'Comfortable temperature', isRequired: false }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
conditionsSection.addRow(row => {
row.addEmojiRating('conditionsOverall', {
label: 'Overall, how do you feel about working conditions?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// SECTION 3: Safety
// ============================================
const safetySection = form.addSubform('safety', {
title: 'Health & Safety',
isVisible: () => employmentSection.dropdown('employmentType')?.value() !== null,
customStyles: () => {
const rating = safetySection.starRating('safetyRating')?.value() || 0;
if (rating >= 4) return { backgroundColor: '#dcfce7', padding: '16px', borderRadius: '8px' };
if (rating >= 3) return { backgroundColor: '#fef9c3', padding: '16px', borderRadius: '8px' };
if (rating >= 1) return { backgroundColor: '#fecaca', padding: '16px', borderRadius: '8px' };
return { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' };
}
});
safetySection.addRow(row => {
row.addStarRating('safetyRating', {
label: 'Overall Safety Rating',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
safetySection.addRow(row => {
row.addMatrixQuestion('safetyMatrix', {
label: 'Rate safety practices:',
rows: [
{ id: 'training', label: 'Safety training provided', isRequired: true },
{ id: 'ppe', label: 'Protective equipment available', isRequired: true },
{ id: 'chemicals', label: 'Chemical handling is safe', isRequired: false },
{ id: 'equipment', label: 'Equipment is well-maintained', isRequired: true },
{ id: 'first-aid', label: 'First aid accessible', isRequired: true },
{ id: 'reporting', label: 'Can report safety concerns', isRequired: true }
],
columns: [
{ id: 'na', label: 'N/A' },
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
safetySection.addRow(row => {
row.addCheckboxList('safetyConcerns', {
label: 'Do you have any safety concerns?',
options: [
{ id: 'none', name: 'No concerns - I feel safe' },
{ id: 'heat', name: 'Heat illness risk' },
{ id: 'chemicals', name: 'Chemical exposure' },
{ id: 'equipment', name: 'Dangerous equipment' },
{ id: 'lifting', name: 'Heavy lifting/ergonomics' },
{ id: 'ppe', name: 'Inadequate protective gear' },
{ id: 'training', name: 'Insufficient training' },
{ id: 'other', name: 'Other safety concerns' }
],
orientation: 'vertical'
});
});
safetySection.addSpacer({ isVisible: () => {
const concerns = safetySection.checkboxList('safetyConcerns')?.value() || [];
return concerns.length > 0 && !concerns.includes('none');
}});
safetySection.addRow(row => {
row.addTextarea('safetyConcernDetails', {
label: 'Please describe your safety concerns',
placeholder: 'Describe any unsafe conditions or practices...',
rows: 3,
autoExpand: true,
isVisible: () => {
const concerns = safetySection.checkboxList('safetyConcerns')?.value() || [];
return concerns.length > 0 && !concerns.includes('none');
}
});
});
// ============================================
// SECTION 4: Equipment & Tools
// ============================================
const equipmentSection = form.addSubform('equipment', {
title: 'Equipment & Tools',
isVisible: () => employmentSection.dropdown('employmentType')?.value() !== null
});
equipmentSection.addRow(row => {
row.addRatingScale('equipmentQuality', {
preset: 'likert-5',
label: 'Equipment and tools are in good condition',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
equipmentSection.addRow(row => {
row.addRatingScale('equipmentAvailability', {
preset: 'likert-5',
label: 'I have the tools I need to do my job',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
// ============================================
// SECTION 5: Management & Communication
// ============================================
const managementSection = form.addSubform('management', {
title: 'Management & Communication',
isVisible: () => employmentSection.dropdown('employmentType')?.value() !== null
});
managementSection.addRow(row => {
row.addMatrixQuestion('managementMatrix', {
label: 'Rate management and communication:',
rows: [
{ id: 'respect', label: 'Treated with respect', isRequired: true },
{ id: 'instructions', label: 'Clear work instructions', isRequired: true },
{ id: 'feedback', label: 'Can share concerns/feedback', isRequired: true },
{ id: 'fairness', label: 'Fair treatment of all workers', isRequired: true },
{ id: 'recognition', label: 'Good work is recognized', isRequired: false }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
managementSection.addRow(row => {
row.addStarRating('supervisorRating', {
label: 'Rate your supervisor/crew leader',
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
// ============================================
// SECTION 6: Compensation & Benefits
// ============================================
const compensationSection = form.addSubform('compensation', {
title: 'Compensation & Benefits',
isVisible: () => employmentSection.dropdown('employmentType')?.value() !== null
});
compensationSection.addRow(row => {
row.addRatingScale('payFairness', {
preset: 'likert-5',
label: 'My pay is fair for the work I do',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
compensationSection.addRow(row => {
row.addRatingScale('payTimely', {
preset: 'likert-5',
label: 'I am paid on time and accurately',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
compensationSection.addRow(row => {
row.addCheckboxList('benefitsReceived', {
label: 'Which benefits do you receive? (select all that apply)',
options: [
{ id: 'none', name: 'No benefits provided' },
{ id: 'housing', name: 'Housing' },
{ id: 'meals', name: 'Meals' },
{ id: 'transportation', name: 'Transportation' },
{ id: 'health', name: 'Health insurance' },
{ id: 'training', name: 'Training/skill development' },
{ id: 'bonus', name: 'Bonuses' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 7: Housing (conditional)
// ============================================
const housingSection = form.addSubform('housing', {
title: 'Housing Conditions',
isVisible: () => {
const benefits = compensationSection.checkboxList('benefitsReceived')?.value() || [];
return benefits.includes('housing');
},
customStyles: { backgroundColor: '#fef9c3', padding: '16px', borderRadius: '8px' }
});
housingSection.addRow(row => {
row.addMatrixQuestion('housingMatrix', {
label: 'Rate housing conditions:',
rows: [
{ id: 'cleanliness', label: 'Cleanliness', isRequired: true },
{ id: 'space', label: 'Adequate space', isRequired: true },
{ id: 'privacy', label: 'Privacy', isRequired: false },
{ id: 'utilities', label: 'Working utilities (water, electricity)', isRequired: true },
{ id: 'safety', label: 'Safety/security', isRequired: true }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 8: Overall Satisfaction
// ============================================
const overallSection = form.addSubform('overall', {
title: 'Overall Experience',
isVisible: () => safetySection.starRating('safetyRating')?.value() !== null,
customStyles: () => {
const experience = overallSection.emojiRating('overallExperience')?.value();
if (experience === 'excellent' || experience === 'good') {
return { backgroundColor: '#dcfce7', padding: '16px', borderRadius: '8px' };
}
if (experience === 'neutral') {
return { backgroundColor: '#fef9c3', padding: '16px', borderRadius: '8px' };
}
if (experience === 'bad' || experience === 'very-bad') {
return { backgroundColor: '#fecaca', padding: '16px', borderRadius: '8px' };
}
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
overallSection.addRow(row => {
row.addEmojiRating('overallExperience', {
label: 'Overall, how has your experience been working here?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
overallSection.addRow(row => {
row.addThumbRating('returnNextSeason', {
label: 'Would you return to work here next season?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center',
size: 'lg'
});
});
overallSection.addRow(row => {
row.addThumbRating('recommendToOthers', {
label: 'Would you recommend this job to friends/family?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center',
size: 'lg'
});
});
overallSection.addSpacer();
overallSection.addRow(row => {
row.addTextarea('improvements', {
label: 'What could be improved to make this a better place to work?',
placeholder: 'Share your suggestions for improvement...',
rows: 3,
autoExpand: true
});
});
overallSection.addRow(row => {
row.addTextarea('positives', {
label: 'What do you like most about working here?',
placeholder: 'Share what you appreciate...',
rows: 2,
autoExpand: true
});
});
// ============================================
// SECTION 9: Summary
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Feedback Summary',
isVisible: () => overallSection.emojiRating('overallExperience')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const empType = employmentSection.dropdown('employmentType')?.value();
const workArea = employmentSection.dropdown('primaryWork')?.value();
const safety = safetySection.starRating('safetyRating')?.value();
const supervisor = managementSection.starRating('supervisorRating')?.value();
const experience = overallSection.emojiRating('overallExperience')?.value();
const returnWork = overallSection.thumbRating('returnNextSeason')?.value();
const recommend = overallSection.thumbRating('recommendToOthers')?.value();
const safetyConcerns = safetySection.checkboxList('safetyConcerns')?.value() || [];
const empTypeLabels: Record<string, string> = {
'seasonal': 'Seasonal',
'temporary': 'Temporary',
'permanent': 'Permanent',
'contract': 'Contract'
};
const experienceLabels: Record<string, string> = {
'very-bad': 'Very Negative',
'bad': 'Negative',
'neutral': 'Neutral',
'good': 'Positive',
'excellent': 'Very Positive'
};
let summary = `WORKER FEEDBACK SUMMARY\n`;
summary += `${'═'.repeat(28)}\n\n`;
if (empType) summary += `Type: ${empTypeLabels[empType]}\n`;
if (workArea) summary += `Area: ${workArea}\n`;
summary += `\nRATINGS:\n`;
if (safety) summary += `Safety: ${'★'.repeat(safety)}${'☆'.repeat(5 - safety)}\n`;
if (supervisor) summary += `Supervisor: ${'★'.repeat(supervisor)}${'☆'.repeat(5 - supervisor)}\n`;
if (experience) {
summary += `\nExperience: ${experienceLabels[experience]}\n`;
}
const hasConcerns = safetyConcerns.length > 0 && !safetyConcerns.includes('none');
if (hasConcerns) {
summary += `\n⚠️ Safety concerns: ${safetyConcerns.length}\n`;
}
if (returnWork || recommend) {
summary += `\nReturn: ${returnWork === 'up' ? 'Yes' : returnWork === 'down' ? 'No' : '-'}\n`;
summary += `Recommend: ${recommend === 'up' ? 'Yes' : recommend === 'down' ? 'No' : '-'}`;
}
return summary;
},
customStyles: () => {
const experience = overallSection.emojiRating('overallExperience')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px'
};
if (experience === 'excellent' || experience === 'good') {
return { ...baseStyles, backgroundColor: '#dcfce7', borderLeft: '4px solid #22c55e' };
} else if (experience === 'neutral') {
return { ...baseStyles, backgroundColor: '#fef9c3', borderLeft: '4px solid #eab308' };
} else if (experience === 'bad' || experience === 'very-bad') {
return { ...baseStyles, backgroundColor: '#fecaca', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #854d0e' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => overallSection.emojiRating('overallExperience')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback!',
message: 'Your feedback is valuable and helps us improve working conditions for everyone. All responses are kept confidential.'
});
}