import { useState, useEffect, useRef, useCallback } from "react";
/* โโโ ALL QUESTIONS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */
const QUESTIONS = [
// Welcome screen
{ id: "welcome", type: "welcome",
heading: "Performance Intake Application",
sub: "This isn't a generic contact form. It's a comprehensive coaching application that lets us build a precision protocol around your specific goals, history, and life.\n\nTake your time. Be honest. The more detail you give us, the better your program will be.",
tag: "Confidential ยท ~15 Minutes ยท 9 Sections",
btnLabel: "Begin Application โ" },
// โโ 01 Personal
{ id: "s01", type: "section", label: "01", title: "Personal Profile", sub: "Tell us who you are" },
{ id: "firstName", type: "text", section: "01", q: "What's your first name?", placeholder: "First name", required: true },
{ id: "lastName", type: "text", section: "01", q: "And your last name?", placeholder: "Last name", required: true },
{ id: "email", type: "email", section: "01", q: "Best email address to reach you?", placeholder: "you@email.com", required: true },
{ id: "phone", type: "tel", section: "01", q: "Your phone number?", placeholder: "(555) 000-0000", required: true },
{ id: "dob", type: "date", section: "01", q: "Date of birth?", required: true },
{ id: "location", type: "text", section: "01", q: "What city and state are you in?", placeholder: "e.g. Birmingham, AL", required: true },
{ id: "occupation", type: "text", section: "01", q: "What do you do professionally?", placeholder: "Job title or industry", required: true },
{ id: "hearAbout", type: "choice", section: "01", q: "How did you hear about us?", required: true,
options: ["Instagram", "Referral from a friend", "Existing client referral", "Google / Web Search", "TikTok", "Podcast", "Other"] },
{ id: "hearAboutOther", type: "text", section: "01", q: "Tell us how โ where did you come across us?", placeholder: "Give us the specifics...", conditional: { field: "hearAbout", value: "Other" } },
// โโ 02 Goals
{ id: "s02", type: "section", label: "02", title: "Goals & Vision", sub: "Define your target outcome" },
{ id: "primaryGoal", type: "choice", section: "02", q: "What is your #1 primary goal?", required: true,
options: ["Body recomposition (lose fat, build muscle)", "Fat loss / weight loss", "Muscle building / hypertrophy", "Athletic performance", "Hormonal optimization", "Fertility support", "General health & longevity", "Post-injury comeback", "Other"] },
{ id: "primaryGoalDetail", type: "long", section: "02", required: true,
q: "Describe your primary goal in your own words.",
hint: "What does success look like to you at the end of 90 days? Be as specific as possible." },
{ id: "targetPhysique", type: "text", section: "02",
q: "Do you have a target bodyweight or physique goal?",
placeholder: "e.g. 185 lbs, lose 15 lbs of fat, visible abs..." },
{ id: "timeline", type: "choice", section: "02", q: "What is your desired timeline for results?", required: true,
options: ["30 days", "60 days", "90 days (recommended)", "6 months", "12 months", "Building for life โ no set deadline"] },
{ id: "motivation", type: "long", section: "02", required: true,
q: "What is driving you to make this change RIGHT NOW?",
hint: "What happened โ or is about to happen โ that made you take action today? Be honest." },
// โโ 03 Training
{ id: "s03", type: "section", label: "03", title: "Training Background", sub: "Your history in the gym" },
{ id: "trainingAge", type: "choice", section: "03", q: "How many years have you been training consistently?", required: true,
options: ["Less than 1 year", "1โ2 years", "2โ4 years", "4โ7 years", "7โ10 years", "10โ15 years", "15+ years"] },
{ id: "trainingLevel", type: "choice", section: "03", q: "How would you honestly rate your current training level?", required: true,
options: ["Beginner โ new to structured training", "Novice โ less than 1 year consistent", "Intermediate โ some programming experience", "Advanced โ multiple years with structured programs", "Elite โ competitive or professional level"] },
{ id: "trainingStyle", type: "multi", section: "03", q: "What training styles have you done? Select all that apply.", required: true,
options: ["Bodybuilding / hypertrophy", "Powerlifting", "CrossFit / functional fitness", "HIIT", "Endurance / cardio", "Sports-specific", "Calisthenics", "Yoga / mobility", "No prior training"] },
{ id: "equipment", type: "multi", section: "03", q: "What equipment do you have access to?", required: true,
options: ["Full commercial gym", "Home gym with squat rack", "Dumbbells + barbells", "Kettlebells", "Cardio machines (rower, bike, treadmill)", "Sauna", "YMCA / community gym", "Resistance bands only", "Bodyweight only"] },
{ id: "trainingDays", type: "choice", section: "03", q: "How many days per week can you realistically commit to training?", required: true,
options: ["2 days", "3 days", "4 days", "5 days", "6 days"] },
{ id: "sessionLength", type: "choice", section: "03", q: "How long can each training session realistically be?", required: true,
options: ["30 minutes", "45 minutes", "60 minutes", "75 minutes", "90+ minutes", "It varies"] },
{ id: "bestResults", type: "long", section: "03",
q: "What type of training has produced your best results historically?",
hint: "Tell us what worked and what didn't. Any style you respond especially well to?" },
{ id: "burnout", type: "choice", section: "03", q: "Have you ever experienced training burnout or overtraining?",
options: ["No", "Yes โ briefly", "Yes โ significantly, took extended time off", "Yes โ currently experiencing it"] },
// โโ 04 Body & Health
{ id: "s04", type: "section", label: "04", title: "Body Composition & Health", sub: "Where you are right now" },
{ id: "currentWeight", type: "number", section: "04", q: "Current bodyweight in pounds?", placeholder: "e.g. 220", required: true },
{ id: "height", type: "text", section: "04", q: "Your height?", placeholder: "e.g. 5'11\"", required: true },
{ id: "currentPhysique", type: "choice", section: "04", q: "How would you honestly describe your current physique?",
options: ["Very lean (under 12% BF)", "Lean (12โ16% BF)", "Average (16โ22% BF)", "Above average (22โ28% BF)", "Significantly above goal (28%+ BF)", "Unsure"] },
{ id: "weightHistory", type: "long", section: "04", required: true,
q: "Describe your weight history over the past 2โ3 years.",
hint: "Have you gained, lost, maintained? What caused the changes? Be specific." },
{ id: "medicalConditions", type: "long", section: "04", required: true,
q: "Do you have any current or past medical conditions relevant to fitness and nutrition?",
hint: "Hormonal, metabolic, cardiovascular, autoimmune, mental health โ nothing is too minor to mention." },
{ id: "injuries", type: "long", section: "04", required: true,
q: "Any current or past injuries that affect training?",
hint: "List body part, nature of injury, and current status. Include surgeries and movement restrictions." },
{ id: "medications", type: "long", section: "04",
q: "Current medications or prescribed treatments?",
hint: "Include all prescriptions, hormone therapies, and physician-supervised treatments." },
{ id: "hormonalHistory", type: "choice", section: "04", q: "Have you used performance-enhancing hormones or TRT?",
options: ["No, never", "Yes โ TRT / testosterone therapy (current)", "Yes โ TRT / testosterone therapy (past)", "Yes โ anabolic steroids (past)", "Yes โ other hormone therapy", "Prefer not to say"] },
{ id: "recentLabs", type: "choice", section: "04", q: "Have you had recent bloodwork / lab panels done?",
options: ["Yes โ within the last 3 months", "Yes โ within the last 6 months", "Yes โ over 6 months ago", "No โ not recently", "No โ never"] },
// โโ 05 Nutrition
{ id: "s05", type: "section", label: "05", title: "Nutrition & Diet", sub: "What and how you eat" },
{ id: "currentDiet", type: "choice", section: "05", q: "How would you describe your current diet?", required: true,
options: ["Mostly whole foods, well structured", "Generally healthy but inconsistent", "Average โ some good, some poor choices", "Poor โ mostly processed or untracked", "Very restrictive / history of disordered eating", "Athlete-level tracking and precision"] },
{ id: "proteinTracking", type: "choice", section: "05", q: "Are you currently tracking protein intake?", required: true,
options: ["Yes โ accurately with a food scale", "Yes โ loosely estimating", "No โ but I'm aware of it", "No โ not tracking at all"] },
{ id: "estimatedProtein", type: "text", section: "05",
q: "Rough daily protein intake estimate?", placeholder: "e.g. ~150g, ~180g, or 'no idea'" },
{ id: "nutritionChallenge", type: "multi", section: "05", q: "What are your biggest nutrition challenges right now?",
options: ["Hitting protein targets", "Controlling portions", "Emotional / stress eating", "Too much processed food", "Inconsistency on weekends", "Alcohol / social situations", "Meal prep and planning", "Appetite control", "Knowing what to eat", "Budget or time constraints"] },
{ id: "alcoholUse", type: "choice", section: "05", q: "Current alcohol consumption?", required: true,
options: ["None โ I don't drink", "Rarely (1โ2 drinks / month)", "Occasionally (1โ3 drinks / week)", "Regularly (4โ7 drinks / week)", "Daily or near-daily", "Binge pattern on weekends"] },
{ id: "tobaccoUse", type: "choice", section: "05", q: "Current tobacco or nicotine use?", required: true,
options: ["Never used", "Former user โ quit 1+ years ago", "Former user โ quit less than 1 year ago", "Current โ cigarettes", "Current โ vaping / e-cigarettes", "Current โ nicotine pouches", "Occasional / social only"] },
{ id: "currentSupplements", type: "long", section: "05",
q: "What supplements are you currently taking?",
hint: "List everything: protein powder, creatine, vitamins, pre-workout, herbs, hormonal support, etc." },
// โโ 06 Lifestyle
{ id: "s06", type: "section", label: "06", title: "Lifestyle & Recovery", sub: "Sleep, stress, and daily habits" },
{ id: "avgSleep", type: "choice", section: "06", q: "Average nightly sleep duration?", required: true,
options: ["Less than 5 hours", "5โ6 hours", "6โ7 hours", "7โ8 hours", "8โ9 hours", "9+ hours"] },
{ id: "sleepQuality", type: "choice", section: "06", q: "How would you rate your sleep quality?", required: true,
options: ["Excellent โ wake up refreshed consistently", "Good โ mostly restful", "Fair โ inconsistent", "Poor โ rarely feel rested", "Very poor โ chronic sleep issues"] },
{ id: "stressLevel", type: "choice", section: "06", q: "Current daily stress level?", required: true,
options: ["1โ2 (very low)", "3โ4 (low)", "5โ6 (moderate)", "7โ8 (high)", "9โ10 (extreme / unsustainable)"] },
{ id: "stressSources", type: "multi", section: "06", q: "Primary sources of stress in your life right now?",
options: ["Work / career demands", "Business ownership", "Financial pressure", "Relationship / marriage", "Family responsibilities", "Parenthood (current or upcoming)", "Health concerns", "Life transition", "Low stress currently"] },
{ id: "wearable", type: "choice", section: "06", q: "Do you use a fitness or recovery wearable?",
options: ["Yes โ WHOOP", "Yes โ Oura Ring", "Yes โ Garmin", "Yes โ Apple Watch", "Yes โ Fitbit / other", "No โ but I'm open to it", "No โ not interested"] },
{ id: "dailySchedule", type: "long", section: "06", required: true,
q: "Walk us through your typical weekday schedule.",
hint: "Wake time, work hours, training window, family time, bedtime. We design around your real life." },
// โโ 07 Mindset
{ id: "s07", type: "section", label: "07", title: "Mindset & Commitment", sub: "The foundation everything is built on" },
{ id: "pastFailures", type: "long", section: "07", required: true,
q: "What has stopped you from achieving your goals in the past?",
hint: "Be brutally honest. Consistency? Knowledge? Accountability? Identify the real pattern, not the surface reason." },
{ id: "accountability", type: "choice", section: "07", q: "How important is external accountability to your success?", required: true,
options: ["Critical โ I need someone checking on me", "Very important โ significantly improves consistency", "Moderately helpful โ I can self-direct but benefit from it", "Minimal โ I'm highly self-directed", "I prefer complete independence"] },
{ id: "coachingStyle", type: "choice", section: "07", q: "What coaching style do you respond best to?",
options: ["Direct and no-nonsense โ tell me exactly what to do", "Collaborative โ I want to understand the why", "Supportive / encouraging", "Challenge-oriented โ push me harder than I push myself", "Data-driven โ show me the numbers", "Flexible โ adapt week by week"] },
{ id: "willingnessToChange", type: "choice", section: "07", q: "How willing are you to change your current habits completely if necessary?", required: true,
options: ["1โ2 โ I want results but minimal disruption", "3โ4 โ I'll change some things", "5โ6 โ Open to moderate changes", "7โ8 โ I'll do what it takes", "9โ10 โ I'm all in. Tell me exactly what to do."] },
{ id: "programType", type: "choice", section: "07", q: "What type of coaching are you looking for?", required: true,
options: ["Full 1-on-1 coaching (weekly check-ins, custom programming, nutrition, accountability)", "Online programming only (custom plan, self-directed)", "Nutrition coaching only", "Training programming only", "One-time strategy session / consultation", "Not sure yet โ let's discuss"] },
{ id: "investmentLevel", type: "choice", section: "07", q: "Realistic monthly investment range for coaching?", required: true,
options: ["Under $150 / month", "$150โ$300 / month", "$300โ$500 / month", "$500โ$750 / month", "$750โ$1,000 / month", "$1,000+ / month", "Budget is not the primary concern โ I want the best outcome"] },
// โโ 08 Specialized (Optional)
{ id: "s08", type: "section", label: "08", title: "Specialized Health Goals", sub: "Hormonal, fertility & advanced health โ optional but valuable", optional: true },
{ id: "fertilityGoal", type: "choice", section: "08",
q: "Is fertility optimization a current goal?",
options: ["Not applicable", "Yes โ actively trying to conceive", "Yes โ preparing for IUI / IVF", "Yes โ general reproductive health", "Yes โ post-TRT fertility recovery", "Not currently but planning ahead"] },
{ id: "hormonalFocus", type: "choice", section: "08",
q: "Is hormonal optimization a primary focus?",
options: ["Not a primary focus", "Yes โ natural testosterone optimization", "Yes โ post-TRT / HPTA recovery", "Yes โ thyroid or adrenal support", "Yes โ under physician supervision", "Yes โ working with a fertility clinic"] },
{ id: "hormonalSymptoms", type: "multi", section: "08",
q: "Are you experiencing any hormonal symptoms? Select all that apply.",
options: ["Low energy / fatigue", "Low libido", "Mood changes / depression / anxiety", "Poor sleep quality", "Weight gain (midsection)", "Brain fog", "Poor recovery from training", "Low motivation", "Night sweats", "None currently"] },
{ id: "specialNotes", type: "long", section: "08",
q: "Anything else about your health or specialized goals we should know?",
hint: "This is a confidential space. Share anything that helps us build the most accurate protocol for your situation." },
// โโ 09 Final
{ id: "s09", type: "section", label: "09", title: "Final Questions", sub: "Last things before we review your application" },
{ id: "startReadiness", type: "choice", section: "09", q: "How ready are you to start โ right now?", required: true,
options: ["100% ready โ I'm starting today", "Ready โ this week", "Ready โ this month", "Almost ready โ just need to sort a few things", "Exploring options โ not committed yet"] },
{ id: "whyNow", type: "long", section: "09", required: true,
q: "What made you reach out specifically at this time?",
hint: "Was it a post you saw? Something someone said? A moment you had? A deadline approaching? Tell us the real story." },
{ id: "anythingElse", type: "long", section: "09",
q: "Is there anything else you want us to know?",
hint: "This is your space. Anything that doesn't fit above โ say it here." },
{ id: "referralName", type: "text", section: "09",
q: "Were you referred by a current client?", placeholder: "Their name, or leave blank" },
{ id: "consent", type: "agree", section: "09", required: true,
q: "One last thing โ please confirm the following:",
statement: "I confirm the information in this application is honest and accurate to the best of my knowledge. I understand this is a coaching service and not a medical practice, and that health-related decisions will be made in consultation with my licensed healthcare providers." },
// Thank you
{ id: "thankyou", type: "thankyou",
heading: "Application Received.",
sub: "We review every application personally and will be in touch within 24โ48 hours. Check your email for a confirmation.",
steps: [
{ n: "01", label: "Coach reviews your application within 24 hrs" },
{ n: "02", label: "Strategy call scheduled to discuss your protocol" },
{ n: "03", label: "Custom program delivered within 5 business days" },
]
}
];
const KEYBOARD_HINT = "Press Enter โต";
const MULTI_HINT = "Choose all that apply ยท Press Enter to continue";
export default function TypeformIntake() {
const [idx, setIdx] = useState(0);
const [answers, setAnswers] = useState({});
const [inputVal, setInputVal] = useState("");
const [error, setError] = useState("");
const [animDir, setAnimDir] = useState("up"); // "up" | "down"
const [visible, setVisible] = useState(true);
const inputRef = useRef(null);
const q = QUESTIONS[idx];
const total = QUESTIONS.filter(q => q.type !== "welcome" && q.type !== "thankyou" && q.type !== "section").length;
const answered = QUESTIONS.filter((q, i) => i < idx && q.type !== "welcome" && q.type !== "thankyou" && q.type !== "section").length;
const pct = Math.round((answered / total) * 100);
// focus input on question change
useEffect(() => {
if (inputRef.current) setTimeout(() => inputRef.current?.focus(), 320);
}, [idx]);
// sync inputVal with existing answer when navigating back
useEffect(() => {
if (q && answers[q.id] !== undefined) {
const v = answers[q.id];
if (typeof v === "string") setInputVal(v);
else setInputVal("");
} else {
setInputVal("");
}
}, [idx]);
const transition = useCallback((nextIdx, dir = "up") => {
setAnimDir(dir);
setVisible(false);
setError("");
setTimeout(() => {
setIdx(nextIdx);
setVisible(true);
}, 240);
}, []);
const shouldSkip = useCallback((question) => {
if (!question.conditional) return false;
return answers[question.conditional.field] !== question.conditional.value;
}, [answers]);
const nextQuestion = useCallback((overrideIdx) => {
let next = (overrideIdx ?? idx) + 1;
while (next < QUESTIONS.length && shouldSkip(QUESTIONS[next])) next++;
return next;
}, [idx, shouldSkip]);
const prevQuestion = useCallback(() => {
let prev = idx - 1;
while (prev > 0 && shouldSkip(QUESTIONS[prev])) prev--;
transition(prev, "down");
}, [idx, transition, shouldSkip]);
const advance = useCallback((val) => {
const cur = q;
// Validate required
if (cur.required) {
const v = val ?? answers[cur.id];
const empty = !v || (Array.isArray(v) && v.length === 0) || v === "";
if (empty) { setError("This field is required โ please fill it in before continuing."); return; }
}
if (val !== undefined) setAnswers(prev => ({ ...prev, [cur.id]: val }));
transition(nextQuestion());
}, [q, answers, transition, nextQuestion]);
const handleTextNext = () => {
const val = inputVal.trim();
if (q.required && !val) { setError("This field is required."); return; }
setAnswers(prev => ({ ...prev, [q.id]: val }));
transition(nextQuestion());
};
const handleKeyDown = (e) => {
if (e.key === "Enter" && !e.shiftKey && q.type !== "long") {
e.preventDefault();
handleTextNext();
}
};
const handleChoice = (opt) => {
setAnswers(prev => ({ ...prev, [q.id]: opt }));
setTimeout(() => transition(nextQuestion()), 220);
};
const toggleMulti = (opt) => {
const cur = answers[q.id] || [];
const next = cur.includes(opt) ? cur.filter(o => o !== opt) : [...cur, opt];
setAnswers(prev => ({ ...prev, [q.id]: next }));
setError("");
};
const handleAgree = (agreed) => {
if (!agreed) { setError("You must agree to proceed."); return; }
setAnswers(prev => ({ ...prev, [q.id]: true }));
transition(nextQuestion());
};
// โโ RENDER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
const slideStyle = {
opacity: visible ? 1 : 0,
transform: visible ? "translateY(0)" : animDir === "up" ? "translateY(28px)" : "translateY(-28px)",
transition: "opacity 0.24s ease, transform 0.24s ease",
};
const isMultiSelected = (opt) => (answers[q.id] || []).includes(opt);
const multiCount = (answers[q.id] || []).length;
return (
{/* Progress */}
{/* Top bar */}
{q.type !== "welcome" && q.type !== "thankyou" && (
{/* Bottom brand bar */}
{q.type !== "welcome" && q.type !== "thankyou" && (
);
}
High Performance Coaching
{answered} / {total} questions
)}
{/* Main content */}
{/* โโ WELCOME โโ */}
{q.type === "welcome" && (
)}
{/* โโ SECTION HEADER โโ */}
{q.type === "section" && (
{q.optional && (
)}
)}
{/* โโ TEXT / EMAIL / TEL / NUMBER / DATE โโ */}
{(q.type === "text" || q.type === "email" || q.type === "tel" || q.type === "number" || q.type === "date") && (
)}
{/* โโ NAV (back) โโ */}
{q.type !== "welcome" && q.type !== "thankyou" && idx > 1 && (
{q.tag}
{q.heading}
{q.sub}
Your responses are strictly confidential
{q.label}
{q.optional &&
Optional Section
}
{q.title}
{q.sub}
{q.section &&
)}
{/* โโ LONG TEXT โโ */}
{q.type === "long" && (
Section {q.section}
}
{q.q} {q.required && *}
{q.hint &&{q.hint}
} { setInputVal(e.target.value); setError(""); }} onKeyDown={handleKeyDown} /> {error &&{error}
}
{KEYBOARD_HINT}
{q.section &&
)}
{/* โโ CHOICE โโ */}
{q.type === "choice" && (
Section {q.section}
}
{q.q} {q.required && *}
{q.hint &&{q.hint}
}
{q.section &&
)}
{/* โโ MULTI SELECT โโ */}
{q.type === "multi" && (
Section {q.section}
}
{q.q} {q.required && *}
{q.options.map((opt, oi) => {
const letter = String.fromCharCode(65 + oi);
const isSelected = answers[q.id] === opt;
return (
);
})}
{error && {error}
}
{q.section &&
)}
{/* โโ AGREE โโ */}
{q.type === "agree" && (
Section {q.section}
}
{q.q} {q.required && *}
{MULTI_HINT}
{q.options.map(opt => {
const sel = isMultiSelected(opt);
return (
{error && toggleMulti(opt)}>
);
})}
{sel && "โ"}
{opt}
{error}
}
{q.section &&
)}
{/* โโ THANK YOU โโ */}
{q.type === "thankyou" && (
Section {q.section}
}
{q.q}
{q.statement}
{error && {error}
}โ
{q.heading}
{q.sub}
{q.steps.map(step => (
))}
{step.n}
{step.label}
or use keyboard
)}
High Performance Coaching
{pct}%
)}