import React, { ReactNode, useState } from 'react'; import { Box, Button, ButtonBase, Typography } from '@mui/material'; import { ForgottenPassword } from './ForgottenPassword'; import { ForgottenUsername } from './ForgottenUsername'; import { OtherProblem } from './OtherProblem'; import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos'; enum PageType { ForgotPassword = 'password', ForgotUsername = 'username', Other = 'other', } type PageItem = { type: PageType; label: string; body: ReactNode; }; const pages: PageItem[] = [ { type: PageType.ForgotPassword, label: 'Forgotten password', body: }, { type: PageType.ForgotUsername, label: 'Forgotten username', body: }, { type: PageType.Other, label: 'Other problem', body: }, ]; export const HelpCenter = () => { const [page, setPage] = useState(); const currentPage = pages.find((pageItem) => pageItem.type === page); return ( {currentPage ? (

{currentPage.label}

{currentPage.body}
) : ( <> What can we help you with? {pages.map((pageItem) => ( setPage(pageItem.type)} > {pageItem.label} ))} )}
); };