export function momentOfTruthForm(form: FormTs) {
// Moment of Truth Feedback - Real-time emotional capture at critical touchpoints
// Demonstrates: EmojiRating, Slider, RadioButton, SuggestionChips, dynamic content
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Quick Feedback',
computedValue: () => 'How was this moment? Your instant reaction matters.',
customStyles: {
backgroundColor: '#ec4899',
color: 'white',
padding: '20px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Moment Identification
// ============================================
const momentSection = form.addSubform('momentSection', {
title: 'This Moment'
});
momentSection.addRow(row => {
row.addDropdown('momentType', {
label: 'What just happened?',
options: [
{ id: 'first-use', name: 'First time using the product' },
{ id: 'purchase', name: 'Completed a purchase' },
{ id: 'support', name: 'Got help from support' },
{ id: 'delivery', name: 'Received a delivery' },
{ id: 'onboarding', name: 'Completed onboarding' },
{ id: 'feature', name: 'Tried a new feature' },
{ id: 'renewal', name: 'Renewed subscription' },
{ id: 'problem', name: 'Experienced a problem' },
{ id: 'other', name: 'Other moment' }
],
placeholder: 'Select the moment type',
isRequired: true
});
});
// ============================================
// SECTION 2: Emotional Capture
// ============================================
const emotionSection = form.addSubform('emotionSection', {
title: 'Your Feeling',
isVisible: () => momentSection.dropdown('momentType')?.value() !== null
});
emotionSection.addRow(row => {
row.addEmojiRating('emotionalReaction', {
label: 'How do you feel right now?',
preset: 'custom',
emojis: [
{ id: 'frustrated', emoji: '😤', label: 'Frustrated' },
{ id: 'disappointed', emoji: '😞', label: 'Disappointed' },
{ id: 'neutral', emoji: '😐', label: 'Neutral' },
{ id: 'pleased', emoji: '😊', label: 'Pleased' },
{ id: 'delighted', emoji: '🤩', label: 'Delighted' }
],
size: 'lg',
alignment: 'center',
isRequired: true
});
});
emotionSection.addRow(row => {
row.addSlider('emotionIntensity', {
label: 'How strong is this feeling?',
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5,
isVisible: () => emotionSection.emojiRating('emotionalReaction')?.value() !== null
});
});
// ============================================
// SECTION 3: Positive Moment Details
// ============================================
const positiveSection = form.addSubform('positiveSection', {
title: 'What Made It Great?',
isVisible: () => {
const emotion = emotionSection.emojiRating('emotionalReaction')?.value();
return emotion === 'pleased' || emotion === 'delighted';
},
customStyles: {
backgroundColor: '#ecfdf5',
padding: '16px',
borderRadius: '8px'
}
});
positiveSection.addRow(row => {
row.addSuggestionChips('positiveFactors', {
label: 'What contributed to this positive experience?',
suggestions: [
{ id: 'easy', name: 'Easy to use' },
{ id: 'fast', name: 'Fast process' },
{ id: 'helpful', name: 'Helpful staff' },
{ id: 'quality', name: 'Great quality' },
{ id: 'exceeded', name: 'Exceeded expectations' },
{ id: 'personal', name: 'Felt personal' },
{ id: 'value', name: 'Good value' },
{ id: 'surprise', name: 'Pleasant surprise' }
],
max: 3,
alignment: 'left'
});
});
positiveSection.addRow(row => {
row.addStarRating('momentRating', {
label: 'Rate this moment',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
// ============================================
// SECTION 4: Negative Moment Details
// ============================================
const negativeSection = form.addSubform('negativeSection', {
title: 'What Went Wrong?',
isVisible: () => {
const emotion = emotionSection.emojiRating('emotionalReaction')?.value();
return emotion === 'frustrated' || emotion === 'disappointed';
},
customStyles: {
backgroundColor: '#fef2f2',
padding: '16px',
borderRadius: '8px',
borderLeft: '4px solid #ef4444'
}
});
negativeSection.addRow(row => {
row.addCheckboxList('negativeFactors', {
label: 'What caused this negative experience?',
options: [
{ id: 'confusing', name: 'Confusing or unclear' },
{ id: 'slow', name: 'Too slow or took too long' },
{ id: 'unhelpful', name: 'Unhelpful response' },
{ id: 'broken', name: 'Something didn\'t work' },
{ id: 'unexpected', name: 'Unexpected outcome' },
{ id: 'impersonal', name: 'Felt impersonal' },
{ id: 'expensive', name: 'Too expensive' },
{ id: 'effort', name: 'Required too much effort' }
],
orientation: 'vertical'
});
});
negativeSection.addSpacer();
negativeSection.addRow(row => {
row.addTextarea('whatWentWrong', {
label: 'What specifically went wrong?',
placeholder: 'Please describe what happened...',
rows: 3,
autoExpand: true
});
});
negativeSection.addRow(row => {
row.addRatingScale('resolutionUrgency', {
label: 'How urgently does this need to be fixed?',
preset: 'custom',
min: 1,
max: 5,
lowLabel: 'Can wait',
highLabel: 'Immediate'
});
});
// ============================================
// SECTION 5: Expectation Gap
// ============================================
const expectationSection = form.addSubform('expectationSection', {
title: 'Expectations vs Reality',
isVisible: () => emotionSection.emojiRating('emotionalReaction')?.value() !== null
});
expectationSection.addRow(row => {
row.addRadioButton('expectationMatch', {
label: 'How did this moment compare to your expectations?',
options: [
{ id: 'far-below', name: 'Far below expectations' },
{ id: 'below', name: 'Below expectations' },
{ id: 'met', name: 'Met expectations' },
{ id: 'above', name: 'Above expectations' },
{ id: 'far-above', name: 'Far exceeded expectations' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 6: Impact Assessment
// ============================================
const impactSection = form.addSubform('impactSection', {
title: 'Impact on Your View',
isVisible: () => emotionSection.emojiRating('emotionalReaction')?.value() !== null
});
impactSection.addRow(row => {
row.addMatrixQuestion('impactMatrix', {
label: 'How does this moment affect your view of us?',
rows: [
{ id: 'trust', label: 'Trust in our brand' },
{ id: 'loyalty', label: 'Likelihood to stay' },
{ id: 'recommend', label: 'Likelihood to recommend' }
],
columns: [
{ id: 'decreased', label: 'Decreased' },
{ id: 'unchanged', label: 'Unchanged' },
{ id: 'increased', label: 'Increased' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 7: Quick Follow-up
// ============================================
const followupSection = form.addSubform('followupSection', {
title: 'One More Thing',
isVisible: () => emotionSection.emojiRating('emotionalReaction')?.value() !== null
});
followupSection.addRow(row => {
row.addThumbRating('wouldRepeat', {
label: 'Would you want to experience this moment again?',
showLabels: true,
upLabel: 'Yes, definitely',
downLabel: 'No, rather not',
size: 'lg',
alignment: 'center'
});
});
followupSection.addSpacer();
followupSection.addRow(row => {
row.addTextarea('oneWord', {
label: 'Describe this moment in one word or phrase:',
placeholder: 'e.g., "Seamless", "Frustrating", "Surprising"...',
rows: 1,
maxLength: 50
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Moment Summary',
isVisible: () => {
const emotion = emotionSection.emojiRating('emotionalReaction')?.value();
return emotion !== null;
}
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const momentType = momentSection.dropdown('momentType')?.value();
const emotion = emotionSection.emojiRating('emotionalReaction')?.value();
const intensity = emotionSection.slider('emotionIntensity')?.value();
const expectation = expectationSection.radioButton('expectationMatch')?.value();
const wouldRepeat = followupSection.thumbRating('wouldRepeat')?.value();
const oneWord = followupSection.textarea('oneWord')?.value();
const momentLabels: Record<string, string> = {
'first-use': 'First Use',
'purchase': 'Purchase',
'support': 'Support',
'delivery': 'Delivery',
'onboarding': 'Onboarding',
'feature': 'New Feature',
'renewal': 'Renewal',
'problem': 'Problem',
'other': 'Other'
};
const emotionEmojis: Record<string, string> = {
'frustrated': '😤',
'disappointed': '😞',
'neutral': '😐',
'pleased': '😊',
'delighted': '🤩'
};
const expectationLabels: Record<string, string> = {
'far-below': 'Far Below',
'below': 'Below',
'met': 'Met',
'above': 'Above',
'far-above': 'Far Exceeded'
};
let summary = `⚡ Moment of Truth Captured\n`;
summary += `${'═'.repeat(28)}\n\n`;
if (momentType) summary += `📍 Moment: ${momentLabels[momentType] || momentType}\n`;
if (emotion) summary += `${emotionEmojis[emotion] || ''} Feeling: ${emotion}\n`;
if (intensity) summary += `💪 Intensity: ${intensity}/10\n`;
if (expectation) summary += `📊 Expectations: ${expectationLabels[expectation] || expectation}\n`;
if (wouldRepeat) summary += `🔄 Would Repeat: ${wouldRepeat === 'up' ? 'Yes' : 'No'}\n`;
if (oneWord) summary += `\n💬 "${oneWord}"`;
return summary;
},
customStyles: () => {
const emotion = emotionSection.emojiRating('emotionalReaction')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (emotion === 'delighted' || emotion === 'pleased') {
return { ...baseStyles, backgroundColor: '#ecfdf5', borderLeft: '4px solid #10b981' };
} else if (emotion === 'frustrated' || emotion === 'disappointed') {
return { ...baseStyles, backgroundColor: '#fef2f2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #94a3b8' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Capture This Moment',
isVisible: () => emotionSection.emojiRating('emotionalReaction')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Moment Captured!',
message: 'Thank you for sharing this moment with us. Your real-time feedback helps us create better experiences at every touchpoint.'
});
}