import React from "react"; import DatingPreferencesViewer from "./dating-preferences"; import VoiceViewer from "./voice-viewer"; import PersonalityViewer from "./personality-viewer"; import { SwitchMiiInstructions } from "@/types"; import { Icon } from "@iconify/react"; import { COLORS } from "@/lib/switch"; interface Props { instructions: Partial; } interface SectionProps { name: string; instructions: Partial; children?: React.ReactNode; isSubSection?: boolean; } const ORDINAL_SUFFIXES: Record = { one: "st", two: "nd", few: "rd", other: "th", }; const ordinalRules = new Intl.PluralRules("en-US", { type: "ordinal" }); function not(value: any) { return value !== undefined && value !== null; } function GridPosition({ index, cols = 5 }: { index: number; cols?: number }) { const row = Math.floor(index / cols) + 1; const col = (index % cols) + 1; const rowSuffix = ORDINAL_SUFFIXES[ordinalRules.select(row)]; const colSuffix = ORDINAL_SUFFIXES[ordinalRules.select(col)]; return `${row}${rowSuffix} row, ${col}${colSuffix} column`; } function ColorPosition({ color }: { color: number | undefined | null }) { if (color === undefined || color === null) return null; if (color <= 7) { return (
Color menu on left,
); } if (color >= 108) { return (
Outside color menu,
); } return (
Color menu on right,
); } interface TableCellProps { label: string; children: React.ReactNode; } function TableCell({ label, children }: TableCellProps) { return ( {label} {children} ); } function Section({ name, instructions, children, isSubSection }: SectionProps) { if (typeof instructions !== "object" || !instructions) return null; const color = "color" in instructions ? instructions.color : undefined; const height = "height" in instructions ? instructions.height : undefined; const distance = "distance" in instructions ? instructions.distance : undefined; const rotation = "rotation" in instructions ? instructions.rotation : undefined; const size = "size" in instructions ? instructions.size : undefined; const stretch = "stretch" in instructions ? instructions.stretch : undefined; return (

{name}

{not(color) && ( )} {not(height) && {height}} {not(distance) && {distance}} {not(rotation) && {rotation}} {not(size) && {size}} {not(stretch) && {stretch}} {children}
); } export default function MiiInstructions({ instructions }: Props) { if (Object.keys(instructions).length === 0) return null; const { head, hair, eyebrows, eyes, nose, lips, ears, glasses, other, height, weight, birthday, datingPreferences, voice, personality } = instructions; return ( <> {head && (
{not(head.skinColor) && ( )}
)} {hair && (
{not(hair.subColor) && ( )} {not(hair.subColor2) && ( )} {not(hair.style) && {hair.style}} {not(hair.isFlipped) && {hair.isFlipped ? "Yes" : "No"}}
)} {eyebrows &&
} {eyes && (
)} {nose &&
} {lips && (
{not(lips.hasLipstick) && {lips.hasLipstick ? "Yes" : "No"}}
)} {ears &&
} {glasses && (
{not(glasses.ringColor) && ( )} {not(glasses.shadesColor) && ( )}
)} {other && (
{other.moustache && other.moustache.isFlipped && {other.moustache.isFlipped ? "Yes" : "No"}}
)} {(height || weight || datingPreferences || voice || personality) && (

Misc

{height && (
)} {weight && (
)} {birthday && (

Birthday

{birthday.day && {birthday.day}} {birthday.month && {birthday.month}} {birthday.age && {birthday.age}} {birthday.dontAge && {birthday.dontAge ? "Yes" : "No"}}
)} {datingPreferences && (

Dating Preferences

)} {voice && (

Voice

)} {personality && (

Personality

)}
)} ); }