- implement lists

- implement generic sections
- implement list actions
- implement error handlers
This commit is contained in:
Amruth Pillai
2020-07-08 05:01:50 +05:30
parent d7e86ddf29
commit bee6a40e9f
38 changed files with 762 additions and 177 deletions

View File

@ -1,4 +1,6 @@
import { navigate } from "gatsby";
import React, { useContext, useEffect, useState } from "react";
import { toast } from "react-toastify";
import Artboard from "../../components/builder/center/Artboard";
import LeftSidebar from "../../components/builder/left/LeftSidebar";
import RightSidebar from "../../components/builder/right/RightSidebar";
@ -6,7 +8,7 @@ import LoadingScreen from "../../components/router/LoadingScreen";
import DatabaseContext from "../../contexts/DatabaseContext";
import ResumeContext from "../../contexts/ResumeContext";
const Builder = ({ user, id }) => {
const Builder = ({ id }) => {
const [loading, setLoading] = useState(true);
const { getResume } = useContext(DatabaseContext);
const { dispatch } = useContext(ResumeContext);
@ -14,13 +16,23 @@ const Builder = ({ user, id }) => {
useEffect(() => {
(async () => {
const resume = await getResume(id);
if (!resume) {
navigate("/app/dashboard");
toast.error(
`The resume you were looking for does not exist anymore... or maybe it never did?`
);
return null;
}
dispatch({ type: "set_data", payload: resume });
setLoading(false);
})();
}, [id, getResume, dispatch]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);
if (loading) {
return <LoadingScreen message="Loading Resume..." />;
return <LoadingScreen />;
}
return (