Files
TheGame/packages/web/utils/setupOptions.tsx
δυς 317ba7c9e5 Refactor Setup Wizard & Profile Modal Configuration Panes (#1127)
* incorporating configuration panes from #1078

* standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪

* switching box type, ambiguating overly-specific names, & massaging heights 📱

* reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬

* fixing render of color disposition selector 🕍

* self code review changes: removed some `;`s 🎋

* getting yarn typecheck && yarn lint to pass post rebase 🏇🏾

* handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺

* `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊

* properly encapsulating ETH address regex 🚲

* adding some tasks 🏥

* fixed skills layou

* handling default values? 

* corrections for revision comments from @dan13ram (UI bugs to follow) 🌋

* cleaning up memberships & explorer type 🧫

* refactoring player roles configuration and display to use `WizardPane` 🔮

* bunches of mobile fixes & repairing the display of deserialized skills 📟

* removing redirect in static props & formatting memberships display for responsiveness 🪆

* improving comprehensability of `/me` & more mobile tweaking 🍦

* various spacing fixes & a “try again” button for connecting 🫕

* maybe fixed issue with saving images for fields with default values 🇩🇿

* switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰

* fix: removed verify on brightId button

* fix: clean up username page

* formatting & fixing skills issues 🥩

* reformatting NFT display 🚂

* adding `/join` 🚉

* style: peth's suggestions

* added mainnet required message

* style: slight tweak of megamenu item positions

* chore(release): 0.2.0

Co-authored-by: tenfinney <scott@1box.onmicrosoft.com>
Co-authored-by: dan13ram <dan13ram@gmail.com>
Co-authored-by: vidvidvid <weetopol@gmail.com>
2022-02-28 14:06:16 -05:00

140 lines
2.8 KiB
TypeScript

import { Maybe } from '@metafam/utils';
import { ReactElement } from 'react';
export type SetupStep = {
label: string;
slug?: string;
sectionIndex: number;
};
export type SetupSection = {
label: string;
title: {
[any: string]: string | undefined | ReactElement;
};
};
export class SetupOptions {
sections: SetupSection[] = [
{
label: 'About You',
title: { base: 'About', sm: '1. About You' },
},
{
label: 'Professional Profile',
title: {
base: 'Pro',
sm: <>2. Pro&shy;fess&shy;ional</>,
lg: <>2. Pro&shy;fess&shy;ional Profile</>,
},
},
{
label: 'Player Profile',
title: {
base: 'Player',
sm: '3. Player',
lg: '3. Player Profile',
},
},
{
label: 'Start Playing',
title: {
base: 'Play',
sm: '4. Play',
md: '4. Start Playing',
},
},
];
steps: SetupStep[] = [
{
label: 'Username',
slug: 'username',
sectionIndex: 0,
},
{
label: 'Color Disposition',
slug: 'colorDisposition',
sectionIndex: 0,
},
{
label: 'Time Zone',
slug: 'timeZone',
sectionIndex: 0,
},
{
label: 'Skills',
slug: 'skills',
sectionIndex: 1,
},
{
label: 'Availability',
slug: 'availability',
sectionIndex: 1,
},
{
label: 'Player Type',
slug: 'playerType',
sectionIndex: 2,
},
{
label: 'Roles',
slug: 'roles',
sectionIndex: 2,
},
{
label: 'Pronouns',
slug: 'pronouns',
sectionIndex: 2,
},
{
label: 'Memberships',
slug: 'memberships',
sectionIndex: 2,
},
{
label: 'Start Playing',
slug: 'complete',
sectionIndex: 3,
},
];
stepIndexMatchingSlug(slug: Maybe<string>): number {
return this.steps.findIndex((step) => step.slug === slug);
}
get numSteps(): number {
return this.steps.length;
}
isLastStep(stepIndex: number): boolean {
return stepIndex >= this.numSteps - 1;
}
isFinalStepOfSection(stepIndex: number): boolean {
if (this.isLastStep(stepIndex)) return true;
return (
this.steps[stepIndex].sectionIndex !==
this.steps[stepIndex + 1].sectionIndex
);
}
progressWithinSection(stepIndex: number): number {
const stepSectionIndex = this.steps[stepIndex].sectionIndex;
let stepsCompletedInSection = 0;
const stepsInSection = this.steps.reduce(
(count: number, step: SetupStep, index: number) => {
if (stepIndex === index) {
stepsCompletedInSection = count;
}
if (step.sectionIndex === stepSectionIndex) {
return count + 1;
}
return count;
},
0,
);
return Math.floor((stepsCompletedInSection + 1) * 100.0) / stepsInSection;
}
}