Skip to content

Commit

Permalink
Merge pull request #31 from ipti/new/registration
Browse files Browse the repository at this point in the history
New/registration
  • Loading branch information
jonnypaulino authored Jul 2, 2024
2 parents d0b58fa + 63ce222 commit 524fe2a
Show file tree
Hide file tree
Showing 41 changed files with 528 additions and 229 deletions.
16 changes: 16 additions & 0 deletions src/Components/ContentPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ReactNode } from "react";
import { Container, Padding } from "../../Styles/styles"

const ContentPage = ({ description, title, children }: { title: string, description: string, children: ReactNode }) => {
return (
<Container>
<h1>{title}</h1>
<Padding padding="8px" />
<p>{description}</p>
<Padding padding="8px" />
{children}
</Container>
)
}

export default ContentPage;
13 changes: 12 additions & 1 deletion src/Components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,20 @@ const Menu = ({ viewdMenu }: { viewdMenu: boolean }) => {
active={active === 5 ? true : false}
path={"/beneficiarios"}
icon={active === 5 ? beneficiaries_hover : beneficiaries}
/><Padding />
<Item
text={"Reaplicadores"}
funcActiv={() => {
setActive(8);
menuItem("8");
}}
active={active === 8 ? true : false}
path={"/reaplicadores"}
icon={active === 8 ? turmasHover : turmas}
/>
<Padding />
{props.user?.role === ROLE.ADMIN ||
props.user?.role === ROLE.COORDINATORS ? (
props.user?.role === ROLE.COORDINATORS ? (
<Item
text={"Usuarios"}
funcActiv={() => {
Expand All @@ -150,6 +160,7 @@ const Menu = ({ viewdMenu }: { viewdMenu: boolean }) => {
icon={active === 6 ? user_hover : user}
/>
) : null}

<Padding />

<Item
Expand Down
5 changes: 4 additions & 1 deletion src/Context/Beneficiaries/BeneficiaresCreate/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ export const BeneficiariesCreateState = () => {
project: undefined,
status: "",
classroom: 0,
deficiency_description: ""
deficiency_description: "",
kinship: ""
};


return {
initialValue,
tsOne,
Expand Down
1 change: 1 addition & 0 deletions src/Context/Beneficiaries/BeneficiaresCreate/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface BeneficiariesCreateType {
zone: number | undefined,
project: number | undefined,
deficiency_description: string | undefined
kinship: string
};
tsOne: Tsone | undefined;
project: any | undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/Context/Beneficiaries/BeneficiaresEdit/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export const BeneficiariesEditState = () => {
responsable_cpf: registrations?.responsable_cpf,
responsable_telephone: registrations?.responsable_telephone,
status: getStatus(registrations?.status!),
deficiency_description: registrations?.deficiency_description
deficiency_description: registrations?.deficiency_description,
kinship: registrations?.kinship

};

Expand Down
1 change: 1 addition & 0 deletions src/Context/Beneficiaries/BeneficiaresEdit/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Registration {
createdAt: string;
updatedAt: string;
register_classroom: RegisterClassroom[];
kinship: string
}

export interface RegisterClassroom {
Expand Down
3 changes: 2 additions & 1 deletion src/Context/Classroom/Registration/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const RegistrationClassroomState = () => {
responsable_cpf: registration?.registration.responsable_cpf,
responsable_telephone: registration?.registration.responsable_telephone,
status: getStatus(registration?.status!),
deficiency_description: registration?.registration.deficiency_description
deficiency_description: registration?.registration.deficiency_description,
kinship: registration?.registration.kinship

};

Expand Down
2 changes: 2 additions & 0 deletions src/Context/Classroom/Registration/type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface UpdateRegister
status: {id: string, name: string} | undefined;
registration_classroom_id?: number
deficiency_description: any
kinship: string | undefined
}
export interface RegistrationType {
id: number
Expand Down Expand Up @@ -56,4 +57,5 @@ export interface Registration {
status: string
createdAt: string
updatedAt: string
kinship: string
}
1 change: 1 addition & 0 deletions src/Context/Register/type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface Registration {
responsable_name?: string;
responsable_cpf?: string;
responsable_telephone?: string;
kinship?: string;
zone: number | null;
}

Expand Down
16 changes: 14 additions & 2 deletions src/Context/Users/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export const UsersState = () => {
username: data.username,
password: data.password,
role: data.role,
project: GetId(data.project)
project: GetId(data.project),
sex: data.sex,
color_race: data.color_race,
birthday:data.birthday,
email: data.email,
initial_date: data.initial_date,
phone: data.phone
}
props.requestUserMutation.mutate(body);
};
Expand All @@ -35,7 +41,13 @@ export const UsersState = () => {
name: data.name,
username: data.username,
role: data.role,
project: GetId(data.project)
project: GetId(data.project),
sex: data.sex,
color_race: data.color_race,
birthday:data.birthday,
email: data.email,
initial_date: data.initial_date,
phone: data.phone
}
props.requestUpdateUserMutation.mutate({data: body, id: id});
};
Expand Down
6 changes: 6 additions & 0 deletions src/Context/Users/type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export interface CreateUser {
password?: string;
project: number[];
role?: {name: string, id: string}
email?: string,
phone?: string,
sex: number,
color_race: number,
initial_date: string,
birthday: string
}

export interface User {
Expand Down
15 changes: 15 additions & 0 deletions src/Controller/controllerGlobal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ export const ROLE = {
COORDINATORS: "COORDINATORS",
};

export const kinship = [
{ id: "PAI", name: 'Pai' },
{ id: "MAE", name: 'Mãe' },
{ id: "CONJUGE", name: 'Cônjuge' },
{ id: "FILHO_A", name: 'Filho(a)' },
{ id: "ENTEADO_A", name: 'Enteado(a)' },
{ id: "NETO_A", name: 'Neto(a)' },
{ id: "SOGRO_A", name: 'Sogro(a)' },
{ id: "IRMAO_A", name: 'Irmão(a)' },
{ id: "GENRO", name: 'Genro' },
{ id: "NORA", name: 'Nora' },
{ id: "OUTRO", name: 'Outro' },
{ id: "NAO_PARENTE", name: 'Não Parente' }
]

export const loadImageFileAsBase64 = (imagePath: string): Promise<string> => {
return new Promise((resolve, reject) => {
fetch(imagePath)
Expand Down
42 changes: 34 additions & 8 deletions src/Pages/Beneficiaries/BeneficiariesCreate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { Form, Formik } from "formik";
import { Button } from "primereact/button";
import { useContext } from "react";
import * as Yup from "yup";
import CalendarComponent from "../../../Components/Calendar";
import ContentPage from "../../../Components/ContentPage";
import DropdownComponent from "../../../Components/Dropdown";
import MaskInput from "../../../Components/InputMask";
import Loading from "../../../Components/Loading";
import RadioButtonComponent from "../../../Components/RadioButton";
import TextInput from "../../../Components/TextInput";
import BeneficiariesCreateProvider, {
BeneficiariesCreateContext,
} from "../../../Context/Beneficiaries/BeneficiaresCreate/context";
import { BeneficiariesCreateType } from "../../../Context/Beneficiaries/BeneficiaresCreate/type";
import { color_race, typesex } from "../../../Controller/controllerGlobal";
import { Column, Container, Padding, Row } from "../../../Styles/styles";
import CalendarComponent from "../../../Components/Calendar";
import * as Yup from "yup";
import {
color_race,
kinship,
typesex,
} from "../../../Controller/controllerGlobal";
import { validaCPF } from "../../../Controller/controllerValidCPF";
import RadioButtonComponent from "../../../Components/RadioButton";
import { Column, Padding, Row } from "../../../Styles/styles";

const BeneficiariesCreate = () => {
return (
Expand Down Expand Up @@ -59,8 +64,10 @@ const RegistrationPage = () => {
if (false) return <Loading />;

return (
<Container>
<h1>Criar Beneficiario</h1>
<ContentPage
title="Criar Beneficiario"
description="Criar novo beneficiário."
>
<Padding padding="16px" />
{true ? (
<Formik
Expand Down Expand Up @@ -288,6 +295,25 @@ const RegistrationPage = () => {
</div>
) : null}
</div>
<div className="col-12 md:col-6">
<label>Parentesco</label>
<Padding />
<DropdownComponent
placerholder="Parantesco"
onChange={handleChange}
options={kinship}
name="kinship"
optionsValue="id"
optionsLabel="name"
value={values.kinship}
/>

{errors.kinship && touched.kinship ? (
<div style={{ color: "red", marginTop: "8px" }}>
{errors.kinship}
</div>
) : null}
</div>
</div>{" "}
<Padding padding="8px" />
<h3>Matricula *</h3>
Expand Down Expand Up @@ -381,7 +407,7 @@ const RegistrationPage = () => {
}}
</Formik>
) : null}
</Container>
</ContentPage>
);
};
export default BeneficiariesCreate;
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const ModalCreateRegisterClassroom = ({
<Form>
<div className="grid">
<div className="col-12">
<label>Matricula</label>
<label>Projeto</label>
<Padding />
<DropdownComponent
value={props.project}
Expand Down
15 changes: 15 additions & 0 deletions src/Pages/Beneficiaries/BeneficiariesEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { BeneficiariesEditType } from "../../../Context/Beneficiaries/Beneficiar
import {
color_race,
getStatus,
kinship,
typesex,
} from "../../../Controller/controllerGlobal";
import color from "../../../Styles/colors";
Expand Down Expand Up @@ -220,6 +221,20 @@ const BeneficiariesEditPage = () => {
onChange={handleChange}
/>
</div>
<div className="col-12 md:col-6">
<label>Parentesco</label>
<Padding />
<DropdownComponent
placerholder="Parantesco"
onChange={handleChange}
options={kinship}
name="kinship"
optionsValue="id"
optionsLabel="name"
value={values.kinship}
/>
</div>

</div>{" "}
<Padding padding="8px" />
<h3>Matriculas</h3>
Expand Down
8 changes: 4 additions & 4 deletions src/Pages/Beneficiaries/BeneficiariesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { InputText } from "primereact/inputtext";
import { Paginator } from "primereact/paginator";
import { useContext, useState } from "react";
import { useNavigate } from "react-router-dom";
import ContentPage from "../../../Components/ContentPage";
import BeneficiariesListProvider, {
BeneficiariesListContext,
} from "../../../Context/Beneficiaries/BeneficiariesList/context";
Expand All @@ -16,7 +17,7 @@ import {
somarNumeros,
} from "../../../Controller/controllerGlobal";
import color from "../../../Styles/colors";
import { Container, Padding, Row } from "../../../Styles/styles";
import { Padding, Row } from "../../../Styles/styles";
import ModalFilter from "./ModalFilter";

const BeneficiariesList = () => {
Expand Down Expand Up @@ -89,8 +90,7 @@ const BeneficiariesListPage = () => {

return (
<>
<Container>
<h1>Beneficiários</h1>
<ContentPage title="Beneficiários" description="Visualização dos beneficiários da tecnologia.">
<Padding padding="16px" />
<Row style={{ gap: 8 }}>
{props.nameFilter?.length! > 0 && (
Expand Down Expand Up @@ -139,7 +139,7 @@ const BeneficiariesListPage = () => {
}}
rows={props.limite}
/>
</Container>
</ContentPage>
<ConfirmDialog
visible={visible}
onHide={() => setVisible(false)}
Expand Down
61 changes: 61 additions & 0 deletions src/Pages/Classroom/ClassroomCriar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Form, Formik } from "formik";
import { Button } from "primereact/button";
import { useContext } from "react";
import { useParams } from "react-router-dom";
import ContentPage from "../../../Components/ContentPage";
import Loading from "../../../Components/Loading";
import TextInput from "../../../Components/TextInput";
import ClassroomProvider, { ClassroomContext } from "../../../Context/Classroom/context";
import { ClassroomTypes } from "../../../Context/Classroom/type";
import { getYear } from "../../../Services/localstorage";
import { Padding, Row } from "../../../Styles/styles";

const FormClassroom = () => {
return (
<ClassroomProvider>
<FormClassroomPage />
</ClassroomProvider>
)
}

const FormClassroomPage = () => {

const { id } = useParams()

const initialValues = {
name: ""
}

const props = useContext(ClassroomContext) as ClassroomTypes

if (props.isLoading) return <Loading />;


return (
<ContentPage title="Criar turma" description="Crie uma nova turma.">
<Padding padding="16px" />
<Formik initialValues={initialValues} onSubmit={(values) => { props.CreateClassroom({ ...values, project: parseInt(id!), year: parseInt(getYear()!) }) }}>
{({ values, errors, handleChange, touched }) => {
return (
<Form>
<label>Nome *</label>
<Padding />
<TextInput name="name" onChange={handleChange} placeholder="Nome *" value={values.name} />
<Padding />
{errors.name && touched.name ? (
<div style={{ color: "red", marginTop: "8px" }}>{errors.name}</div>
) : null}
<Padding padding="16px" />
<Row id="end">
<Button label="Criar" />
</Row>
</Form>
)
}}
</Formik>

</ContentPage>
)
}

export default FormClassroom;
Loading

0 comments on commit 524fe2a

Please sign in to comment.