diff --git a/src/app/dashboard/applications.error.tsx b/src/app/dashboard/applications.error.tsx new file mode 100644 index 0000000..866ae83 --- /dev/null +++ b/src/app/dashboard/applications.error.tsx @@ -0,0 +1,132 @@ +import { Answer, QuestionAnswer } from "../questions/interfaces"; +import { Application, BEState } from "../../utils/state"; +import { List, ListItem, Metric, Title } from "@tremor/react"; +import React, { useEffect, useLayoutEffect } from "react"; +import { RenderQuestion, UseQuestions, useQuestions } from "../questions/list"; + +import { isEmpty } from "lodash"; + +interface RenderEditQuestionProps extends UseQuestions { + question: QuestionAnswer; +} + +export const RenderEditQuestion = (props: RenderEditQuestionProps) => { + const { + questions: savedQuestions, + handleChangeAnswer, + handleSaveQuestion, + setSelectedQuestion, + selectedQuestion, + } = useQuestions(); + + const question = selectedQuestion; + + useEffect(() => { + console.log("savedQuestions.length", savedQuestions.length); + const selectedSavedQuestion = savedQuestions.find( + (q) => q?.question?.question === props?.question?.question?.question + ); + + if (!question && selectedSavedQuestion) { + console.log("selectedSavedQuestion", selectedSavedQuestion); + setSelectedQuestion(selectedSavedQuestion); + } + + }, [props?.question, savedQuestions]); + + if (!question || !question?.question) return null; + + return ( +
+
+ {question.question.question} +
+ + +
+ +
+
+ ); +}; + +interface ApplicationsErrorProps { + state: BEState; + useQuestions: UseQuestions; +} +export const ApplicationsError = (props: ApplicationsErrorProps) => { + const { state, useQuestions } = props; + const [selectedApp, setSelectedApp] = React.useState(null); + const { completedApps, skippedApps, apps } = state; + + return ( + <> + {skippedApps.length > 0 && ( +
+ {/* JOB */} + + {/* Questions */} + + {/* Apps */} +
+ + {skippedApps.map((item, index) => { + const isSelectedJob = selectedApp?.job?.id === item.job.id; + + return ( +
+ setSelectedApp(item)} + // key={item.question.inputId} + className={`${isSelectedJob? 'bg-gray-200': ''} hover:bg-gray-100 cursor-pointer px-2`} + > + + {index + 1} {item.job.title} - {item.job.company} ( + {item.questions.length}) + + +
+ )})} +
+
+ + {selectedApp && ( +
+
+ + {selectedApp.job.title} - {selectedApp.job.company} + +
+ + {selectedApp.questions.map((question, index) => ( + + ))} +
+ )} +
+ )} + + ); +}; + +export default ApplicationsError; diff --git a/src/app/dashboard/index.tsx b/src/app/dashboard/index.tsx index a62bea9..2df5c71 100644 --- a/src/app/dashboard/index.tsx +++ b/src/app/dashboard/index.tsx @@ -13,6 +13,7 @@ import { TabPanels, } from "@tremor/react"; +import ApplicationsError from "./applications.error"; import { LayoutPageProps } from "../layout"; import QuestionsError from "./questions.error"; import React from "react"; @@ -163,17 +164,12 @@ export const Dashboard = ({ state }: LayoutPageProps) => { -
- - Product Z - - $ 99,484 - 16% - - - -
+
+ {/* ApplicationsCompleted */}