diff --git a/src/Context/Beneficiaries/BeneficiaresCreate/state.tsx b/src/Context/Beneficiaries/BeneficiaresCreate/state.tsx index 86e4501..818f735 100644 --- a/src/Context/Beneficiaries/BeneficiaresCreate/state.tsx +++ b/src/Context/Beneficiaries/BeneficiaresCreate/state.tsx @@ -12,6 +12,7 @@ export const BeneficiariesCreateState = () => { const [classrooms, setClassrooms] = useState(); const props = ControllerPreRegistration() + useEffect(() => { if (classroomsFetch) { @@ -29,7 +30,7 @@ export const BeneficiariesCreateState = () => { const CreateRegister = (values: any) => { const data = new Date(values?.birthday); const dataFormatada = data?.toISOString()?.split('T')[0]; - 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, '') }) + 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, '') }) } diff --git a/src/Context/Beneficiaries/BeneficiaresEdit/state.tsx b/src/Context/Beneficiaries/BeneficiaresEdit/state.tsx index fd0a8b4..ba7fa3b 100644 --- a/src/Context/Beneficiaries/BeneficiaresEdit/state.tsx +++ b/src/Context/Beneficiaries/BeneficiaresEdit/state.tsx @@ -86,6 +86,7 @@ export const BeneficiariesEditState = () => { /[^a-zA-Z0-9]/g, "" ), + kinship: data.kinship === "" ? "NAO_DEFINIDO" : data.kinship, responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, ""), }, id: id, diff --git a/src/Context/Beneficiaries/BeneficiariesList/context.tsx b/src/Context/Beneficiaries/BeneficiariesList/context.tsx index c2398c4..20b1e68 100644 --- a/src/Context/Beneficiaries/BeneficiariesList/context.tsx +++ b/src/Context/Beneficiaries/BeneficiariesList/context.tsx @@ -23,7 +23,9 @@ const BeneficiariesListProvider = ({ cpfFilter, nameFilter, allFilter, - setallFilter + setallFilter, + setTsId, + tsId } = BeneficiariesListState(); return ( @@ -41,7 +43,9 @@ const BeneficiariesListProvider = ({ cpfFilter, nameFilter, allFilter, - setallFilter + setallFilter, + setTsId, + tsId }} > {children} diff --git a/src/Context/Beneficiaries/BeneficiariesList/state.tsx b/src/Context/Beneficiaries/BeneficiariesList/state.tsx index b30f505..06136f5 100644 --- a/src/Context/Beneficiaries/BeneficiariesList/state.tsx +++ b/src/Context/Beneficiaries/BeneficiariesList/state.tsx @@ -7,6 +7,7 @@ export const BeneficiariesListState = () => { const [page, setPage] = useState(0); const [limite, setLimite] = useState(10); const [nameFilter, setnameFilter] = useState(); + const [tsId, setTsId] = useState() const [cpfFilter, setcpfFilter] = useState(); const [allFilter, setallFilter] = useState(""); @@ -18,7 +19,8 @@ export const BeneficiariesListState = () => { page: Math.floor(page / 10 + 1), name: nameFilter !== "" ? nameFilter : undefined, cpf: cpfFilter !== "" ? cpfFilter?.replace(/[^a-zA-Z0-9]/g, '') : undefined, - allFilter: allFilter !== "" ? allFilter : undefined + allFilter: allFilter !== "" ? allFilter : undefined, + idTs: tsId?.toString(), }); const handleFilter = (values: { name: string; cpf: string }) => { @@ -50,6 +52,7 @@ export const BeneficiariesListState = () => { nameFilter, cpfFilter, allFilter, - setallFilter + setallFilter, + tsId, setTsId }; }; diff --git a/src/Context/Beneficiaries/BeneficiariesList/type.ts b/src/Context/Beneficiaries/BeneficiariesList/type.ts index e549cf2..6cdd768 100644 --- a/src/Context/Beneficiaries/BeneficiariesList/type.ts +++ b/src/Context/Beneficiaries/BeneficiariesList/type.ts @@ -10,6 +10,8 @@ export interface BeneficiariesListType { nameFilter: string | undefined cpfFilter: string | undefined allFilter: string | undefined + tsId: number | undefined + setTsId: Dispatch> setallFilter: Dispatch> handleFilter: (values: { name: string; diff --git a/src/Context/Classroom/Registration/state.tsx b/src/Context/Classroom/Registration/state.tsx index bfe4f8c..fcd2771 100644 --- a/src/Context/Classroom/Registration/state.tsx +++ b/src/Context/Classroom/Registration/state.tsx @@ -51,6 +51,7 @@ export const RegistrationClassroomState = () => { /[^a-zA-Z0-9]/g, "" ), + kinship: data.kinship === "" ? "NAO_DEFINIDO" : data.kinship, responsable_cpf: data?.responsable_cpf?.replace(/[^a-zA-Z0-9]/g, ""), }, id: id, diff --git a/src/Context/Classroom/Registration/type.tsx b/src/Context/Classroom/Registration/type.tsx index a42c11a..b9cce83 100644 --- a/src/Context/Classroom/Registration/type.tsx +++ b/src/Context/Classroom/Registration/type.tsx @@ -29,7 +29,7 @@ export interface UpdateRegister status: {id: string, name: string} | undefined; registration_classroom_id?: number deficiency_description: any - kinship: string | undefined + kinship: string | undefined | null } export interface RegistrationType { id: number diff --git a/src/Context/Register/state.tsx b/src/Context/Register/state.tsx index 2a4efa8..18bbb9a 100644 --- a/src/Context/Register/state.tsx +++ b/src/Context/Register/state.tsx @@ -58,7 +58,7 @@ export const RegisterState = () => { const data = new Date(dataValues?.birthday); const dataFormatada = data?.toISOString()?.split('T')[0]; - 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, '') }) + 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, '') }) } const initialState: Registration = { diff --git a/src/Context/Register/type.tsx b/src/Context/Register/type.tsx index cb95491..5ca45ef 100644 --- a/src/Context/Register/type.tsx +++ b/src/Context/Register/type.tsx @@ -35,7 +35,7 @@ export interface Registration { responsable_name?: string; responsable_cpf?: string; responsable_telephone?: string; - kinship?: string; + kinship?: string | null; zone: number | null; } diff --git a/src/Controller/controllerGlobal.tsx b/src/Controller/controllerGlobal.tsx index f9744b2..a27f3d9 100644 --- a/src/Controller/controllerGlobal.tsx +++ b/src/Controller/controllerGlobal.tsx @@ -90,16 +90,14 @@ export const ROLE = { export const kinship = [ { id: "PAI", name: 'Pai' }, { id: "MAE", name: 'Mãe' }, - { id: "CONJUGE", name: 'Cônjuge' }, + { id: "PRIMO_A", name: 'Primo(a)' }, + { id: "TIO_A", name: 'Tio(a)' }, { 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' } + { id: "NAO_PARENTE", name: 'Não Parente' }, + { id: "NAO_DEFINIDO", name: 'Não Definido' } + ] export const loadImageFileAsBase64 = (imagePath: string): Promise => { diff --git a/src/Pages/Beneficiaries/BeneficiariesList/index.tsx b/src/Pages/Beneficiaries/BeneficiariesList/index.tsx index 0d2565b..8157fdf 100644 --- a/src/Pages/Beneficiaries/BeneficiariesList/index.tsx +++ b/src/Pages/Beneficiaries/BeneficiariesList/index.tsx @@ -19,6 +19,9 @@ import { import color from "../../../Styles/colors"; import { Padding, Row } from "../../../Styles/styles"; import ModalFilter from "./ModalFilter"; +import DropdownComponent from "../../../Components/Dropdown"; +import { PropsAplicationContext } from "../../../Types/types"; +import { AplicationContext } from "../../../Context/Aplication/context"; const BeneficiariesList = () => { return ( @@ -30,6 +33,7 @@ const BeneficiariesList = () => { const BeneficiariesListPage = () => { const props = useContext(BeneficiariesListContext) as BeneficiariesListType; + const propsAplication = useContext(AplicationContext) as PropsAplicationContext; const history = useNavigate(); const [visible, setVisible] = useState(); @@ -91,6 +95,22 @@ const BeneficiariesListPage = () => { return ( <> + + + {propsAplication.project + ? ( + { + props.setTsId(e.target.value); + }} + /> + ) : null}{" "} + {props.nameFilter?.length! > 0 && ( diff --git a/src/Services/Beneficiaries/query.tsx b/src/Services/Beneficiaries/query.tsx index 0e1e746..413dd13 100644 --- a/src/Services/Beneficiaries/query.tsx +++ b/src/Services/Beneficiaries/query.tsx @@ -6,15 +6,17 @@ export const useFetchRequestAllRegistration = ({ limite, cpf, name, - allFilter + allFilter, + idTs }: { page: number; limite: number; name?: string; cpf?: string; - allFilter?: string + allFilter?: string, + idTs?: string, }) => { - return useQuery(["useRequestAllRegistration", page, limite, cpf, name, allFilter], () => - requestAllRegistration({ limite: limite, page: page, cpf: cpf, name: name, allFilter: allFilter }) + return useQuery(["useRequestAllRegistration", page, limite, cpf, name, allFilter, idTs], () => + requestAllRegistration({ limite: limite, page: page, cpf: cpf, name: name, allFilter: allFilter, idTs: idTs }) ); }; diff --git a/src/Services/Beneficiaries/request.tsx b/src/Services/Beneficiaries/request.tsx index aa34f98..8433221 100644 --- a/src/Services/Beneficiaries/request.tsx +++ b/src/Services/Beneficiaries/request.tsx @@ -1,28 +1,31 @@ import http from "../axios"; -import { GetIdTs, logout } from "../localstorage"; +import { logout } from "../localstorage"; export const requestAllRegistration = ({ page, limite, cpf, name, - allFilter + allFilter, + idTs, }: { page: number; limite: number; name?: string, + idTs?: string, cpf?: string, allFilter?: string }) => { const nameFilter = name ? "&nameFilter=" + name : "" const cpfFilter = cpf ? "&cpfFilter=" + cpf : "" - const allFilterRequest = allFilter ? "&allFilter=" + allFilter : "" + const idTsFilter = idTs ? "&idTs=" + idTs : "" + const allFilterRequest = allFilter ? "&allFilter=" + allFilter.replace(/[^a-zA-Z0-9 ]/g, '') : "" let path = "/registration-token-bff/registration-all?page=" + page + "&limit=" + - limite + "&idTs="+ GetIdTs() + nameFilter + cpfFilter + allFilterRequest; + limite + idTsFilter + nameFilter + cpfFilter + allFilterRequest; return http .get(path) .then((response) => response.data) diff --git a/src/Services/PreRegistration/types.tsx b/src/Services/PreRegistration/types.tsx index 8aaed85..bdb57a1 100644 --- a/src/Services/PreRegistration/types.tsx +++ b/src/Services/PreRegistration/types.tsx @@ -13,6 +13,7 @@ export interface CreatePreRegistration { responsable_telephone?: string | null; zone: number; classroom: number; + kinship: string | undefined | null } export interface CreateRegistrationClassroomType {