import React, { useState, useEffect } from 'react'; import { useNavigate, useLocation, useParams } from 'react-router-dom'; import { useAuth } from '../contexts/AuthContext'; import { useOrg } from '../contexts/OrgContext'; import { EMPLOYEE_QUESTIONS, EmployeeSubmissionAnswers, EmployeeQuestion } from '../employeeQuestions'; import { API_URL } from '../constants'; // Icon SVG Component const AuditlyIcon: React.FC = () => ( ); // Progress Bar Component for Section Headers const SectionProgressBar: React.FC<{ currentStep: number; totalSteps: number }> = ({ currentStep, totalSteps }) => { return (
{Array.from({ length: Math.min(7, totalSteps) }, (_, index) => { const isActive = index < Math.ceil((currentStep / totalSteps) * 7); return (
{isActive ? (
) : ( )}
); })}
); }; // Question Input Component const QuestionInput: React.FC<{ question: EmployeeQuestion; value: string; onChange: (value: string) => void; }> = ({ question, value, onChange }) => { switch (question.type) { case 'scale': return (
{question.prompt}
{question.scaleLabels?.min}
{Array.from({ length: question.scaleMax! - question.scaleMin! + 1 }, (_, index) => { const ratingValue = question.scaleMin! + index; const isSelected = parseInt(value) === ratingValue; return ( ); })}
{question.scaleLabels?.max}
); case 'yesno': return (
{question.prompt}
onChange('No')} className={`w-20 h-20 relative rounded-[999px] overflow-hidden cursor-pointer transition-colors ${value === 'No' ? 'bg-Neutrals-NeutralSlate800' : 'bg-Neutrals-NeutralSlate100 hover:bg-Neutrals-NeutralSlate200' }`} >
No
onChange('Yes')} className={`w-20 h-20 relative rounded-[999px] overflow-hidden cursor-pointer transition-colors ${value === 'Yes' ? 'bg-Neutrals-NeutralSlate800' : 'bg-Neutrals-NeutralSlate100 hover:bg-Neutrals-NeutralSlate200' }`} >
Yes
); case 'textarea': return (
{question.prompt}