Skip to content

Commit

Permalink
first book view
Browse files Browse the repository at this point in the history
  • Loading branch information
asanzo committed Oct 24, 2023
1 parent b157691 commit e6da8ec
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/components/book/BookView.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Typography } from "@mui/material";
import { Stack, Typography } from "@mui/material";
import { useParams } from "react-router-dom";
import { Book, getBook } from "../../staticData/books";
import { EmberView } from "../emberView/EmberView";
import { Header } from "../header/Header";
import HomeIcon from '@mui/icons-material/Home';
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { PBreadcrumbs } from "../PBreadcrumbs";
import { Challenge } from "../../staticData/challenges";

const Breadcrumb = (book: Book) => {
const {t} = useTranslation("books")
Expand All @@ -29,6 +29,32 @@ export const BookView = () => {

return <>
<Header CenterComponent={Breadcrumb(book)}/>
<EmberView path={`libros/${id}`}/>
<ChallengeList book={book} />
</>
}

const ChallengeList = ({book}: {book: Book}) => {
const {t} = useTranslation("books")
return <Stack>
<Typography variant="h1">{t(`${book.id}.title`)}</Typography>
{book.chapters.map( chapter => <Stack key={chapter.id}>
<Typography variant="h2">{t(`chapters.${chapter.id}.title`)}</Typography>
{chapter.groups.map( group => {
var groupTitle = t(`groups.${group.id}.title`)
return <Stack key={group.id}>
{groupTitle && <Typography variant="h3">{groupTitle}</Typography>}
<Stack direction="row">
{group.challenges.map( challenge =>
<ChallengeCard key={challenge.id} challenge={challenge} />
)}
</Stack>
</Stack>
})}
</Stack>)}
</Stack>
}

const ChallengeCard = ({challenge}:{challenge: Challenge}) => {
const {t} = useTranslation("challenges")
return <Typography>{t(`${challenge.id}.title`)}</Typography>
}

0 comments on commit e6da8ec

Please sign in to comment.