diff --git a/apps/app/components/Event/EventInfo.js b/apps/app/components/Event/EventInfo.js index 50bd47cf..f16395d9 100644 --- a/apps/app/components/Event/EventInfo.js +++ b/apps/app/components/Event/EventInfo.js @@ -1,3 +1,4 @@ +import { useEffect, useState } from "react"; import { Descriptions } from "antd"; import { AlignLeftOutlined, @@ -9,14 +10,25 @@ import { HomeOutlined, TeamOutlined, } from "@ant-design/icons"; +import { getEnrolledNinjas } from "bokkenjs"; function EventInfo({ event, - enrolledNinjas, breakpoints = { xs: 1, sm: 1, md: 1, lg: 1, xl: 1, xxl: 6 }, }) { - enrolledNinjas = typeof enrolledNinjas !== "undefined" ? enrolledNinjas : 0; const labelStyle = { color: "rgba(0, 0, 0, 0.45)", maxWidth: "30vw" }; + const [enrolledNinjas, setEnrolledNinjas] = useState([]); + + useEffect(() => { + getEnrolledNinjas(event.id) + .then((response) => setEnrolledNinjas(response.data)) + .catch((error) => { + notifyError( + "Ocorreu um erro", + "Não foi possível obter os ninjas inscritos" + ); + }); + }, [event.id]); const timeForEnrollmentsClose = () => { const enrollmentsClose = new Date(event.enrollments_close).getTime(); @@ -31,7 +43,7 @@ function EventInfo({ + Data } @@ -47,7 +59,7 @@ function EventInfo({ + Notas } @@ -58,18 +70,18 @@ function EventInfo({ + Limite de Vagas } span={2} > - {enrolledNinjas} / {event.spots_available} + {enrolledNinjas.length} / {event.spots_available} + Localização } @@ -80,7 +92,7 @@ function EventInfo({ + Início } @@ -94,7 +106,7 @@ function EventInfo({ + Fim } @@ -108,7 +120,7 @@ function EventInfo({ + Turma } @@ -119,7 +131,7 @@ function EventInfo({ + Abertura das inscrições } @@ -137,11 +149,11 @@ function EventInfo({ labelStyle={labelStyle} label={ timeForEnrollmentsClose() ? ( - + Fecho das inscrições ) : ( - + Fecho das inscrições ) diff --git a/apps/app/components/Event/index.js b/apps/app/components/Event/index.js index e1808e0e..891ab756 100644 --- a/apps/app/components/Event/index.js +++ b/apps/app/components/Event/index.js @@ -17,7 +17,6 @@ const Event = ({ collapsed = true, details = false, isLoading = false, - enrolledNinjas, }) => { const { user } = useAuth(); const role = user?.role; @@ -59,7 +58,7 @@ const Event = ({ + Data } @@ -74,7 +73,7 @@ const Event = ({ + Localização } @@ -85,7 +84,7 @@ const Event = ({ + Início } @@ -98,7 +97,7 @@ const Event = ({ + Fim } @@ -111,7 +110,7 @@ const Event = ({ + Turma } @@ -120,7 +119,7 @@ const Event = ({ ) : ( - + )} {role === EUser.Organizer ? ( <> diff --git a/apps/app/pages/admin/event/[id].tsx b/apps/app/pages/admin/event/[id].tsx index dabb592d..4f3787b4 100644 --- a/apps/app/pages/admin/event/[id].tsx +++ b/apps/app/pages/admin/event/[id].tsx @@ -56,7 +56,6 @@ function EventPage() { collapsed={false} details={true} isLoading={isLoading} - enrolledNinjas={0} /> diff --git a/apps/app/pages/event/[id].tsx b/apps/app/pages/event/[id].tsx index 9fea4ee3..07a1f8f7 100644 --- a/apps/app/pages/event/[id].tsx +++ b/apps/app/pages/event/[id].tsx @@ -222,7 +222,6 @@ function EventPage() { collapsed={false} details={true} isLoading={isLoading} - enrolledNinjas={enrolledNinjas.length} /> diff --git a/apps/app/pages/events.js b/apps/app/pages/events.js index 234d4592..dbc3a19b 100644 --- a/apps/app/pages/events.js +++ b/apps/app/pages/events.js @@ -17,7 +17,7 @@ function Events() { {events?.map((info) => ( - + ))} diff --git a/apps/app/pages/index.tsx b/apps/app/pages/index.tsx index c6a67e47..a250c6e4 100644 --- a/apps/app/pages/index.tsx +++ b/apps/app/pages/index.tsx @@ -110,7 +110,6 @@ function Dashboard() { event={nextEvent()} collapsed={false} isLoading={isLoadingEvents} - enrolledNinjas={0} /> ) : ( Aguarda que o próximo evento seja divulgado @@ -125,11 +124,7 @@ function Dashboard() { > {events?.slice(0, 3).map((event: any) => ( - + ))}