Skip to content

Commit e705b96

Browse files
committed
troca na rota de registration
1 parent 226855d commit e705b96

File tree

7 files changed

+83
-52
lines changed

7 files changed

+83
-52
lines changed

src/Components/Layout/layout.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
import React, { useState } from "react";
1+
import React, { useEffect, useState } from "react";
22
import { Column, Row } from "../../Styles/styles";
33
import Menu from "../Menu";
44
import TopBar from "./TopBar";
55

66
const Layout = ({ children }: { children: React.ReactNode }) => {
7-
const [viewdMenu, setViewdMenu] = useState(true)
7+
const [viewdMenu, setViewdMenu] = useState(true);
88

9-
return (
10-
<Column style={{ height: "100%" }}>
11-
<Row style={{ height: "100%" }}>
12-
<Menu viewdMenu={viewdMenu} />
13-
<Column style={{ width: "100%" }}>
14-
<TopBar setViewdMenu={setViewdMenu} viewdMenu={viewdMenu} />
15-
<div style={{ overflowY: "auto", height: "100%" }}>{children}</div>
16-
</Column>
17-
</Row>
9+
useEffect(() => {
10+
if (window.innerWidth < 1020) {
11+
setViewdMenu(false);
12+
}
13+
}, []);
14+
15+
return (
16+
<Column style={{ height: "100%" }}>
17+
<Row style={{ height: "100%" }}>
18+
<Menu viewdMenu={viewdMenu} />
19+
<Column style={{ width: "100%" }}>
20+
<TopBar setViewdMenu={setViewdMenu} viewdMenu={viewdMenu} />
21+
<div style={{ overflowY: "auto", height: "100%" }}>{children}</div>
1822
</Column>
19-
)
20-
}
23+
</Row>
24+
</Column>
25+
);
26+
};
2127

22-
export default Layout;
28+
export default Layout;

src/Context/Classroom/Registration/state.tsx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import { useFetchRequestClassroomRegistrationOne } from "../../../Services/PreRe
66
import { formatarData, Status } from "../../../Controller/controllerGlobal";
77
export const RegistrationClassroomState = () => {
88
const { idRegistration } = useParams();
9-
const { data: registrationRequest, isLoading } = useFetchRequestClassroomRegistrationOne(
10-
parseInt(idRegistration!)
11-
);
9+
const { data: registrationRequest, isLoading } =
10+
useFetchRequestClassroomRegistrationOne(parseInt(idRegistration!));
1211

1312
const { requestPreRegistrationMutation } = ControllerUpdateRegistration();
1413

@@ -44,34 +43,48 @@ export const RegistrationClassroomState = () => {
4443
return color.find((props) => props.id === color_race);
4544
};
4645

47-
const date = new Date(registration?.birthday!);
46+
const date = new Date(registration?.registration.birthday!);
4847

4948
const status = [
5049
{ id: Status.APPROVED, name: "Aprovado" },
5150
{ id: Status.REPROVED, name: "Reprovado" },
5251
{ id: Status.PENDING, name: "Pedente" },
53-
]
52+
];
5453

5554
const getStatus = (id: string) => {
56-
return status.find(props => props.id === id)
57-
}
55+
return status.find((props) => props.id === id);
56+
};
5857
const initialValue = {
59-
name: registration?.name,
60-
sex: VerifySex(registration?.sex!),
61-
cpf: registration?.cpf,
62-
color_race: VerifyColor(registration?.color_race!),
63-
birthday: !isNaN(date.getTime()) ? formatarData(registration?.birthday!) : registration?.birthday,
64-
deficiency: registration?.deficiency
58+
name: registration?.registration.name,
59+
sex: VerifySex(registration?.registration.sex!),
60+
cpf: registration?.registration.cpf,
61+
color_race: VerifyColor(registration?.registration.color_race!),
62+
birthday: !isNaN(date.getTime())
63+
? formatarData(registration?.registration.birthday!)
64+
: registration?.registration.birthday,
65+
deficiency: registration?.registration.deficiency
6566
? { name: "Sim", id: true }
6667
: { name: "Não", id: false },
67-
responsable_name: registration?.responsable_name,
68-
responsable_cpf: registration?.responsable_cpf,
69-
responsable_telephone: registration?.responsable_telephone,
68+
responsable_name: registration?.registration.responsable_name,
69+
responsable_cpf: registration?.registration.responsable_cpf,
70+
responsable_telephone: registration?.registration.responsable_telephone,
7071
status: getStatus(registration?.status!),
7172
};
7273

