-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Janderson Souza Matias
authored and
Janderson Souza Matias
committed
Aug 2, 2023
1 parent
43df384
commit 8ff6aa8
Showing
8 changed files
with
1,329 additions
and
1,287 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ import { | |
Box, | ||
Button, | ||
Center, | ||
Flex, | ||
Heading, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import Icon from "@/components/Base/Icon"; | ||
import { IAnswer, ICompetence, ISession } from "@/types"; | ||
import { | ||
Drawer, | ||
DrawerOverlay, | ||
DrawerContent, | ||
DrawerCloseButton, | ||
DrawerHeader, | ||
DrawerBody, | ||
HStack, | ||
Text, | ||
VStack, | ||
Divider, | ||
} from "@chakra-ui/react"; | ||
import { useEffect, useState } from "react"; | ||
|
||
type Props = { | ||
session?: ISession; | ||
onClose: () => void; | ||
}; | ||
|
||
const SessionView: React.FC<Props> = ({ session, onClose }) => { | ||
const [competencies, setCompetencies] = useState<ICompetence[]>([]); | ||
|
||
useEffect(() => { | ||
if (session) { | ||
setCompetencies( | ||
session.answers | ||
.reduce((acc: ICompetence[], item: IAnswer) => { | ||
const competence = acc.find( | ||
(competence) => competence.id === item.question.competence_id | ||
); | ||
if (competence) { | ||
competence.answers?.push(item); | ||
return acc; | ||
} else { | ||
return [ | ||
...acc, | ||
{ ...(item.question.competence as any), answers: [item] }, | ||
]; | ||
} | ||
}, [] as ICompetence[]) | ||
.reverse() | ||
); | ||
} else { | ||
setCompetencies([]); | ||
} | ||
}, [session]); | ||
|
||
return ( | ||
<Drawer isOpen={!!session} placement="right" onClose={onClose} size="md"> | ||
<DrawerOverlay /> | ||
<DrawerContent roundedLeft={14}> | ||
<DrawerCloseButton mt={2} color="Primary.$200" /> | ||
<DrawerHeader>{"View session"}</DrawerHeader> | ||
|
||
<DrawerBody> | ||
<HStack mb="4px" alignItems="center"> | ||
<Icon name="university" size={20} /> | ||
<Text fontWeight="semibold">School</Text> | ||
</HStack> | ||
<Text>{session?.school.name}</Text> | ||
<Divider my="8px" /> | ||
|
||
<HStack mb="4px" alignItems="center"> | ||
<Icon name="user-alt" size={20} /> | ||
<Text fontWeight="semibold">Coach</Text> | ||
</HStack> | ||
<Text>{session?.coach.name}</Text> | ||
<Divider my="8px" /> | ||
|
||
<HStack mb="4px" alignItems="center"> | ||
<Icon name="graduation-cap" size={20} /> | ||
<Text fontWeight="semibold">Teacher</Text> | ||
</HStack> | ||
<Text>{session?.teacher.name}</Text> | ||
<Divider my="8px" /> | ||
|
||
{session?.feedbacks[0] && ( | ||
<VStack w="100%" mb="20px" py="16px" borderBottom="1px solid #eee"> | ||
<Text w="100%" mb="16px" fontSize={20} fontWeight="semibold"> | ||
Feedback annotation | ||
</Text> | ||
<Text w="100%">{session?.feedbacks[0].value}</Text> | ||
</VStack> | ||
)} | ||
{competencies.map((competence, index) => ( | ||
<div> | ||
<Text fontSize={20} fontWeight="semibold"> | ||
{index + 1} | ||
{". "} | ||
{competence.title} | ||
</Text> | ||
{competence.answers?.map((answer) => ( | ||
<div> | ||
<p>{answer.question.title}</p> | ||
<Text fontSize="12px" mb="8px"> | ||
{answer.question.description} | ||
</Text> | ||
<HStack mb="16px"> | ||
{[1, 2, 3, 4, 5].map((value) => | ||
value <= answer.value ? ( | ||
<Icon name="star-solid" color="#E89F0C" /> | ||
) : ( | ||
<Icon name="star-solid" color="#C7CBD1" /> | ||
) | ||
)} | ||
</HStack> | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
</DrawerBody> | ||
</DrawerContent> | ||
</Drawer> | ||
); | ||
}; | ||
|
||
export default SessionView; |
Oops, something went wrong.