Skip to content

Commit d85f938

Browse files
author
TI JONNY
committed
fix: create registration
1 parent b8a6caa commit d85f938

File tree

14 files changed

+59
-23
lines changed

14 files changed

+59
-23
lines changed

src/Context/Beneficiaries/BeneficiaresCreate/state.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const BeneficiariesCreateState = () => {
1212
const [classrooms, setClassrooms] = useState<any>();
1313
const props = ControllerPreRegistration()
1414

15+
1516

1617
useEffect(() => {
1718
if (classroomsFetch) {
@@ -29,7 +30,7 @@ export const BeneficiariesCreateState = () => {
2930
const CreateRegister = (values: any) => {
3031
const data = new Date(values?.birthday);
3132
const dataFormatada = data?.toISOString()?.split('T')[0];
32-
props.requestRegistrationMutation.mutate({ ...values, cpf: values.cpf.replace(/[^a-zA-Z0-9]/g, ''), responsable_telephone: values.responsable_telephone.replace(/[^a-zA-Z0-9]/g, ''), birthday: dataFormatada, responsable_cpf: values?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, '') })
33+
props.requestRegistrationMutation.mutate({ ...values, cpf: values.cpf.replace(/[^a-zA-Z0-9]/g, ''),kinship: values.kinship === "" ? "NAO_DEFINIDO" : values.kinship, responsable_telephone: values.responsable_telephone.replace(/[^a-zA-Z0-9]/g, ''), birthday: dataFormatada, responsable_cpf: values?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, '') })
3334
}
3435

3536

src/Context/Beneficiaries/BeneficiaresEdit/state.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const BeneficiariesEditState = () => {
8686
/[^a-zA-Z0-9]/g,
8787
""
8888
),
89+
kinship: data.kinship === "" ? "NAO_DEFINIDO" : data.kinship,
8990
responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, ""),
9091
},
9192
id: id,

src/Context/Beneficiaries/BeneficiariesList/context.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const BeneficiariesListProvider = ({
2323
cpfFilter,
2424
nameFilter,
2525
allFilter,
26-
setallFilter
26+
setallFilter,
27+
setTsId,
28+
tsId
2729
} = BeneficiariesListState();
2830

2931
return (
@@ -41,7 +43,9 @@ const BeneficiariesListProvider = ({
4143
cpfFilter,
4244
nameFilter,
4345
allFilter,
44-
setallFilter
46+
setallFilter,
47+
setTsId,
48+
tsId
4549
}}
4650
>
4751
{children}

src/Context/Beneficiaries/BeneficiariesList/state.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const BeneficiariesListState = () => {
77
const [page, setPage] = useState(0);
88
const [limite, setLimite] = useState(10);
99
const [nameFilter, setnameFilter] = useState<string | undefined>();
10+
const [tsId, setTsId] = useState<number | undefined>()
1011

1112
const [cpfFilter, setcpfFilter] = useState<string | undefined>();
1213
const [allFilter, setallFilter] = useState<string | undefined>("");
@@ -18,7 +19,8 @@ export const BeneficiariesListState = () => {
1819
page: Math.floor(page / 10 + 1),
1920
name: nameFilter !== "" ? nameFilter : undefined,
2021
cpf: cpfFilter !== "" ? cpfFilter?.replace(/[^a-zA-Z0-9]/g, '') : undefined,
21-
allFilter: allFilter !== "" ? allFilter : undefined
22+
allFilter: allFilter !== "" ? allFilter : undefined,
23+
idTs: tsId?.toString(),
2224
});
2325

2426
const handleFilter = (values: { name: string; cpf: string }) => {
@@ -50,6 +52,7 @@ export const BeneficiariesListState = () => {
5052
nameFilter,
5153
cpfFilter,
5254
allFilter,
53-
setallFilter
55+
setallFilter,
56+
tsId, setTsId
5457
};
5558
};

src/Context/Beneficiaries/BeneficiariesList/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface BeneficiariesListType {
1010
nameFilter: string | undefined
1111
cpfFilter: string | undefined
1212
allFilter: string | undefined
13+
tsId: number | undefined
14+
setTsId: Dispatch<SetStateAction<number | undefined>>
1315
setallFilter: Dispatch<SetStateAction<string | undefined>>
1416
handleFilter: (values: {
1517
name: string;

src/Context/Classroom/Registration/state.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const RegistrationClassroomState = () => {
5151
/[^a-zA-Z0-9]/g,
5252
""
5353
),
54+
kinship: data.kinship === "" ? "NAO_DEFINIDO" : data.kinship,
5455
responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, ""),
5556
},
5657
id: id,

src/Context/Classroom/Registration/type.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface UpdateRegister
2929
status: {id: string, name: string} | undefined;
3030
registration_classroom_id?: number
3131
deficiency_description: any
32-
kinship: string | undefined
32+
kinship: string | undefined | null
3333
}
3434
export interface RegistrationType {
3535
id: number

src/Context/Register/state.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const RegisterState = () => {
5858
const data = new Date(dataValues?.birthday);
5959
const dataFormatada = data?.toISOString()?.split('T')[0];
6060

61-
props.requestPreRegistrationMutation.mutate({ ...dataValues, cpf: dataValues.cpf.replace(/[^a-zA-Z0-9]/g, ''), responsable_telephone: dataValues.responsable_telephone.replace(/[^a-zA-Z0-9]/g, ''), birthday: dataFormatada, responsable_cpf: dataValues?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, '') })
61+
props.requestPreRegistrationMutation.mutate({ ...dataValues, cpf: dataValues.cpf.replace(/[^a-zA-Z0-9]/g, ''),kinship: dataValues.kinship === "" ? "NAO_DEFINIDO" : dataValues.kinship, responsable_telephone: dataValues.responsable_telephone.replace(/[^a-zA-Z0-9]/g, ''), birthday: dataFormatada, responsable_cpf: dataValues?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, '') })
6262
}
6363

6464
const initialState: Registration = {

src/Context/Register/type.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface Registration {
3535
responsable_name?: string;
3636
responsable_cpf?: string;
3737
responsable_telephone?: string;
38-
kinship?: string;
38+
kinship?: string | null;
3939
zone: number | null;
4040
}
4141

src/Controller/controllerGlobal.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ export const ROLE = {
9090
export const kinship = [
9191
{ id: "PAI", name: 'Pai' },
9292
{ id: "MAE", name: 'Mãe' },
93-
{ id: "CONJUGE", name: 'Cônjuge' },
93+
{ id: "PRIMO_A", name: 'Primo(a)' },
94+
{ id: "TIO_A", name: 'Tio(a)' },
9495
{ id: "FILHO_A", name: 'Filho(a)' },
95-
{ id: "ENTEADO_A", name: 'Enteado(a)' },
96-
{ id: "NETO_A", name: 'Neto(a)' },
97-
{ id: "SOGRO_A", name: 'Sogro(a)' },
9896
{ id: "IRMAO_A", name: 'Irmão(a)' },
99-
{ id: "GENRO", name: 'Genro' },
100-
{ id: "NORA", name: 'Nora' },
10197
{ id: "OUTRO", name: 'Outro' },
102-
{ id: "NAO_PARENTE", name: 'Não Parente' }
98+
{ id: "NAO_PARENTE", name: 'Não Parente' },
99+
{ id: "NAO_DEFINIDO", name: 'Não Definido' }
100+
103101
]
104102

105103
export const loadImageFileAsBase64 = (imagePath: string): Promise<string> => {

src/Pages/Beneficiaries/BeneficiariesList/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import {
1919
import color from "../../../Styles/colors";
2020
import { Padding, Row } from "../../../Styles/styles";
2121
import ModalFilter from "./ModalFilter";
22+
import DropdownComponent from "../../../Components/Dropdown";
23+
import { PropsAplicationContext } from "../../../Types/types";
24+
import { AplicationContext } from "../../../Context/Aplication/context";
2225

2326
const BeneficiariesList = () => {
2427
return (
@@ -30,6 +33,7 @@ const BeneficiariesList = () => {
3033

3134
const BeneficiariesListPage = () => {
3235
const props = useContext(BeneficiariesListContext) as BeneficiariesListType;
36+
const propsAplication = useContext(AplicationContext) as PropsAplicationContext;
3337
const history = useNavigate();
3438

3539
const [visible, setVisible] = useState<any>();
@@ -91,6 +95,22 @@ const BeneficiariesListPage = () => {
9195
return (
9296
<>
9397
<ContentPage title="Beneficiários" description="Visualização dos beneficiários da tecnologia.">
98+
<Row id="end">
99+
100+
{propsAplication.project
101+
? (
102+
<DropdownComponent
103+
placerholder="Escolha uma tecnologia"
104+
options={[{ name: "Todos", id: undefined }, ...propsAplication.project]}
105+
value={props.tsId}
106+
optionsValue="id"
107+
108+
onChange={(e) => {
109+
props.setTsId(e.target.value);
110+
}}
111+
/>
112+
) : null}{" "}
113+
</Row>
94114
<Padding padding="16px" />
95115
<Row style={{ gap: 8 }}>
96116
{props.nameFilter?.length! > 0 && (

src/Services/Beneficiaries/query.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ export const useFetchRequestAllRegistration = ({
66
limite,
77
cpf,
88
name,
9-
allFilter
9+
allFilter,
10+
idTs
1011
}: {
1112
page: number;
1213
limite: number;
1314
name?: string;
1415
cpf?: string;
15-
allFilter?: string
16+
allFilter?: string,
17+
idTs?: string,
1618
}) => {
17-
return useQuery(["useRequestAllRegistration", page, limite, cpf, name, allFilter], () =>
18-
requestAllRegistration({ limite: limite, page: page, cpf: cpf, name: name, allFilter: allFilter })
19+
return useQuery(["useRequestAllRegistration", page, limite, cpf, name, allFilter, idTs], () =>
20+
requestAllRegistration({ limite: limite, page: page, cpf: cpf, name: name, allFilter: allFilter, idTs: idTs })
1921
);
2022
};

src/Services/Beneficiaries/request.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import http from "../axios";
2-
import { GetIdTs, logout } from "../localstorage";
2+
import { logout } from "../localstorage";
33

44
export const requestAllRegistration = ({
55
page,
66
limite,
77
cpf,
88
name,
9-
allFilter
9+
allFilter,
10+
idTs,
1011
}: {
1112
page: number;
1213
limite: number;
1314
name?: string,
15+
idTs?: string,
1416
cpf?: string,
1517
allFilter?: string
1618
}) => {
1719
const nameFilter = name ? "&nameFilter=" + name : ""
1820
const cpfFilter = cpf ? "&cpfFilter=" + cpf : ""
19-
const allFilterRequest = allFilter ? "&allFilter=" + allFilter : ""
21+
const idTsFilter = idTs ? "&idTs=" + idTs : ""
22+
const allFilterRequest = allFilter ? "&allFilter=" + allFilter.replace(/[^a-zA-Z0-9 ]/g, '') : ""
2023

2124
let path =
2225
"/registration-token-bff/registration-all?page=" +
2326
page +
2427
"&limit=" +
25-
limite + "&idTs="+ GetIdTs() + nameFilter + cpfFilter + allFilterRequest;
28+
limite + idTsFilter + nameFilter + cpfFilter + allFilterRequest;
2629
return http
2730
.get(path)
2831
.then((response) => response.data)

src/Services/PreRegistration/types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface CreatePreRegistration {
1313
responsable_telephone?: string | null;
1414
zone: number;
1515
classroom: number;
16+
kinship: string | undefined | null
1617
}
1718

1819
export interface CreateRegistrationClassroomType {

0 commit comments

Comments
 (0)