7374
const handleUpdateRegistration = (data: UpdateRegister, id: number) => {
74-
requestPreRegistrationMutation.mutate({ data: { ...data, birthday: registration?.birthday, responsable_telephone: data?.responsable_telephone?.replace(/[^a-zA-Z0-9]/g, ''), responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, '') }, id: id });
75+
requestPreRegistrationMutation.mutate({
76+
data: {
77+
...data,
78+
registration_classroom_id: registration?.id,
79+
birthday: registration?.registration.birthday,
80+
responsable_telephone: data?.responsable_telephone?.replace(
81+
/[^a-zA-Z0-9]/g,
82+
""
83+
),
84+
responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, ""),
85+
},
86+
id: id,
87+
});
7588
};
7689

7790
return {
@@ -80,6 +93,6 @@ export const RegistrationClassroomState = () => {
8093
typesex,
8194
color,
8295
handleUpdateRegistration,
83-
isLoading
96+
isLoading,
8497
};
8598
};

src/Context/Classroom/Registration/type.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,32 @@ export interface UpdateRegister
3535
responsable_cpf: string | undefined;
3636
responsable_telephone: string | undefined;
3737
status: {id: string, name: string} | undefined;
38+
registration_classroom_id?: number
3839
}
39-
4040
export interface RegistrationType {
41-
id: number;
42-
classroom_fk?: number;
43-
name?: string;
44-
birthday?: string;
45-
cpf?: string;
46-
sex?: number;
47-
color_race?: number;
48-
deficiency?: boolean;
49-
deficiency_description?: string | null;
50-
responsable_name?: string;
51-
responsable_cpf?: string;
52-
responsable_telephone?: string;
53-
zone?: number;
54-
status?: string;
41+
id: number
42+
registration_fk: number
43+
classroom_fk: number
44+
status: string
45+
createdAt: string
46+
updatedAt: string
47+
registration: Registration
48+
}
49+
50+
export interface Registration {
51+
id: number
52+
name: string
53+
birthday: string
54+
cpf: string
55+
sex: number
56+
color_race: number
57+
deficiency: boolean
58+
deficiency_description: any
59+
responsable_name: string
60+
responsable_cpf: string
61+
responsable_telephone: string
62+
zone: number
63+
status: string
64+
createdAt: string
65+
updatedAt: string
5566
}

src/Context/Classroom/RegistrationsList/type.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export interface RegistrationType {
1616
classroom_fk: number
1717
createdAt: string
1818
updatedAt: string
19-
registration: Registration
19+
registration: Registration,
20+
status: string
2021
}
2122

2223
export interface Registration {

src/Pages/Classroom/ClassroomOne/RegistrationList/Registration/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const RegistrationPage = () => {
2727
RegistrationDetailsContext
2828
) as RegistrationDetailsTypes;
2929

30-
const { idRegistration, id } = useParams();
30+
const { id } = useParams();
3131
const { data: classroom } = useFetchRequestClassroomOne(parseInt(id!));
3232

3333
if (props.isLoading) return <Loading />;
@@ -42,7 +42,7 @@ const RegistrationPage = () => {
4242
onSubmit={(values) => {
4343
props.handleUpdateRegistration(
4444
{ ...values },
45-
parseInt(idRegistration!)
45+
props.registration?.registration_fk!
4646
);
4747
}}
4848
>

src/Pages/Classroom/ClassroomOne/RegistrationList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const RegistrationListPage = () => {
3737
{props.registrations?.map((item, index) => {
3838
return (
3939
<div className="col-12 md:col-6 lg:col-4" key={index}>
40-
<CardRegistration title={item.registration.id.toString()} subtitle={item.registration.name} idRegistration={item.registration.id} status={item.registration.status} />
40+
<CardRegistration title={item.registration.id.toString()} subtitle={item.registration.name} idRegistration={item.id} status={item.status} />
4141
</div>
4242
);
4343
})}

src/Services/PreRegistration/request.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const requestClassroomRegistration = (id: number) => {
6969
};
7070

7171
export const requestClassroomRegistrationOne = (id: number) => {
72-
let path = "/registration/" + id;
72+
let path = "/registration-token-bff/one?idRegistrationClassroom=" + id;
7373
return http
7474
.get(path)
7575
.then(response => response.data)

0 commit comments

Comments
 (0)