From 23dcdb5ea4102af0c2bb5d8e0dddca8e459f77b4 Mon Sep 17 00:00:00 2001 From: jonny paulino Date: Wed, 17 Jul 2024 10:13:00 -0300 Subject: [PATCH] v1 admin synapse --- src/Components/Layout/TopBar/style.ts | 2 +- .../ModalAddStudent/index.tsx | 125 +++++++----------- src/Pages/School/SchoolList/index.tsx | 2 +- src/Pages/Student/StudentList/index.tsx | 1 - src/Pages/Users/CreateUser/index.tsx | 3 +- src/Services/Classroom/controller.tsx | 2 +- src/Services/Login/controller.tsx | 47 ++++--- src/Services/Login/request.tsx | 6 +- src/Services/SocialTechnology/request.tsx | 20 +-- 9 files changed, 90 insertions(+), 118 deletions(-) diff --git a/src/Components/Layout/TopBar/style.ts b/src/Components/Layout/TopBar/style.ts index 4bc7954..dda0216 100644 --- a/src/Components/Layout/TopBar/style.ts +++ b/src/Components/Layout/TopBar/style.ts @@ -11,7 +11,7 @@ export const Container = styled.div` padding: 10px; .iconResponsive { - @media screen and (min-width: 750px) { + @media screen and (min-width: 1080px) { display: none ; } } diff --git a/src/Pages/Classroom/ClassroomOne/RegistrationList/ModalAddStudent/index.tsx b/src/Pages/Classroom/ClassroomOne/RegistrationList/ModalAddStudent/index.tsx index eb032f5..068c52d 100644 --- a/src/Pages/Classroom/ClassroomOne/RegistrationList/ModalAddStudent/index.tsx +++ b/src/Pages/Classroom/ClassroomOne/RegistrationList/ModalAddStudent/index.tsx @@ -1,16 +1,13 @@ import { Form, Formik } from "formik"; import { Button } from "primereact/button"; import { Dialog } from "primereact/dialog"; +import { useContext } from "react"; import { useParams } from "react-router-dom"; import DropdownComponent from "../../../../../Components/Dropdown"; -import { Column, Padding, Row } from "../../../../../Styles/styles"; -import { RadioButton } from "primereact/radiobutton"; -import { useContext, useState } from "react"; -import UsersProvider from "../../../../../Context/Users/context"; -import { CreateUserPage } from "../../../../Users/CreateUser"; -import { useFetchRequestAllRegistration } from "../../../../../Services/Beneficiaries/query"; import { RegistrationClassroomContext } from "../../../../../Context/Classroom/RegistrationsList/context"; import { RegistrationClassroomTypes } from "../../../../../Context/Classroom/RegistrationsList/type"; +import { useFetchRequestAllRegistration } from "../../../../../Services/Beneficiaries/query"; +import { Column, Padding, Row } from "../../../../../Styles/styles"; const ModalAddStudent = ({ onHide, @@ -26,16 +23,12 @@ const ModalAddStudent = ({ ) as RegistrationClassroomTypes; - const [isNew, setIsNew] = useState(false); - - const { data: registrationsRequests } = useFetchRequestAllRegistration(); const initialValues = { classroom_id: id, - student_id: "" - } - + student_id: "", + }; return ( -
-
-
- setIsNew(e.value)} - checked={isNew === false} - /> - -
-
- setIsNew(e.value)} - checked={isNew === true} - /> - -
-
-
- {isNew ? ( - - - - ) : ( - { - props.AddStudentClassroom({ student_id: parseInt(values.student_id), classroom_id: parseInt(id!) }) - onHide(); - }} - > - {({ values, handleChange, errors, touched }) => { - return ( -
-
- - - - {errors.student_id && touched.student_id ? ( -
- {errors.student_id} -
- ) : null} -
- - - -
); }; diff --git a/src/Pages/School/SchoolList/index.tsx b/src/Pages/School/SchoolList/index.tsx index e9a9ca6..28e546c 100644 --- a/src/Pages/School/SchoolList/index.tsx +++ b/src/Pages/School/SchoolList/index.tsx @@ -35,7 +35,7 @@ const TecnologySocial = () => {
{propsAplication.project?.map((item, index) => { return ( -
+
); diff --git a/src/Pages/Student/StudentList/index.tsx b/src/Pages/Student/StudentList/index.tsx index 7a0056f..73e104c 100644 --- a/src/Pages/Student/StudentList/index.tsx +++ b/src/Pages/Student/StudentList/index.tsx @@ -89,7 +89,6 @@ const BeneficiariesListPage = () => { value={props.registrations} tableStyle={{ minWidth: "50rem" }} header={renderHeader} - showGridlines paginator rows={10} > diff --git a/src/Pages/Users/CreateUser/index.tsx b/src/Pages/Users/CreateUser/index.tsx index fce565e..080da23 100644 --- a/src/Pages/Users/CreateUser/index.tsx +++ b/src/Pages/Users/CreateUser/index.tsx @@ -40,7 +40,7 @@ export const CreateUserPage = ({ isStudent }: { isStudent: boolean }) => { }); return ( - + { validationSchema={CreateUserSchema} > {({ values, handleChange, errors, touched }) => { - console.log(errors); return (
{ confirmButtonColor: styles.colors.colorsBaseProductNormal, }).then((result) => { if (result.isConfirmed) { - queryClient.refetchQueries("") + queryClient.refetchQueries("useRequestsClassroomRegistration") } }); }, diff --git a/src/Services/Login/controller.tsx b/src/Services/Login/controller.tsx index 12b80cc..0b55a14 100644 --- a/src/Services/Login/controller.tsx +++ b/src/Services/Login/controller.tsx @@ -6,7 +6,7 @@ import { idUser, login, logout, menuItem } from "../localstorage"; import { LoginRequest, LoginSystemRequest } from "./request"; import { LoginTypes } from "./types"; -export const LoginController = ({ setError }: { setError: any, }) => { +export const LoginController = ({ setError }: { setError: any }) => { const history = useNavigate(); const LoginRequestMutation = useMutation( @@ -14,20 +14,26 @@ export const LoginController = ({ setError }: { setError: any, }) => { { onError: (error: any) => { Swal.fire({ - icon: 'error', + icon: "error", title: error.response.data.message, confirmButtonColor: styles.colors.colorsBaseProductNormal, - }) - setError(error.response.data.message) + }); + setError(error.response.data.message); }, onSuccess: (data) => { - idUser(JSON.stringify(data.data)); - - history("/"); - menuItem("1"); - window.location.reload(); + if (data.data?.student?.id) { + Swal.fire({ + icon: "error", + title: "Seu usuário não tem permissão para acessar o sistema.", + confirmButtonColor: styles.colors.colorsBaseProductNormal, + }); + } else { + idUser(JSON.stringify(data.data)); + history("/"); + menuItem("1"); + window.location.reload(); + } }, - } ); @@ -36,25 +42,26 @@ export const LoginController = ({ setError }: { setError: any, }) => { { onError: (error: any) => { Swal.fire({ - icon: 'error', + icon: "error", title: error.response.data.message, confirmButtonColor: styles.colors.colorsBaseProductNormal, - }) - setError(error.response.data.message) + }); + setError(error.response.data.message); }, onSuccess: (data, variables) => { - logout() + logout(); login(data.data.token); - LoginRequestMutation.mutate({user_name: variables.user_name, password: variables.password}) - + LoginRequestMutation.mutate({ + user_name: variables.user_name, + password: variables.password, + }); }, - } ); return { LoginRequestMutation, - LoginSystemRequestMutation - } -} \ No newline at end of file + LoginSystemRequestMutation, + }; +}; diff --git a/src/Services/Login/request.tsx b/src/Services/Login/request.tsx index db15d4d..268914f 100644 --- a/src/Services/Login/request.tsx +++ b/src/Services/Login/request.tsx @@ -2,11 +2,9 @@ import http from "../axios"; import { LoginTypes } from "./types"; export const LoginSystemRequest = async (body: LoginTypes) => { - - console.log(process.env.REACT_APP_API_PATH_USERNAME) return await http.post("/user/login-system-auth", { - user_name: "editor", - password: "iptisynpaseeditor2022", + user_name: process.env.REACT_APP_API_PATH_USERNAME, + password: process.env.REACT_APP_API_PATH_PASSWORD, }); }; diff --git a/src/Services/SocialTechnology/request.tsx b/src/Services/SocialTechnology/request.tsx index 6e796ee..44e5f2e 100644 --- a/src/Services/SocialTechnology/request.tsx +++ b/src/Services/SocialTechnology/request.tsx @@ -1,8 +1,7 @@ import http from "../axios"; -import { GetIdUser } from "../localstorage"; +import { GetIdUser, logout } from "../localstorage"; export const requestSocialTechnologytList = async () => { - console.log(GetIdUser()) if (false) { return await http .get("/user/teacher-school/" + GetIdUser().id) @@ -22,10 +21,11 @@ export const requestSocialTechnologytList = async () => { .get("/school") .then((response) => response.data) .catch((err) => { - // if(err.response.status === 401){ - // logout() - // window.location.reload() - // } + + if(err.response.status === 401){ + logout() + window.location.reload() + } throw err; }); @@ -55,10 +55,10 @@ export const requestCreateSocialTechnology = async (body: {name: string, uf: str .post("/school", body) .then((response) => response.data) .catch((err) => { - // if(err.response.status === 401){ - // logout() - // window.location.reload() - // } + if(err.response.status === 401){ + logout() + window.location.reload() + } throw err; });