From d5969375989ee19e9205789bc7df469f9fc16c41 Mon Sep 17 00:00:00 2001 From: WindowsCrashed Date: Fri, 4 Aug 2023 23:43:50 -0300 Subject: [PATCH] add new assessment manual page --- .../pages/assessment/NewAssessmentManual.tsx | 188 ++++++++++++++++++ app/javascript/routes/paths.ts | 1 + app/javascript/routes/routes.tsx | 2 + 3 files changed, 191 insertions(+) create mode 100644 app/javascript/pages/assessment/NewAssessmentManual.tsx diff --git a/app/javascript/pages/assessment/NewAssessmentManual.tsx b/app/javascript/pages/assessment/NewAssessmentManual.tsx new file mode 100644 index 0000000..59d23a2 --- /dev/null +++ b/app/javascript/pages/assessment/NewAssessmentManual.tsx @@ -0,0 +1,188 @@ +import { gql, useQuery } from "@apollo/client"; +import React, { useState } from "react"; +import { FaTrash } from "react-icons/fa"; +import { Controller, useForm } from "react-hook-form"; + +import { Axis, Query } from "../../__generated__/graphql-schema"; +import { Button, Card, Input, Navigator } from '../../components'; + +type NewAssessementManualForm = { + axisWeights: Record +} + +const NEW_ASSESSEMENT_DATA_QUERY = gql` + query NewAssessementDataQuery { + axes { + nodes { + id + name + } + } + } +` + +export const NewAssessementManual = () => { + const { data } = useQuery(NEW_ASSESSEMENT_DATA_QUERY) + const axes = data?.axes.nodes + + const [subjectsIds, setSubjectsIds] = useState([]) + const { register, control, watch } = useForm({ + mode: 'onBlur' + }) + + + const addAxisForm = useForm<{ axisId: string }>() + + const handleAddAxis = (formData: { axisId: string }) => { + setSubjectsIds(prev => [...prev, formData.axisId]) + addAxisForm.reset(); + } + + const handleRemoveAxis = (axisId: string) => { + setSubjectsIds(prev => prev.filter((axis => axis !== axisId))) + } + + if (!axes?.length) return null + + const notSelectedAxis: Axis[] = axes.filter((axis) => !subjectsIds.includes(axis.id)) + const selectedAxis: Axis[] = axes.filter((axis) => subjectsIds.includes(axis.id)) + + return ( +
+ // <> + // + //
+ // + //
+ //

Titulo:

+ //
+ // + //
+ //
+ //
+ //

Observações:

+ //
+ // + //
+ //
+ //
+ // + //
+ //
+ // + // + //
+ //
+ + //
+ // {selectedAxis.map(axis => ( + //
+ //
+ //
+ //
{axis.name}
+ //
handleRemoveAxis(axis.id)}>
+ //
+ //
+ // Fácil + // + // {watch(`axisWeights.easy.${axis.id}`) ?? 5} + // + //
+ // ( + // + // )} + // /> + + //
+ + //
+ //
+ // Médio + // + // {watch(`axisWeights.medium.${axis.id}`) ?? 5} + // + //
+ // ( + // + // )} + // /> + + //
+ + //
+ //
+ // Difícil + // + // {watch(`axisWeights.hard.${axis.id}`) ?? 5} + // + //
+ // ( + // + // )} + // /> + + //
+ + //
+ //
+ //
+ // ))} + //
+ //
+ //
+ // + // + ) +} \ No newline at end of file diff --git a/app/javascript/routes/paths.ts b/app/javascript/routes/paths.ts index 376de37..1318bd0 100644 --- a/app/javascript/routes/paths.ts +++ b/app/javascript/routes/paths.ts @@ -21,4 +21,5 @@ export const DashboardRoutePaths = { export const AssessmentRoutePaths = { index: "/assessments", new: "/assessments/new", + newManual: "/assessments/new-manual" } \ No newline at end of file diff --git a/app/javascript/routes/routes.tsx b/app/javascript/routes/routes.tsx index dadbf56..55ce9c5 100644 --- a/app/javascript/routes/routes.tsx +++ b/app/javascript/routes/routes.tsx @@ -3,6 +3,7 @@ import { Redirect, Route, Switch } from "react-router-dom"; import { AssessmentList } from "../pages/assessment"; import { NewAssessement } from "../pages/assessment/NewAssessement"; +import { NewAssessementManual } from "../pages/assessment/NewAssessmentManual"; import { Dashboard } from '../pages/dashboard'; import { Edit, List, New, Review, Show } from "../pages/question"; import { Profile } from "../pages/session"; @@ -22,5 +23,6 @@ export const PrivateRoutes = () => ( + );