-
Notifications
You must be signed in to change notification settings - Fork 38
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
Showing
5 changed files
with
191 additions
and
226 deletions.
There are no files selected for viewing
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
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,98 @@ | ||
import { SettingsIcon } from "@chakra-ui/icons"; | ||
import { | ||
Button, | ||
Collapse, | ||
Menu, | ||
MenuButton, | ||
MenuItem, | ||
MenuItemOption, | ||
MenuList, | ||
MenuOptionGroup | ||
} from "@chakra-ui/react"; | ||
import React from "react"; | ||
import { GraphContext, UserContext } from "../Contexts"; | ||
|
||
const UserMenu = (props) => { | ||
const { register, logout, user } = React.useContext(UserContext); | ||
const { changeOrientacion, changeFinDeCarrera, getNode } = React.useContext( | ||
GraphContext | ||
); | ||
|
||
const OrientacionesMenuGroup = () => ( | ||
<MenuOptionGroup | ||
onChange={(value) => { | ||
changeOrientacion(value); | ||
register(); | ||
}} | ||
value={user.orientacion?.nombre || "none"} | ||
title="Orientación" | ||
type="radio" | ||
> | ||
<MenuItemOption type="checkbox" value={"none"}> | ||
No me decidí | ||
</MenuItemOption> | ||
|
||
{user.carrera?.orientaciones && | ||
user.carrera?.orientaciones.map((o) => ( | ||
<MenuItemOption type="checkbox" value={o.nombre}> | ||
{o.nombre} | ||
</MenuItemOption> | ||
))} | ||
</MenuOptionGroup> | ||
); | ||
|
||
return ( | ||
<Menu closeOnSelect={false}> | ||
<MenuButton | ||
w="20ch" | ||
textAlign="left" | ||
as={Button} | ||
leftIcon={<SettingsIcon />} | ||
size="sm" | ||
colorScheme="teal" | ||
> | ||
{user.padron} | ||
</MenuButton> | ||
|
||
<MenuList> | ||
{user.carrera.finDeCarrera && ( | ||
<MenuOptionGroup | ||
onChange={(value) => { | ||
changeFinDeCarrera(value); | ||
register(); | ||
}} | ||
value={user.finDeCarrera?.id || "none"} | ||
title="Fin de Carrera" | ||
type="radio" | ||
> | ||
<MenuItemOption type="checkbox" value={"none"}> | ||
No me decidí | ||
</MenuItemOption> | ||
|
||
{user.carrera?.finDeCarrera && | ||
Object.values(user.carrera.finDeCarrera).map((v) => ( | ||
<MenuItemOption type="checkbox" value={v.id}> | ||
{getNode(v.materia)?.materia} | ||
</MenuItemOption> | ||
))} | ||
</MenuOptionGroup> | ||
)} | ||
|
||
{user.carrera?.eligeOrientaciones === true && ( | ||
<OrientacionesMenuGroup /> | ||
)} | ||
<Collapse | ||
in={user.carrera?.eligeOrientaciones?.[user.finDeCarrera?.id]} | ||
unmountOnExit | ||
> | ||
<OrientacionesMenuGroup /> | ||
</Collapse> | ||
<MenuItem onClick={logout}> | ||
<strong>Cerrar Sesión</strong> | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
); | ||
}; | ||
|
||
export default UserMenu; |
Oops, something went wrong.