diff --git a/src/components/builder/center/Artboard.js b/src/components/builder/center/Artboard.js index 3033804c..e05bba0b 100644 --- a/src/components/builder/center/Artboard.js +++ b/src/components/builder/center/Artboard.js @@ -1,22 +1,20 @@ import React, { useContext } from "react"; import { Helmet } from "react-helmet"; -import ResumeContext from "../../../contexts/ResumeContext"; +import { useSelector } from "../../../contexts/ResumeContext"; import TemplateContext from "../../../contexts/TemplateContext"; import Onyx from "../../../templates/Onyx"; import styles from "./Artboard.module.css"; const Artboard = () => { const { blocks, colors } = useContext(TemplateContext); - const { state } = useContext(ResumeContext); + const state = useSelector((state) => state), + { id, name } = state; return (
- {state.name} | Reactive Resume - + {name} | Reactive Resume +
diff --git a/src/components/builder/left/LeftSidebar.js b/src/components/builder/left/LeftSidebar.js index bb5fcb5c..284ab1e4 100644 --- a/src/components/builder/left/LeftSidebar.js +++ b/src/components/builder/left/LeftSidebar.js @@ -1,12 +1,9 @@ -import React, { Fragment, useContext } from "react"; -import ResumeContext from "../../../contexts/ResumeContext"; +import React, { Fragment } from "react"; import sections from "../../../data/leftSections"; import LeftNavbar from "./LeftNavbar"; import styles from "./LeftSidebar.module.css"; const LeftSidebar = () => { - const { state } = useContext(ResumeContext); - return (
@@ -14,7 +11,7 @@ const LeftSidebar = () => {
{sections.map(({ id, name, event, component: Component }) => ( - +
))} diff --git a/src/components/builder/lists/List.js b/src/components/builder/lists/List.js index 447a5a91..5454367a 100644 --- a/src/components/builder/lists/List.js +++ b/src/components/builder/lists/List.js @@ -3,6 +3,7 @@ import moment from "moment"; import React, { useContext } from "react"; import { MdAdd } from "react-icons/md"; import ModalContext from "../../../contexts/ModalContext"; +import { useSelector } from "../../../contexts/ResumeContext"; import Button from "../../shared/Button"; import EmptyList from "./EmptyList"; import styles from "./List.module.css"; @@ -10,7 +11,6 @@ import ListItem from "./ListItem"; const List = ({ path, - items, title, titlePath, subtitle, @@ -19,6 +19,7 @@ const List = ({ textPath, event, }) => { + const items = useSelector((state) => get(state, path, [])); const { emitter } = useContext(ModalContext); const handleAdd = () => emitter.emit(event); diff --git a/src/components/builder/lists/ListItem.js b/src/components/builder/lists/ListItem.js index a86d2ca4..48b5a2f6 100644 --- a/src/components/builder/lists/ListItem.js +++ b/src/components/builder/lists/ListItem.js @@ -1,8 +1,8 @@ import { Menu, MenuItem } from "@material-ui/core"; -import React, { useContext, useState } from "react"; +import React, { useState } from "react"; import { IoIosArrowDown, IoIosArrowUp } from "react-icons/io"; import { MdMoreVert } from "react-icons/md"; -import ResumeContext from "../../../contexts/ResumeContext"; +import { useDispatch } from "../../../contexts/ResumeContext"; import styles from "./ListItem.module.css"; const ListItem = ({ @@ -16,7 +16,7 @@ const ListItem = ({ onEdit, }) => { const [anchorEl, setAnchorEl] = useState(null); - const { dispatch } = useContext(ResumeContext); + const dispatch = useDispatch(); const handleClick = (event) => setAnchorEl(event.currentTarget); diff --git a/src/components/builder/sections/Awards.js b/src/components/builder/sections/Awards.js index 49b5100e..f4569d59 100644 --- a/src/components/builder/sections/Awards.js +++ b/src/components/builder/sections/Awards.js @@ -1,11 +1,9 @@ -import { get } from "lodash"; import React from "react"; import Heading from "../../shared/Heading"; import List from "../lists/List"; const Awards = ({ id, name, event, state }) => { const path = `${id}.items`; - const items = get(state, path, []); return (
@@ -13,7 +11,6 @@ const Awards = ({ id, name, event, state }) => { { const path = `${id}.items`; - const items = get(state, path, []); return (
@@ -13,7 +11,6 @@ const Certifications = ({ id, name, event, state }) => { { const path = `${id}.items`; - const items = get(state, path, []); return (
@@ -13,7 +11,6 @@ const Education = ({ id, name, event, state }) => { { - const fileInputRef = useRef(null); - const { uploadPhotograph } = useContext(StorageContext); - - const handleIconClick = () => { - fileInputRef.current.click(); - }; - - const handleImageUpload = (e) => { - const file = e.target.files[0]; - uploadPhotograph(file); - }; - return (
Profile -
-
handleKeyDown(e, handleIconClick)} - > - - -
- -
+
- - + +
- +
- - + +
- - + +

- - - + + +
); }; diff --git a/src/components/builder/sections/Skills.js b/src/components/builder/sections/Skills.js new file mode 100644 index 00000000..c5b24177 --- /dev/null +++ b/src/components/builder/sections/Skills.js @@ -0,0 +1,17 @@ +import React from "react"; +import Heading from "../../shared/Heading"; +import List from "../lists/List"; + +const Skills = ({ id, name, event }) => { + const path = `${id}.items`; + + return ( +
+ {name} + + +
+ ); +}; + +export default Skills; diff --git a/src/components/builder/sections/Social.js b/src/components/builder/sections/Social.js index dd5c7839..322b4bf0 100644 --- a/src/components/builder/sections/Social.js +++ b/src/components/builder/sections/Social.js @@ -1,11 +1,9 @@ -import { get } from "lodash"; import React from "react"; import Heading from "../../shared/Heading"; import List from "../lists/List"; -const Social = ({ id, name, event, state }) => { +const Social = ({ id, name, event }) => { const path = `${id}.items`; - const items = get(state, path, []); return (
@@ -13,7 +11,6 @@ const Social = ({ id, name, event, state }) => { { const path = `${id}.items`; - const items = get(state, path, []); return (
{name} - +
); }; diff --git a/src/components/shared/Input.js b/src/components/shared/Input.js index e110318b..106d2bf1 100644 --- a/src/components/shared/Input.js +++ b/src/components/shared/Input.js @@ -1,9 +1,9 @@ import cx from "classnames"; import { get, isFunction } from "lodash"; -import React, { useContext } from "react"; +import React, { useMemo } from "react"; import { MdClose } from "react-icons/md"; import { v4 as uuidv4 } from "uuid"; -import ResumeContext from "../../contexts/ResumeContext"; +import { useDispatch, useSelector } from "../../contexts/ResumeContext"; import { handleKeyDown } from "../../utils"; import styles from "./Input.module.css"; @@ -11,8 +11,8 @@ const Input = ({ name, path, label, - value, error, + value, onBlur, touched, checked, @@ -25,86 +25,109 @@ const Input = ({ type = "text", }) => { const uuid = uuidv4(); - const { state, dispatch } = useContext(ResumeContext); + const stateValue = useSelector((state) => get(state, path)); + const dispatch = useDispatch(); - const inputProps = (path) => ({ - value: get(state, path) || "", - onChange: (e) => { - dispatch({ - type: "on_input", - payload: { - path, - value: e.target.value, - }, - }); - }, - }); + value = value || stateValue; + onChange = isFunction(onChange) + ? onChange + : (e) => { + dispatch({ + type: "on_input", + payload: { + path, + value: e.target.value, + }, + }); + }; - return ( -
-