export function storeVisitFeedbackSurvey(form: FormTs) {
// In-Store Experience Survey
// Demonstrates: MatrixQuestion, StarRating, EmojiRating, ThumbRating, RadioButton, conditional sections
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'How Was Your Visit?',
computedValue: () => 'Help us improve your shopping experience by sharing your feedback.',
customStyles: {
backgroundColor: '#059669',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Visit Details
// ============================================
const visitSection = form.addSubform('visitSection', {
title: 'About Your Visit'
});
visitSection.addRow(row => {
row.addDropdown('storeLocation', {
label: 'Store Location',
options: [
{ id: 'downtown', name: 'Downtown Main Street' },
{ id: 'mall-north', name: 'Northgate Mall' },
{ id: 'mall-south', name: 'Southside Plaza' },
{ id: 'suburb-west', name: 'Westfield Shopping Center' },
{ id: 'suburb-east', name: 'Eastview Retail Park' },
{ id: 'other', name: 'Other Location' }
],
placeholder: 'Select store...',
isRequired: true
}, '1fr');
row.addDatepicker('visitDate', {
label: 'Visit Date',
maxDate: () => new Date().toISOString(),
isRequired: true
}, '200px');
});
visitSection.addRow(row => {
row.addRadioButton('visitPurpose', {
label: 'What was the main purpose of your visit?',
options: [
{ id: 'browse', name: 'Browsing' },
{ id: 'specific', name: 'Looking for specific item' },
{ id: 'pickup', name: 'Order pickup' },
{ id: 'return', name: 'Return/Exchange' },
{ id: 'service', name: 'Customer service' }
],
orientation: 'horizontal',
isRequired: true
});
});
visitSection.addRow(row => {
row.addThumbRating('madePurchase', {
label: 'Did you make a purchase?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
size: 'lg',
alignment: 'left'
});
});
// ============================================
// SECTION 2: Staff Experience
// ============================================
const staffIntroSection = form.addSubform('staffIntroSection', {
title: 'Staff Assistance'
});
staffIntroSection.addRow(row => {
row.addRadioButton('staffInteraction', {
label: 'Did you interact with any staff members?',
options: [
{ id: 'yes-approached', name: 'Yes, staff approached me' },
{ id: 'yes-asked', name: 'Yes, I asked for help' },
{ id: 'no-needed', name: 'No, but I needed help' },
{ id: 'no-fine', name: 'No, I was fine on my own' }
],
orientation: 'vertical'
});
});
const staffSection = form.addSubform('staffSection', {
title: 'Rate Our Staff',
isVisible: () => {
const interaction = staffIntroSection.radioButton('staffInteraction')?.value();
return interaction === 'yes-approached' || interaction === 'yes-asked';
},
customStyles: { backgroundColor: '#f0fdf4', padding: '16px', borderRadius: '8px' }
});
staffSection.addRow(row => {
row.addMatrixQuestion('staffMatrix', {
label: 'Please rate our staff on the following:',
rows: [
{ id: 'greeting', label: 'Friendly greeting/welcome', isRequired: true },
{ id: 'knowledge', label: 'Product knowledge' },
{ id: 'helpfulness', label: 'Helpfulness' },
{ id: 'availability', label: 'Availability when needed' },
{ id: 'recommendations', label: 'Quality of recommendations' },
{ id: 'patience', label: 'Patience and attentiveness' }
],
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
});
});
staffSection.addSpacer({ height: '16px' });
staffSection.addRow(row => {
row.addStarRating('staffOverall', {
label: 'Overall staff rating',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
// Needed help but did not get it
const noHelpSection = form.addSubform('noHelpSection', {
title: 'Tell Us What Happened',
isVisible: () => staffIntroSection.radioButton('staffInteraction')?.value() === 'no-needed',
customStyles: { backgroundColor: '#fef2f2', padding: '16px', borderRadius: '8px' }
});
noHelpSection.addRow(row => {
row.addCheckboxList('noHelpReasons', {
label: 'Why did you not receive help? (Select all that apply)',
options: [
{ id: 'no-staff', name: 'Could not find any staff' },
{ id: 'staff-busy', name: 'Staff were busy with others' },
{ id: 'ignored', name: 'Staff did not approach me' },
{ id: 'long-wait', name: 'Wait time was too long' },
{ id: 'gave-up', name: 'I gave up looking for help' }
],
orientation: 'vertical'
});
});
noHelpSection.addRow(row => {
row.addTextarea('noHelpDetails', {
label: 'Please tell us more about your experience',
placeholder: 'What were you looking for? How long did you wait?',
rows: 2
});
});
// ============================================
// SECTION 3: Store Environment
// ============================================
const environmentSection = form.addSubform('environmentSection', {
title: 'Store Environment'
});
environmentSection.addRow(row => {
row.addMatrixQuestion('environmentMatrix', {
label: 'Rate the store environment:',
rows: [
{ id: 'cleanliness', label: 'Cleanliness', isRequired: true },
{ id: 'organization', label: 'Organization & layout' },
{ id: 'navigation', label: 'Easy to find products' },
{ id: 'signage', label: 'Clear signage & pricing' },
{ id: 'lighting', label: 'Lighting & ambiance' },
{ id: 'crowding', label: 'Comfortable space (not crowded)' }
],
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: Product Experience
// ============================================
const productSection = form.addSubform('productSection', {
title: 'Products & Selection'
});
productSection.addRow(row => {
row.addEmojiRating('productSatisfaction', {
label: 'How satisfied were you with the product selection?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
productSection.addRow(row => {
row.addThumbRating('foundItem', {
label: 'Did you find what you were looking for?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'left'
}, '1fr');
row.addThumbRating('pricingFair', {
label: 'Was the pricing fair and competitive?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'left'
}, '1fr');
});
// Product not found details
productSection.addRow(row => {
row.addTextarea('notFoundDetails', {
label: 'What were you looking for that you could not find?',
placeholder: 'Describe the product, size, color, etc.',
rows: 2,
isVisible: () => productSection.thumbRating('foundItem')?.value() === 'down'
});
});
// ============================================
// SECTION 5: Checkout Experience
// ============================================
const checkoutSection = form.addSubform('checkoutSection', {
title: 'Checkout Experience',
isVisible: () => visitSection.thumbRating('madePurchase')?.value() === 'up'
});
checkoutSection.addRow(row => {
row.addRatingScale('checkoutSpeed', {
label: 'How was the checkout speed?',
preset: 'satisfaction',
lowLabel: 'Very Slow',
highLabel: 'Very Fast'
});
});
checkoutSection.addRow(row => {
row.addRadioButton('checkoutMethod', {
label: 'How did you check out?',
options: [
{ id: 'cashier', name: 'With cashier' },
{ id: 'self', name: 'Self-checkout' },
{ id: 'mobile', name: 'Mobile/app checkout' }
],
orientation: 'horizontal'
});
});
checkoutSection.addRow(row => {
row.addMatrixQuestion('checkoutMatrix', {
label: 'Rate your checkout experience:',
rows: [
{ id: 'wait-time', label: 'Wait time' },
{ id: 'cashier-friendly', label: 'Cashier friendliness' },
{ id: 'accuracy', label: 'Transaction accuracy' },
{ id: 'bagging', label: 'Bagging/packaging' }
],
columns: [
{ id: 'na', label: 'N/A' },
{ id: '1', label: 'Poor' },
{ id: '2', label: 'Fair' },
{ id: '3', label: 'Good' },
{ id: '4', label: 'Excellent' }
],
striped: true,
fullWidth: true,
isVisible: () => checkoutSection.radioButton('checkoutMethod')?.value() === 'cashier'
});
});
// ============================================
// SECTION 6: Overall Experience
// ============================================
const overallSection = form.addSubform('overallSection', {
title: 'Overall Experience'
});
overallSection.addRow(row => {
row.addStarRating('overallRating', {
label: 'Rate your overall shopping experience',
maxStars: 5,
size: 'xl',
alignment: 'center',
showConfettiOnMax: true
});
});
overallSection.addRow(row => {
row.addRatingScale('returnLikelihood', {
label: 'How likely are you to return to this store?',
preset: 'nps',
showCategoryLabel: false,
showSegmentColors: true
});
});
// ============================================
// SECTION 7: Additional Feedback
// ============================================
const feedbackSection = form.addSubform('feedbackSection', {
title: 'Additional Comments'
});
feedbackSection.addRow(row => {
row.addSuggestionChips('highlights', {
label: 'What did you like most? (Select up to 3)',
suggestions: [
{ id: 'staff', name: 'Friendly staff' },
{ id: 'selection', name: 'Great selection' },
{ id: 'prices', name: 'Good prices' },
{ id: 'clean', name: 'Clean store' },
{ id: 'easy', name: 'Easy shopping' },
{ id: 'fast', name: 'Fast checkout' },
{ id: 'quality', name: 'Quality products' },
{ id: 'location', name: 'Convenient location' }
],
max: 3,
alignment: 'center'
});
});
feedbackSection.addSpacer({ height: '16px' });
feedbackSection.addRow(row => {
row.addTextarea('comments', {
label: 'Any other comments or suggestions?',
placeholder: 'Tell us how we can improve your shopping experience...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Visit Summary',
isVisible: () => overallSection.starRating('overallRating')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const overall = overallSection.starRating('overallRating')?.value();
const location = visitSection.dropdown('storeLocation')?.value();
const purpose = visitSection.radioButton('visitPurpose')?.value();
const purchased = visitSection.thumbRating('madePurchase')?.value();
const staffRating = staffSection.starRating('staffOverall')?.value();
const foundItem = productSection.thumbRating('foundItem')?.value();
const returnScore = overallSection.ratingScale('returnLikelihood')?.value();
if (!overall) return '';
const locationLabels: Record<string, string> = {
'downtown': 'Downtown Main Street',
'mall-north': 'Northgate Mall',
'mall-south': 'Southside Plaza',
'suburb-west': 'Westfield Shopping Center',
'suburb-east': 'Eastview Retail Park',
'other': 'Other Location'
};
const purposeLabels: Record<string, string> = {
'browse': 'Browsing',
'specific': 'Looking for specific item',
'pickup': 'Order pickup',
'return': 'Return/Exchange',
'service': 'Customer service'
};
let summary = `Store Visit Feedback\n`;
summary += `${'='.repeat(24)}\n\n`;
if (location) {
summary += `Store: ${locationLabels[location] || location}\n`;
}
if (purpose) {
summary += `Purpose: ${purposeLabels[purpose] || purpose}\n`;
}
summary += `Made Purchase: ${purchased === 'up' ? 'Yes' : purchased === 'down' ? 'No' : 'Not specified'}\n`;
summary += `Found Item: ${foundItem === 'up' ? 'Yes' : foundItem === 'down' ? 'No' : 'N/A'}\n\n`;
summary += `Overall Rating: ${'*'.repeat(overall)}${'*'.repeat(5 - overall)} (${overall}/5)\n`;
if (staffRating) {
summary += `Staff Rating: ${staffRating}/5\n`;
}
if (returnScore !== null && returnScore !== undefined) {
summary += `Return Likelihood: ${returnScore}/10\n`;
}
return summary;
},
customStyles: () => {
const overall = overallSection.starRating('overallRating')?.value() || 0;
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (overall >= 4) {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #059669' };
} else if (overall >= 3) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => overallSection.starRating('overallRating')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Shopping With Us!',
message: 'Your feedback helps us create a better shopping experience. We appreciate you taking the time to share your thoughts.'
});
}