Skip to content

Commit

Permalink
OV-369: + add constants
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-lacorazza committed Sep 26, 2024
1 parent 9fa778d commit a6ee73f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion frontend/src/bundles/common/components/stepper/stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ type Properties = {

const Stepper: React.FC<Properties> = ({ steps, currentStep, onClickBack }) => {
const activeStepIndex = steps.indexOf(currentStep);
const progressPercent = (activeStepIndex / (steps.length - 1)) * 100;
const MAX_PERCENT = 100;
const progressPercent =
(activeStepIndex / (steps.length - 1)) * MAX_PERCENT;

const backButton = (
<IconButton
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/bundles/create-avatar/enums/steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const Steps = {
INSTRUCTIONS: 'Instructions',
UPLOAD: 'Upload',
CONSENT: 'Consent',
} as const;

export { Steps };
16 changes: 11 additions & 5 deletions frontend/src/bundles/create-avatar/pages/create-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@ import {
} from '~/bundles/common/hooks/hooks.js';

import { Consent, Instruction } from '../components/components.js';
import { Steps } from '../enums/steps.js';
import styles from './styles.module.css';

const CreateAvatar: React.FC = () => {
const steps = useMemo(() => ['Instructions', 'Upload', 'Consent'], []);
const [step, setStep] = useState<string>('Instructions');
const steps = useMemo(
() => [Steps.INSTRUCTIONS, Steps.UPLOAD, Steps.CONSENT],
[],
);
const [step, setStep] = useState<(typeof Steps)[keyof typeof Steps]>(
Steps.INSTRUCTIONS,
);

const renderStepContent = (step: string): JSX.Element | null => {
switch (step) {
case 'Instructions': {
case Steps.INSTRUCTIONS: {
return <Instruction onClickNext={nextStep} />;
}
case 'Upload': {
case Steps.UPLOAD: {
return <UploadVideo onClickNext={nextStep} />;
}
case 'Consent': {
case Steps.CONSENT: {
return <Consent />;
}
default: {
Expand Down

0 comments on commit a6ee73f

Please sign in to comment.