Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
613 changes: 310 additions & 303 deletions components/Header/index.tsx

Large diffs are not rendered by default.

208 changes: 108 additions & 100 deletions components/TopHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,115 +3,123 @@ import { useSession, signOut } from "next-auth/client";
import styled from "styled-components";
import { useClickAway } from "@geist-ui/react";
import { useBasics } from "../../lib/hooks/useBasics";
const TopHeader = () => {
const [session] = useSession();
const [isMenuVisible, setIsMenuVisible] = useState(false);
const ref = useRef(null);
const { expand, expandSideMenu } = useBasics();
import { RootStateOrAny, useDispatch, useSelector } from "react-redux";
import { basicsSlice, expandSideMenu } from "../../lib/reducers/utils-reducer";

useClickAway(ref, () => {
if (isMenuVisible) {
setIsMenuVisible(false);
} else {
return;
}
});
return (
<Wrapper>
<ExpandIcon onClick={expandSideMenu}> {expand ? `<` : `>`} </ExpandIcon>
<Profile
bg={session?.user?.image ?? ""}
onClick={() => setIsMenuVisible(true)}
>
{" "}
{isMenuVisible && (
<div ref={ref} className={"menumodal"}>
<a> Dashboard</a>
<a
href={`/api/auth/signout`}
className={"as"}
onClick={(e) => {
e.preventDefault();
signOut({ callbackUrl: process.env.BASEURL });
}}
>
Cerrar sesión
</a>
</div>
)}
</Profile>
</Wrapper>
);
const TopHeader = () => {
const [session] = useSession();
const [isMenuVisible, setIsMenuVisible] = useState(false);
const ref = useRef(null);
const dispatch = useDispatch();
const { expand } = useSelector((state: RootStateOrAny) => state.basics);
/* const { expandSideMenu } = basicsSlice.actions; */
console.log(expandSideMenu);
useClickAway(ref, () => {
if (isMenuVisible) {
setIsMenuVisible(false);
} else {
return;
}
});
return (
<Wrapper>
<ExpandIcon onClick={() => dispatch(expandSideMenu())}>
{" "}
{expand ? `<` : `>`}{" "}
</ExpandIcon>
<Profile
bg={session?.user?.image ?? ""}
onClick={() => setIsMenuVisible(true)}
>
{" "}
{isMenuVisible && (
<div ref={ref} className={"menumodal"}>
<a> Dashboard</a>
<a
href={`/api/auth/signout`}
className={"as"}
onClick={(e) => {
e.preventDefault();
signOut({ callbackUrl: process.env.BASEURL });
}}
>
Cerrar sesión
</a>
</div>
)}
</Profile>
</Wrapper>
);
};

export default TopHeader;

export const Wrapper = styled.div`
height: 10vh;
width: 100%;
padding: 0 2vw 0 0;
background: white;
display: grid;
grid-template-columns: 1fr 1fr;
align-items: center;
grid-area: header;
box-shadow: 0px 0px 5px 0px rgb(0 0 0 / 15%);
-webkit-box-shadow: 0px 0px 5px 0px rgb(0 0 0 / 15%);
z-index: 1;
.menumodal {
width: 15vw;
display: flex;
z-index: 100;
flex-direction: column;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
height: fit-content;
background: white;
top: 9vh;
right: 2vw;
position: absolute;
a {
font-family: "Inter", sans-serif;
position: relative;
text-decoration: none;
color: #333;
font-size: 13px;
padding: 10px 22px;
outline: none;
user-select: none;
border-bottom: 1px solid #eaeaea;
&:hover {
background: #efefefb3;
}
}
}
height: 10vh;
width: 100%;
padding: 0 2vw 0 0;
background: white;
display: grid;
grid-template-columns: 1fr 1fr;
align-items: center;
grid-area: header;
box-shadow: 0px 0px 5px 0px rgb(0 0 0 / 15%);
-webkit-box-shadow: 0px 0px 5px 0px rgb(0 0 0 / 15%);
z-index: 1;
.menumodal {
width: 15vw;
display: flex;
z-index: 100;
flex-direction: column;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
height: fit-content;
background: white;
top: 9vh;
right: 2vw;
position: absolute;
a {
font-family: "Inter", sans-serif;
position: relative;
text-decoration: none;
color: #333;
font-size: 13px;
padding: 10px 22px;
outline: none;
user-select: none;
border-bottom: 1px solid #eaeaea;
&:hover {
background: #efefefb3;
}
}
}
`;
export const Profile = styled.div`
width: 2vw;
height: 2vw;
align-self: center;
justify-self: end;
border-radius: 50%;
background-image: url("${(props) => props.bg}");
background-position: center;
background-size: cover;
cursor: pointer;
width: 2vw;
height: 2vw;
align-self: center;
justify-self: end;
border-radius: 50%;
background-image: url("${(props) => props.bg}");
background-position: center;
background-size: cover;
cursor: pointer;
`;

export const ExpandIcon = styled.div`
width: 14px;
height: 100%;
background-color: #603eec;
border-top-right-radius: 110px;
border-bottom-right-radius: 110px;
border-bottom: 0;
display: grid;
justify-content: center;
align-items: center;
color: white;
font-weight: 600;
cursor: pointer;
transition: 0.3s;
&:hover {
background: #603eec;
}
width: 14px;
height: 100%;
background-color: #603eec;
border-top-right-radius: 110px;
border-bottom-right-radius: 110px;
border-bottom: 0;
display: grid;
justify-content: center;
align-items: center;
color: white;
font-weight: 600;
cursor: pointer;
transition: 0.3s;
&:hover {
background: #603eec;
}
`;
96 changes: 96 additions & 0 deletions lib/reducers/education-block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
import { createSlice } from "@reduxjs/toolkit";
import { getMonth } from "../getMonth";
import { generateUid } from "../uuid";
import type { PayloadAction } from "@reduxjs/toolkit";

export interface EducationDto {
id: string;
institution: string;
startYear: number;
startMonth: number;
stillHere: boolean;
endYear: number;
endMonth: number;
city: string;
country: string;
grade: string;
studyArea: string;
website: string;
description: string;
}

export interface Education {
education: Array<EducationDto>;
}
const singleEducation: EducationDto = {
id: generateUid("id_"),
institution: "",
startYear: 2021,
startMonth: getMonth(),
stillHere: true,
endYear: 2021,
endMonth: getMonth(),
city: "",
country: "",
grade: "",
studyArea: "",
website: "",
description: "",
};

export const initialState = {
education: [singleEducation],
};

export const educationSlice = createSlice({
name: "education",
initialState,
reducers: {
addEducation: (state) => {
// Redux Toolkit allows us to write "mutating" logic in reducers. It
// doesn't actually mutate the state because it uses the Immer library,
// which detects changes to a "draft state" and produces a brand new
// immutable state based off those changes
state.education.push({
id: generateUid("id_"),
institution: "",
startYear: 2021,
startMonth: getMonth(),
stillHere: true,
endYear: 2021,
endMonth: getMonth(),
city: "",
country: "",
grade: "",
studyArea: "",
website: "",
description: "",
});
},
setEducationInfo: (state, action) => {
/* let newArr = [...state.education]; */
[...state.education].map((item) => {
if (item.id === action.payload.educId) {
if (action.payload.isCheckbox) {
return (item[action.payload.field] =
!item[action.payload.field]);
}
return (item[action.payload.field] = action.payload.value);
}
});
},
/* decrement: (state) => {
state.value -= 1
},
incrementByAmount: (state, action: PayloadAction<number>) => {
state.value += action.payload
}, */
},
});

// Action creators are generated for each case reducer function
export const { addEducation, setEducationInfo } = educationSlice.actions;

export default educationSlice.reducer;

/* import { getMonth } from "../getMonth";
import { generateUid } from "../uuid";

export interface EducationDto {
id: string;
Expand Down Expand Up @@ -83,3 +178,4 @@ const educationReducer = (state = initialState, action) => {
};

export default educationReducer;
*/
Loading