From 84b737a16a7ec139ab514e36a0cf9f577c7ca8c5 Mon Sep 17 00:00:00 2001 From: TI JONNY Date: Tue, 19 Nov 2024 17:05:25 -0300 Subject: [PATCH] fix: listar atividades de uma turma, tipo de error --- .env | 4 +- src/Components/Stamp/index.tsx | 15 ++++-- src/Components/Stamp/style.ts | 50 ++++++++++++++++++- src/Components/TextInput/index.tsx | 4 +- src/Controller/controllerGlobal.tsx | 4 ++ src/Types/types.tsx | 1 + src/assets/image/stamp_gold.svg | 5 ++ .../classroom/activitiesClassroom/page.tsx | 46 ++++++++--------- .../activitiesClassroom/service/types.tsx | 4 ++ .../modalDistributeStamps/index.tsx | 2 +- .../classroom/oneClassroom/service/type.tsx | 2 + .../oneMember/modalDistributeStamps/index.tsx | 2 +- src/page/classroom/oneMember/page.tsx | 4 +- .../classroom/oneMember/service/types.tsx | 2 + src/page/profile/page.tsx | 2 +- src/page/profile/service/types.tsx | 2 + src/page/stramps/components/inputs/index.tsx | 31 ++++++++++-- src/page/stramps/createStramps copy/page.tsx | 3 +- .../createStramps copy/service/controller.tsx | 5 ++ .../createStramps copy/service/request.tsx | 2 +- .../stramps/createStramps/context/state.tsx | 10 +++- src/page/stramps/createStramps/page.tsx | 3 +- .../createStramps/service/controller.tsx | 5 +- src/page/stramps/listStramps/page.tsx | 2 +- src/page/viewdProfile/page.tsx | 2 +- src/page/viewdProfile/service/types.tsx | 2 + 26 files changed, 164 insertions(+), 50 deletions(-) create mode 100644 src/assets/image/stamp_gold.svg diff --git a/.env b/.env index 00dae6f..2d8c501 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -# REACT_APP_API_PATH=http://localhost:3000/ +REACT_APP_API_PATH=http://localhost:3000/ -REACT_APP_API_PATH=https://coded-api.azurewebsites.net/ +# REACT_APP_API_PATH=https://coded-api.azurewebsites.net/ diff --git a/src/Components/Stamp/index.tsx b/src/Components/Stamp/index.tsx index 66a6528..0988229 100644 --- a/src/Components/Stamp/index.tsx +++ b/src/Components/Stamp/index.tsx @@ -1,10 +1,15 @@ -import { StampStyle } from "./style" +import { HoverContainer, StampStyle } from "./style" -const Stamp = ({url}:{url: string}) => { - return( - - stamp +const Stamp = ({ url, description, type }: { url: string, description?: string, type: string }) => { + console.log(type) + return ( + + {/* */} + {description && +

{description}

