Skip to content

Commit

Permalink
chore: implement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Mar 13, 2024
1 parent f12638d commit f3e2b8e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
33 changes: 14 additions & 19 deletions apps/app/components/Event/EventInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ import {
} from "@ant-design/icons";

function EventInfo({
start_time,
end_time,
location,
team,
notes,
enrollments_open,
enrollments_close,
spots_available,
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 timeForEnrollmentsClose = () => {
const enrollmentsClose = new Date(enrollments_close).getTime();
const enrollmentsClose = new Date(event.enrollments_close).getTime();
const nowDate = new Date().getTime();
const timeDiff = (enrollmentsClose - nowDate) / (1000 * 60 * 60 * 24);
const timeDiff = (event.enrollmentsClose - nowDate) / (1000 * 60 * 60 * 24);

return timeDiff > 0 && timeDiff < 1; // Difference of less than a day
};
Expand All @@ -42,7 +37,7 @@ function EventInfo({
}
span={2}
>
{new Date(start_time).toLocaleString("pt", {
{new Date(event.start_time).toLocaleString("pt", {
weekday: "long",
year: "numeric",
month: "long",
Expand All @@ -58,7 +53,7 @@ function EventInfo({
}
span={5}
>
{notes}
{event.notes}
</Descriptions.Item>
<Descriptions.Item
labelStyle={labelStyle}
Expand All @@ -69,7 +64,7 @@ function EventInfo({
}
span={2}
>
{spots_available}
{enrolledNinjas} / {event.spots_available}
</Descriptions.Item>
<Descriptions.Item
labelStyle={labelStyle}
Expand All @@ -80,7 +75,7 @@ function EventInfo({
}
span={5}
>
{location?.name}
{event.location?.name}
</Descriptions.Item>
<Descriptions.Item
labelStyle={labelStyle}
Expand All @@ -91,7 +86,7 @@ function EventInfo({
}
span={2}
>
{new Date(start_time).toLocaleString("pt", {
{new Date(event.start_time).toLocaleString("pt", {
hour: "numeric",
minute: "numeric",
})}
Expand All @@ -105,7 +100,7 @@ function EventInfo({
}
span={5}
>
{new Date(end_time).toLocaleString("pt", {
{new Date(event.end_time).toLocaleString("pt", {
hour: "numeric",
minute: "numeric",
})}
Expand All @@ -119,7 +114,7 @@ function EventInfo({
}
span={2}
>
{team?.name}
{event.team?.name}
</Descriptions.Item>
<Descriptions.Item
labelStyle={labelStyle}
Expand All @@ -130,7 +125,7 @@ function EventInfo({
}
span={2}
>
{new Date(enrollments_open).toLocaleDateString("pt", {
{new Date(event.enrollments_open).toLocaleDateString("pt", {
year: "numeric",
month: "long",
day: "numeric",
Expand All @@ -153,7 +148,7 @@ function EventInfo({
}
span={2}
>
{new Date(enrollments_close).toLocaleDateString("pt", {
{new Date(event.enrollments_close).toLocaleDateString("pt", {
year: "numeric",
month: "long",
day: "numeric",
Expand Down
3 changes: 2 additions & 1 deletion apps/app/components/Event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Event = ({
collapsed = true,
details = false,
isLoading = false,
enrolledNinjas,
}) => {
const { user } = useAuth();
const role = user?.role;
Expand Down Expand Up @@ -119,7 +120,7 @@ const Event = ({
</Descriptions.Item>
</Descriptions>
) : (
<EventInfo {...event} />
<EventInfo event={event} enrolledNinjas={enrolledNinjas} />
)}
{role === EUser.Organizer ? (
<>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/pages/event/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ function EventPage() {
registerMentorOnEvent(value);
}
};

return (
<AppLayout>
<Title level={2}>Detalhes do evento</Title>
Expand All @@ -223,6 +222,7 @@ function EventPage() {
collapsed={false}
details={true}
isLoading={isLoading}
enrolledNinjas={enrolledNinjas.length}
/>
</Row>
<Col>
Expand Down

0 comments on commit f3e2b8e

Please sign in to comment.