export function agriculturalSupplierFeedback(form: FormTs) {
// Agricultural Supplier Feedback Form - Farm input supplier evaluation
// Demonstrates: MatrixQuestion, RatingScale (NPS), StarRating, EmojiRating, ThumbRating, CheckboxList, SuggestionChips, conditional visibility, dynamic styling
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Agricultural Supplier Feedback',
computedValue: () => 'Help us evaluate and improve our supplier relationships',
customStyles: {
backgroundColor: '#166534',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Supplier & Order Information
// ============================================
const supplierSection = form.addSubform('supplier', {
title: 'Supplier & Order Details',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
supplierSection.addRow(row => {
row.addTextbox('supplierName', {
label: 'Supplier/Company Name',
placeholder: 'e.g., AgriSeeds Inc.',
isRequired: true
}, '1fr');
row.addDropdown('supplierCategory', {
label: 'Supplier Category',
options: [
{ id: 'seeds', name: 'Seeds & Planting Materials' },
{ id: 'fertilizer', name: 'Fertilizers & Nutrients' },
{ id: 'chemicals', name: 'Crop Protection/Chemicals' },
{ id: 'equipment', name: 'Equipment & Machinery' },
{ id: 'irrigation', name: 'Irrigation & Water Systems' },
{ id: 'feed', name: 'Animal Feed' },
{ id: 'livestock', name: 'Livestock Supplies' },
{ id: 'packaging', name: 'Packaging Materials' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select category',
isRequired: true
}, '1fr');
});
supplierSection.addRow(row => {
row.addTextbox('orderReference', {
label: 'Order/Invoice Reference',
placeholder: 'e.g., PO-2024-001'
}, '1fr');
row.addDatepicker('orderDate', {
label: 'Order Date',
maxDate: () => new Date().toISOString().split('T')[0]
}, '1fr');
});
supplierSection.addRow(row => {
row.addTextbox('productOrdered', {
label: 'Product(s) Ordered',
placeholder: 'e.g., Corn Seed Variety XYZ, 50 bags'
});
});
supplierSection.addRow(row => {
row.addDropdown('orderFrequency', {
label: 'How often do you order from this supplier?',
options: [
{ id: 'first', name: 'First time ordering' },
{ id: 'occasional', name: 'Occasionally (1-2x per year)' },
{ id: 'regular', name: 'Regularly (3-6x per year)' },
{ id: 'frequent', name: 'Frequently (monthly or more)' }
],
placeholder: 'Select frequency'
}, '1fr');
row.addDropdown('relationshipLength', {
label: 'How long have you worked with this supplier?',
options: [
{ id: 'new', name: 'New (less than 1 year)' },
{ id: '1-3', name: '1-3 years' },
{ id: '3-5', name: '3-5 years' },
{ id: '5+', name: 'More than 5 years' }
],
placeholder: 'Select'
}, '1fr');
});
// ============================================
// SECTION 2: Product Quality
// ============================================
const qualitySection = form.addSubform('quality', {
title: 'Product Quality',
isVisible: () => supplierSection.dropdown('supplierCategory')?.value() !== null,
customStyles: () => {
const rating = qualitySection.starRating('overallQuality')?.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' };
}
});
qualitySection.addRow(row => {
row.addStarRating('overallQuality', {
label: 'Overall Product Quality',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
qualitySection.addRow(row => {
row.addMatrixQuestion('qualityMatrix', {
label: 'Rate specific quality aspects:',
rows: [
{ id: 'specs', label: 'Met specifications/description', isRequired: true },
{ id: 'consistency', label: 'Consistency across batches', isRequired: true },
{ id: 'packaging', label: 'Packaging quality', isRequired: false },
{ id: 'freshness', label: 'Freshness/shelf life', isRequired: false },
{ id: 'performance', label: 'Field/use performance', isRequired: false }
],
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
});
});
qualitySection.addRow(row => {
row.addCheckboxList('qualityIssues', {
label: 'Did you experience any quality issues?',
options: [
{ id: 'none', name: 'No issues - quality was as expected' },
{ id: 'damaged', name: 'Damaged or defective products' },
{ id: 'wrong-specs', name: 'Did not match specifications' },
{ id: 'contamination', name: 'Contamination or impurities' },
{ id: 'short-shelf', name: 'Short shelf life/expiration' },
{ id: 'performance', name: 'Poor field performance' },
{ id: 'inconsistent', name: 'Inconsistent quality' }
],
orientation: 'vertical'
});
});
qualitySection.addSpacer({ isVisible: () => {
const issues = qualitySection.checkboxList('qualityIssues')?.value() || [];
return issues.length > 0 && !issues.includes('none');
}});
qualitySection.addRow(row => {
row.addTextarea('qualityComments', {
label: 'Describe any quality issues encountered',
placeholder: 'Provide details about the quality problems...',
rows: 3,
autoExpand: true,
isVisible: () => {
const issues = qualitySection.checkboxList('qualityIssues')?.value() || [];
return issues.length > 0 && !issues.includes('none');
}
});
});
// ============================================
// SECTION 3: Delivery Performance
// ============================================
const deliverySection = form.addSubform('delivery', {
title: 'Delivery Performance',
isVisible: () => supplierSection.dropdown('supplierCategory')?.value() !== null
});
deliverySection.addRow(row => {
row.addMatrixQuestion('deliveryMatrix', {
label: 'Rate delivery performance:',
rows: [
{ id: 'ontime', label: 'On-time delivery', isRequired: true },
{ id: 'accuracy', label: 'Order accuracy (correct items/qty)', isRequired: true },
{ id: 'condition', label: 'Condition on arrival', isRequired: true },
{ id: 'communication', label: 'Delivery communication/tracking', isRequired: false },
{ id: 'flexibility', label: 'Flexibility with delivery scheduling', isRequired: false }
],
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
});
});
deliverySection.addRow(row => {
row.addRadioButton('deliveryTiming', {
label: 'How was the delivery timing for this order?',
options: [
{ id: 'early', name: 'Early (arrived before expected)' },
{ id: 'ontime', name: 'On time (as promised)' },
{ id: 'slight-delay', name: 'Slight delay (1-3 days late)' },
{ id: 'significant-delay', name: 'Significant delay (4+ days late)' },
{ id: 'very-late', name: 'Very late (impacted operations)' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 4: Pricing & Value
// ============================================
const pricingSection = form.addSubform('pricing', {
title: 'Pricing & Value',
isVisible: () => supplierSection.dropdown('supplierCategory')?.value() !== null
});
pricingSection.addRow(row => {
row.addRatingScale('priceCompetitiveness', {
preset: 'likert-5',
label: 'Pricing is competitive compared to alternatives',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
pricingSection.addRow(row => {
row.addRatingScale('valueForMoney', {
preset: 'likert-5',
label: 'Products provide good value for money',
lowLabel: 'Strongly Disagree',
highLabel: 'Strongly Agree',
alignment: 'center'
});
});
pricingSection.addRow(row => {
row.addSuggestionChips('pricingFactors', {
label: 'What pricing factors are most important to you?',
suggestions: [
{ id: 'base-price', name: 'Base Price' },
{ id: 'volume-discount', name: 'Volume Discounts' },
{ id: 'payment-terms', name: 'Payment Terms' },
{ id: 'loyalty-rewards', name: 'Loyalty Rewards' },
{ id: 'free-shipping', name: 'Free Shipping' },
{ id: 'price-stability', name: 'Price Stability' },
{ id: 'bundling', name: 'Product Bundling' }
],
max: 3,
alignment: 'center'
});
});
// ============================================
// SECTION 5: Customer Service & Support
// ============================================
const serviceSection = form.addSubform('service', {
title: 'Customer Service & Support',
isVisible: () => supplierSection.dropdown('supplierCategory')?.value() !== null
});
serviceSection.addRow(row => {
row.addStarRating('serviceRating', {
label: 'Overall Customer Service',
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
serviceSection.addRow(row => {
row.addMatrixQuestion('serviceMatrix', {
label: 'Rate customer service aspects:',
rows: [
{ id: 'responsiveness', label: 'Response time to inquiries', isRequired: true },
{ id: 'knowledge', label: 'Product knowledge/expertise', isRequired: true },
{ id: 'problemsolving', label: 'Problem resolution', isRequired: false },
{ id: 'proactive', label: 'Proactive communication', isRequired: false },
{ id: 'technical', label: 'Technical support quality', isRequired: false }
],
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
});
});
serviceSection.addRow(row => {
row.addEmojiRating('serviceExperience', {
label: 'How would you describe your service experience?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// SECTION 6: Overall Assessment & NPS
// ============================================
const overallSection = form.addSubform('overall', {
title: 'Overall Assessment',
isVisible: () => qualitySection.starRating('overallQuality')?.value() !== null,
customStyles: () => {
const nps = overallSection.ratingScale('supplierNPS')?.npsCategory();
if (nps === 'promoter') return { backgroundColor: '#dcfce7', padding: '16px', borderRadius: '8px' };
if (nps === 'passive') return { backgroundColor: '#fef9c3', padding: '16px', borderRadius: '8px' };
if (nps === 'detractor') return { backgroundColor: '#fecaca', padding: '16px', borderRadius: '8px' };
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
overallSection.addRow(row => {
row.addRatingScale('supplierNPS', {
preset: 'nps',
label: 'How likely are you to recommend this supplier to other farmers?',
showSegmentColors: true,
showCategoryLabel: true,
showConfettiOnPromoter: true,
alignment: 'center'
});
});
overallSection.addRow(row => {
row.addThumbRating('continueOrdering', {
label: 'Will you continue ordering from this supplier?',
showLabels: true,
upLabel: 'Yes, definitely',
downLabel: 'Probably not',
alignment: 'center',
size: 'lg'
});
});
overallSection.addRow(row => {
row.addSuggestionChips('supplierStrengths', {
label: 'What are this supplier\'s greatest strengths?',
suggestions: [
{ id: 'quality', name: 'Product Quality' },
{ id: 'reliability', name: 'Reliability' },
{ id: 'pricing', name: 'Competitive Pricing' },
{ id: 'service', name: 'Customer Service' },
{ id: 'expertise', name: 'Technical Expertise' },
{ id: 'availability', name: 'Product Availability' },
{ id: 'delivery', name: 'Fast Delivery' },
{ id: 'flexibility', name: 'Flexibility' }
],
max: 3,
alignment: 'center'
});
});
overallSection.addSpacer();
overallSection.addRow(row => {
row.addTextarea('additionalComments', {
label: 'Additional comments or suggestions for this supplier',
placeholder: 'Share any other feedback, concerns, or suggestions...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 7: Summary
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Feedback Summary',
isVisible: () => overallSection.ratingScale('supplierNPS')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const supplier = supplierSection.textbox('supplierName')?.value();
const category = supplierSection.dropdown('supplierCategory')?.value();
const quality = qualitySection.starRating('overallQuality')?.value();
const service = serviceSection.starRating('serviceRating')?.value();
const nps = overallSection.ratingScale('supplierNPS')?.npsCategory();
const npsScore = overallSection.ratingScale('supplierNPS')?.value();
const continueOrder = overallSection.thumbRating('continueOrdering')?.value();
const strengths = overallSection.suggestionChips('supplierStrengths')?.value() || [];
const categoryLabels: Record<string, string> = {
'seeds': 'Seeds & Planting',
'fertilizer': 'Fertilizers',
'chemicals': 'Crop Protection',
'equipment': 'Equipment',
'irrigation': 'Irrigation',
'feed': 'Animal Feed',
'livestock': 'Livestock Supplies',
'packaging': 'Packaging',
'other': 'Other'
};
let summary = `SUPPLIER EVALUATION\n`;
summary += `${'═'.repeat(25)}\n\n`;
if (supplier) summary += `Supplier: ${supplier}\n`;
if (category) summary += `Category: ${categoryLabels[category]}\n`;
summary += `\nRATINGS:\n`;
if (quality) summary += `Quality: ${'★'.repeat(quality)}${'☆'.repeat(5 - quality)} (${quality}/5)\n`;
if (service) summary += `Service: ${'★'.repeat(service)}${'☆'.repeat(5 - service)} (${service}/5)\n`;
if (nps && npsScore !== null && npsScore !== undefined) {
const emoji = nps === 'promoter' ? '🎉' : nps === 'passive' ? '😐' : '😟';
summary += `\n${emoji} NPS: ${npsScore}/10 (${nps})\n`;
}
if (strengths.length > 0) {
summary += `\nStrengths: ${strengths.length} identified\n`;
}
if (continueOrder) {
summary += `\nContinue ordering: ${continueOrder === 'up' ? 'Yes' : 'No'}`;
}
return summary;
},
customStyles: () => {
const nps = overallSection.ratingScale('supplierNPS')?.npsCategory();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px'
};
if (nps === 'promoter') {
return { ...baseStyles, backgroundColor: '#dcfce7', borderLeft: '4px solid #22c55e' };
} else if (nps === 'passive') {
return { ...baseStyles, backgroundColor: '#fef9c3', borderLeft: '4px solid #eab308' };
} else if (nps === 'detractor') {
return { ...baseStyles, backgroundColor: '#fecaca', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #166534' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Supplier Feedback',
isVisible: () => overallSection.ratingScale('supplierNPS')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Feedback!',
message: 'Your supplier evaluation has been recorded. This feedback helps us maintain strong supplier relationships and make informed purchasing decisions.'
});
}