+
} + stamp
) } diff --git a/src/Components/Stamp/style.ts b/src/Components/Stamp/style.ts index c9ec90f..c41836e 100644 --- a/src/Components/Stamp/style.ts +++ b/src/Components/Stamp/style.ts @@ -1,14 +1,26 @@ import styled from "styled-components"; import stamp from '../../assets/image/stamp.svg' +import stampGold from '../../assets/image/stamp_gold.svg' -export const StampStyle = styled.div` - background: url(${stamp}); +import color from "../../Styles/colors"; + +interface StampStyleType { + type: string +} + +export const StampStyle = styled.div` + + background: url(${props => props.type === "GOLD" ? stampGold : stamp}); background-repeat: no-repeat; background-size: 100%; /* background-position: right top; */ height: 90px; width: 90px; + position: relative; + display: inline-block; + + display: flex; flex-direction: column; @@ -18,4 +30,38 @@ export const StampStyle = styled.div` width: 32px; height: 32px; } + + #tooltip { + + } +`; + +export const HoverDiv = styled.div` + width: 200px; + height: 100px; + background-color: lightblue; + border: 1px solid blue; +`; + +export const HoverContainer = styled.div` + position: absolute; + top: 100%; + left: 0; + background-color: ${color.colorBlueClean}; + width: 256px; + /* width: auto; */ + padding: 10px; + /* border: 1px solid gray; */ + border-radius: 16px; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + opacity: 0; + visibility: hidden; + transform: translateY(-10px); + transition: all 0.3s ease-in-out; + + ${StampStyle}:hover & { + opacity: 1; + visibility: visible; + transform: translateY(0); + } `; \ No newline at end of file diff --git a/src/Components/TextInput/index.tsx b/src/Components/TextInput/index.tsx index d40caeb..14583be 100644 --- a/src/Components/TextInput/index.tsx +++ b/src/Components/TextInput/index.tsx @@ -10,7 +10,8 @@ const TextInput = ({ onBlur, name, type, - required + required, + accept }: PropsInputText) => { return (
@@ -23,6 +24,7 @@ const TextInput = ({ name={name} required={required} onChange={onChange} + accept={accept} placeholder={placeholder} />
diff --git a/src/Controller/controllerGlobal.tsx b/src/Controller/controllerGlobal.tsx index b167588..be2f302 100644 --- a/src/Controller/controllerGlobal.tsx +++ b/src/Controller/controllerGlobal.tsx @@ -133,6 +133,10 @@ export const type_tags = [ {id: "ACTIVITIES", name: "Atividades"} ] +export const type_stamp = [ + { id: "GOLD", name: "Ouro"}, + {id: "STANDARD", name: "Padrão"} +] export const Status = { APPROVED: "APPROVED", PENDING: "PENDING", diff --git a/src/Types/types.tsx b/src/Types/types.tsx index c65f642..aa9b743 100644 --- a/src/Types/types.tsx +++ b/src/Types/types.tsx @@ -15,6 +15,7 @@ export interface PropsInputText { name?: string type?: HTMLInputTypeAttribute | undefined required?: boolean + accept?: string | undefined } export interface PropsInputMask { diff --git a/src/assets/image/stamp_gold.svg b/src/assets/image/stamp_gold.svg new file mode 100644 index 0000000..665f328 --- /dev/null +++ b/src/assets/image/stamp_gold.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/page/classroom/activitiesClassroom/page.tsx b/src/page/classroom/activitiesClassroom/page.tsx index 97d156d..de9c695 100644 --- a/src/page/classroom/activitiesClassroom/page.tsx +++ b/src/page/classroom/activitiesClassroom/page.tsx @@ -19,43 +19,43 @@ const ClassroomActivitiesPage = () => { const [value, setValue] = useState() - - + + const propsActivitiesClassroom = useContext(ActivitiesClassroomContext) useEffect(() => { setValue(propsActivitiesClassroom?.classroomActivitiesList?.classroom_module[0]) - }, [propsActivitiesClassroom?.classroomActivitiesList?.classroom_module]) - + }, [propsActivitiesClassroom?.classroomActivitiesList?.classroom_module]) + return ( - {propsActivitiesClassroom?.classroomActivitiesList?.classroom_module?.length! > 0 ?<> -
-
- - - setValue(e.target.value)} /> + {propsActivitiesClassroom?.classroomActivitiesList?.classroom_module?.length! > 0 ? <> +
+
+ + + setValue(e.target.value)} /> +
-
- -
- {value?.classroom.classroom_activities.map((item, index) => { - return ( -
- -
- ) - })} -
- : } + +
+ {value?.classroom.classroom_activities.filter(props => props.activities?.classes.moduleId === value.module?.id).map((item, index) => { + return ( +
+ +
+ ) + })} +
+ : } <> - + {/* { propsActivitiesClassroom?.classroomActivitiesList?.classroom_activities.map((item) => { diff --git a/src/page/classroom/activitiesClassroom/service/types.tsx b/src/page/classroom/activitiesClassroom/service/types.tsx index 8752bc6..71bed45 100644 --- a/src/page/classroom/activitiesClassroom/service/types.tsx +++ b/src/page/classroom/activitiesClassroom/service/types.tsx @@ -21,8 +21,12 @@ export interface ClassroomActivity { export interface Activities { name: string id: number + classes: { + moduleId: number + } } export interface Module { name: string + id: number } diff --git a/src/page/classroom/oneClassroom/modalDistributeStamps/index.tsx b/src/page/classroom/oneClassroom/modalDistributeStamps/index.tsx index 86c484d..7ab95fb 100644 --- a/src/page/classroom/oneClassroom/modalDistributeStamps/index.tsx +++ b/src/page/classroom/oneClassroom/modalDistributeStamps/index.tsx @@ -63,7 +63,7 @@ const ModalDistributeStamps = ({ onHide, visible }: { visible: boolean, onHide() - + diff --git a/src/page/classroom/oneClassroom/service/type.tsx b/src/page/classroom/oneClassroom/service/type.tsx index 8ad07cf..e737f12 100644 --- a/src/page/classroom/oneClassroom/service/type.tsx +++ b/src/page/classroom/oneClassroom/service/type.tsx @@ -44,6 +44,8 @@ export interface ClassroomOne { id: number name: string img_url: string + description: string + type: string createdAt: string updatedAt: string } diff --git a/src/page/classroom/oneMember/modalDistributeStamps/index.tsx b/src/page/classroom/oneMember/modalDistributeStamps/index.tsx index 993df72..69d247e 100644 --- a/src/page/classroom/oneMember/modalDistributeStamps/index.tsx +++ b/src/page/classroom/oneMember/modalDistributeStamps/index.tsx @@ -53,7 +53,7 @@ const ModalDistributeStamps = ({ onHide, visible }: { visible: boolean, onHide() - + diff --git a/src/page/classroom/oneMember/page.tsx b/src/page/classroom/oneMember/page.tsx index 94cd737..2d413eb 100644 --- a/src/page/classroom/oneMember/page.tsx +++ b/src/page/classroom/oneMember/page.tsx @@ -258,8 +258,8 @@ const MemberOnePage = () => { {props.user.stamps_user.map((item) => { return ( - - + +

{item.stamps.name}

diff --git a/src/page/classroom/oneMember/service/types.tsx b/src/page/classroom/oneMember/service/types.tsx index 78ba195..e6080f3 100644 --- a/src/page/classroom/oneMember/service/types.tsx +++ b/src/page/classroom/oneMember/service/types.tsx @@ -39,6 +39,8 @@ export interface Stamps { id: number name: string img_url: string + description: string + type: string createdAt: string updatedAt: string } diff --git a/src/page/profile/page.tsx b/src/page/profile/page.tsx index e81020b..7e3274f 100644 --- a/src/page/profile/page.tsx +++ b/src/page/profile/page.tsx @@ -115,7 +115,7 @@ const ProfilePage = () => { return ( - +

{item.stamps.name}

diff --git a/src/page/profile/service/types.tsx b/src/page/profile/service/types.tsx index e073ba0..f8d736e 100644 --- a/src/page/profile/service/types.tsx +++ b/src/page/profile/service/types.tsx @@ -41,6 +41,8 @@ export interface Stamps { id: number name: string img_url: string + description: string + type: string createdAt: string updatedAt: string } diff --git a/src/page/stramps/components/inputs/index.tsx b/src/page/stramps/components/inputs/index.tsx index 55f0e44..2421111 100644 --- a/src/page/stramps/components/inputs/index.tsx +++ b/src/page/stramps/components/inputs/index.tsx @@ -3,14 +3,15 @@ import { useContext } from "react" import TextInput from "../../../../Components/TextInput" import { Padding } from "../../../../Styles/styles" import { StampsContext } from "../../createStramps/context/context" +import DropdownComponent from "../../../../Components/Dropdown" +import { type_stamp } from "../../../../Controller/controllerGlobal" const Inputs = ({ errors, handleChange, touched, values, isCreated }: { errors: any, values: any, touched: any, handleChange: any, isCreated?: boolean }) => { const propsStamps = useContext(StampsContext) return ( -
- +
@@ -28,12 +29,34 @@ const Inputs = ({ errors, handleChange, touched, values, isCreated }: { errors:
) : null}
- {isCreated &&
+
+ + + + + {errors.type && touched.type ? ( +
+ {errors.type} + +
+ ) : null} +
+ {isCreated &&
propsStamps?.setFile(e.target.files)} diff --git a/src/page/stramps/createStramps copy/page.tsx b/src/page/stramps/createStramps copy/page.tsx index 9c97f41..064cf29 100644 --- a/src/page/stramps/createStramps copy/page.tsx +++ b/src/page/stramps/createStramps copy/page.tsx @@ -6,6 +6,7 @@ import { Padding, Row } from "../../../Styles/styles" import Inputs from "../components/inputs" import StampsProvider, { StampsContext } from "./context/context" import { ProgressSpinner } from "primereact/progressspinner" +import { type_stamp } from "../../../Controller/controllerGlobal" const StampsUpdate = () => { return ( @@ -23,7 +24,7 @@ const StampsUpdatePage = () => { return ( - {propsStamps?.StampsOne && { + {propsStamps?.StampsOne && item.id === propsStamps?.StampsOne?.type) ?? "", }} onSubmit={(values) => { propsStamps?.UpdateStamps(values) }}> {({ values, errors, handleChange, touched }) => { diff --git a/src/page/stramps/createStramps copy/service/controller.tsx b/src/page/stramps/createStramps copy/service/controller.tsx index 0d834d5..c883417 100644 --- a/src/page/stramps/createStramps copy/service/controller.tsx +++ b/src/page/stramps/createStramps copy/service/controller.tsx @@ -20,6 +20,11 @@ export const UpdateStampsController = () => { }, onSuccess: (data) => { queryClient.refetchQueries("useRequestsFindStamps") + Swal.fire({ + icon: 'success', + title: "Turma alterada com sucesso!", + confirmButtonColor: styles.colors.colorPrimary, + }) }, } diff --git a/src/page/stramps/createStramps copy/service/request.tsx b/src/page/stramps/createStramps copy/service/request.tsx index d32e628..f8e23e8 100644 --- a/src/page/stramps/createStramps copy/service/request.tsx +++ b/src/page/stramps/createStramps copy/service/request.tsx @@ -3,7 +3,7 @@ import { logout } from "../../../../service/localstorage"; export const UpdateStampsRequest = async (body: any, id: number) => { - return await http.put("/stamps/"+ id, body) + return await http.put("/stamps/"+ id, {...body, type: body?.type?.id}) } export const FindOneStampsRequest = async (id: string) => { diff --git a/src/page/stramps/createStramps/context/state.tsx b/src/page/stramps/createStramps/context/state.tsx index 25fffa1..f009416 100644 --- a/src/page/stramps/createStramps/context/state.tsx +++ b/src/page/stramps/createStramps/context/state.tsx @@ -11,13 +11,19 @@ export const CreateStampsState = () => { const formData = new FormData() formData.append("name", body.name) + formData.append("description", body.description) + formData.append("type", body.type.id) - if(file){ + + if (file) { formData.append("file", file[0]) } + + console.log(formData) + CreateStampsRequestMutation.mutate(formData) } - + return { CreateStamps, file, setFile } } \ No newline at end of file diff --git a/src/page/stramps/createStramps/page.tsx b/src/page/stramps/createStramps/page.tsx index 8b26ec0..36b4594 100644 --- a/src/page/stramps/createStramps/page.tsx +++ b/src/page/stramps/createStramps/page.tsx @@ -20,7 +20,8 @@ const StampsCreatePage = () => { return ( - { + { + console.log(values) propsStamps?.CreateStamps(values) }}> {({ values, errors, handleChange, touched }) => { diff --git a/src/page/stramps/createStramps/service/controller.tsx b/src/page/stramps/createStramps/service/controller.tsx index f708191..618a913 100644 --- a/src/page/stramps/createStramps/service/controller.tsx +++ b/src/page/stramps/createStramps/service/controller.tsx @@ -2,9 +2,11 @@ import { useMutation } from "react-query"; import Swal from "sweetalert2"; import styles from "../../../../Styles"; import queryClient from "../../../../service/reactquery"; -import { CreateStampsRequest} from "./request"; +import { CreateStampsRequest } from "./request"; +import { useNavigate } from "react-router-dom"; export const CreateStampsController = () => { + const history = useNavigate() const CreateStampsRequestMutation = useMutation( (data: any) => CreateStampsRequest(data), @@ -18,6 +20,7 @@ export const CreateStampsController = () => { }, onSuccess: (data) => { queryClient.refetchQueries("useRequestsFindStamps") + history("/selos"); }, } diff --git a/src/page/stramps/listStramps/page.tsx b/src/page/stramps/listStramps/page.tsx index b331383..a0c3a0e 100644 --- a/src/page/stramps/listStramps/page.tsx +++ b/src/page/stramps/listStramps/page.tsx @@ -77,7 +77,7 @@ const StampsListPage = () => {
- } header="Selo"> + } header="Selo"> diff --git a/src/page/viewdProfile/page.tsx b/src/page/viewdProfile/page.tsx index 37655fd..1bb847b 100644 --- a/src/page/viewdProfile/page.tsx +++ b/src/page/viewdProfile/page.tsx @@ -57,7 +57,7 @@ const ProfilePage = () => { {props.user?.stamps_user.map((item) => { return ( - +

{item.stamps.name}

diff --git a/src/page/viewdProfile/service/types.tsx b/src/page/viewdProfile/service/types.tsx index e073ba0..94c2098 100644 --- a/src/page/viewdProfile/service/types.tsx +++ b/src/page/viewdProfile/service/types.tsx @@ -41,8 +41,10 @@ export interface Stamps { id: number name: string img_url: string + description: string createdAt: string updatedAt: string + type: string }