diff --git a/apps/app/components/LectureForm/index.js b/apps/app/components/LectureForm/index.js index 248bc5ca..32ba42d6 100644 --- a/apps/app/components/LectureForm/index.js +++ b/apps/app/components/LectureForm/index.js @@ -34,6 +34,7 @@ export default function LectureForm({ id }) { setEvents(response.data); }); }, []); + useEffect(() => { if (id !== "new") { listEvents().then((response) => { @@ -51,15 +52,15 @@ export default function LectureForm({ id }) { }, []); const [ninjas, setNinjas] = useState([]); + const fetchData = useCallback(() => { + let promise; - let promise; - - const fetchData = () => { if (!promise) { promise = Promise.all(events.map((event) => getNinjaEvents(event.id))); } + return promise; - }; + }, [events]); useEffect(() => { fetchData().then((responses) => { @@ -71,7 +72,7 @@ export default function LectureForm({ id }) { ) ); }); - }, [events]); + }, [fetchData]); const [filteredNinjas, setFilteredNinjas] = useState([]); const handleEventChange = useCallback( @@ -94,7 +95,8 @@ export default function LectureForm({ id }) { const filtered = mentors.filter((mentor) => { const lecture = lectures.find( (lecture) => - lecture.mentor.id === mentor.id && lecture.event.id === selectedEvent + lecture.mentor.id === mentor.id && + lecture.event.id === selectedEvent.id ); return !lecture; }); @@ -107,17 +109,6 @@ export default function LectureForm({ id }) { ); }, [filteredNinjas]); - useEffect(() => { - const filtered = ninjas.filter((ninja) => { - const lecture = lectures.find( - (lecture) => - lecture.ninja.id === ninja.id && lecture.event.id === selectedEvent - ); - return !lecture; - }); - setFilteredNinjas(filtered); - }, [ninjas, selectedEvent, lectures, handleEventChange]); - useEffect(() => { setFilteredMentors( filteredMentors.sort((a, b) => a.first_name.localeCompare(b.first_name)) @@ -125,7 +116,7 @@ export default function LectureForm({ id }) { }, [filteredMentors]); const onFinish = (values) => { - if (Object.keys(selectedEvent).length != 0) { + if (Object.keys(selectedEvent).length !== 0) { api .createLecture(values) .then(() => { diff --git a/apps/app/components/Signup/index.js b/apps/app/components/Signup/index.tsx similarity index 67% rename from apps/app/components/Signup/index.js rename to apps/app/components/Signup/index.tsx index 8bb22d9b..547a61ab 100644 --- a/apps/app/components/Signup/index.js +++ b/apps/app/components/Signup/index.tsx @@ -6,6 +6,7 @@ import { Form, Input, Radio, + Space, Tooltip, Typography, } from "antd"; @@ -15,21 +16,19 @@ import { MailOutlined, } from "@ant-design/icons"; import { useAuth } from "@coderdojobraga/ui"; -import Koi from "~/components/Koi"; import styles from "./style.module.css"; function Signup() { const { Title, Text } = Typography; const { errors, isLoading, sign_up } = useAuth(); - const [size, setSize] = useState(""); - const handleSizeChange = (e) => { + const handleSizeChange = (e: any) => { setSize(e.target.value); }; - const onFinish = ({ email, password, role }) => { + const onFinish = ({ email, password, role }: any) => { sign_up({ email, password, role }); }; @@ -73,26 +72,30 @@ function Signup() { }, ]} > - - - Guardião - - - Mentor - - - - Ninja   - - - + + + + Guardião + + + + Mentor + + + + + Ninja + + + + + @@ -124,7 +127,7 @@ function Signup() {