-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsingleChallenge.tsx
More file actions
71 lines (66 loc) · 1.95 KB
/
singleChallenge.tsx
File metadata and controls
71 lines (66 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Button, CategoryTag, Heading, Text } from 'ui';
import Image from 'next/image';
import type { Challenge } from '../../../../types/types';
import { useState } from 'react';
import { LoginModal } from 'organisms/loginModal/loginModal';
import { useUser } from '@auth0/nextjs-auth0';
import { SendSolutionModal } from 'organisms/sendSolutionModal/sendSolutionModal';
type SingleChallengePageProps = {
challenge: Challenge;
};
export const SingleChallengePage = ({
challenge,
}: SingleChallengePageProps) => {
const [showModal, setShowModal] = useState(false);
const onClickHandler = () => {
setShowModal((prevState) => !prevState);
};
const { isLoading, user } = useUser();
return (
<main className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<LoginModal
isOpen={!user && !isLoading && showModal}
onClose={onClickHandler}
/>
<SendSolutionModal
isOpen={Boolean(user) && !isLoading && showModal}
onClose={onClickHandler}
/>
<div className="flex items-baseline justify-between border-b border-gray-200 pt-10 pb-6">
<Heading
tag="h2"
size="large"
className="text-4xl font-bold tracking-tight text-gray-900"
>
{challenge?.title}
</Heading>
<div className="flex items-center">
<Button variant="primary" onClick={onClickHandler}>
Prześlij swoje rozwiązanie
</Button>
</div>
</div>
<section aria-labelledby="challenges-heading" className="pt-6 pb-24">
<div className="flex flex-col md:flex-row">
<Image
src={challenge?.image}
alt=""
width="1200"
height="1200"
className="h-full w-full rounded-lg md:w-1/3"
/>
<div className="pt-5 md:pl-10 md:pt-0">
<ul className="pb-5">
{challenge?.tags.map((tag, id) => (
<CategoryTag label={tag} key={id} />
))}
</ul>
<Text size="medium" variant="default" tag="p">
{challenge?.description}
</Text>
</div>
</div>
</section>
</main>
);
};