Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: align icons on event card #226

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions apps/app/components/Event/EventInfo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect, useState } from "react";
import { Descriptions } from "antd";
import {
AlignLeftOutlined,
Expand All @@ -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();
Expand All @@ -31,7 +43,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<CalendarOutlined /> Data
</span>
}
Expand All @@ -47,7 +59,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<AlignLeftOutlined /> Notas
</span>
}
Expand All @@ -58,18 +70,18 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<TeamOutlined /> Limite de Vagas
</span>
}
span={2}
>
{enrolledNinjas} / {event.spots_available}
{enrolledNinjas.length} / {event.spots_available}
</Descriptions.Item>
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<EnvironmentOutlined /> Localização
</span>
}
Expand All @@ -80,7 +92,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<ClockCircleOutlined /> Início
</span>
}
Expand All @@ -94,7 +106,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<ClockCircleOutlined /> Fim
</span>
}
Expand All @@ -108,7 +120,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<HomeOutlined /> Turma
</span>
}
Expand All @@ -119,7 +131,7 @@ function EventInfo({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<CheckCircleOutlined /> Abertura das inscrições
</span>
}
Expand All @@ -137,11 +149,11 @@ function EventInfo({
labelStyle={labelStyle}
label={
timeForEnrollmentsClose() ? (
<span className="animate-bounce text-yellow-600">
<span className="flex animate-bounce items-center gap-x-1 text-yellow-600">
<CloseCircleOutlined /> Fecho das inscrições
</span>
) : (
<span>
<span className="flex items-center gap-x-1">
<CloseCircleOutlined /> Fecho das inscrições
</span>
)
Expand Down
13 changes: 6 additions & 7 deletions apps/app/components/Event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const Event = ({
collapsed = true,
details = false,
isLoading = false,
enrolledNinjas,
}) => {
const { user } = useAuth();
const role = user?.role;
Expand Down Expand Up @@ -59,7 +58,7 @@ const Event = ({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<CalendarOutlined /> Data
</span>
}
Expand All @@ -74,7 +73,7 @@ const Event = ({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<EnvironmentOutlined /> Localização
</span>
}
Expand All @@ -85,7 +84,7 @@ const Event = ({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<ClockCircleOutlined /> Início
</span>
}
Expand All @@ -98,7 +97,7 @@ const Event = ({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<ClockCircleOutlined /> Fim
</span>
}
Expand All @@ -111,7 +110,7 @@ const Event = ({
<Descriptions.Item
labelStyle={labelStyle}
label={
<span>
<span className="flex items-center gap-x-1">
<HomeOutlined /> Turma
</span>
}
Expand All @@ -120,7 +119,7 @@ const Event = ({
</Descriptions.Item>
</Descriptions>
) : (
<EventInfo event={event} enrolledNinjas={enrolledNinjas} />
<EventInfo event={event} />
)}
{role === EUser.Organizer ? (
<>
Expand Down
1 change: 0 additions & 1 deletion apps/app/pages/admin/event/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function EventPage() {
collapsed={false}
details={true}
isLoading={isLoading}
enrolledNinjas={0}
/>
</Row>
<Divider />
Expand Down
1 change: 0 additions & 1 deletion apps/app/pages/event/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function EventPage() {
collapsed={false}
details={true}
isLoading={isLoading}
enrolledNinjas={enrolledNinjas.length}
/>
</Row>
<Col>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/pages/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Events() {
<Row className={styles.row} align="top" justify="start" gutter={[16, 16]}>
{events?.map((info) => (
<Col key={info.id}>
<Event event={info} loading={isLoading} enrolledNinjas={0} />
<Event event={info} loading={isLoading} />
</Col>
))}
</Row>
Expand Down
7 changes: 1 addition & 6 deletions apps/app/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ function Dashboard() {
event={nextEvent()}
collapsed={false}
isLoading={isLoadingEvents}
enrolledNinjas={0}
/>
) : (
<Typography>Aguarda que o próximo evento seja divulgado</Typography>
Expand All @@ -125,11 +124,7 @@ function Dashboard() {
>
{events?.slice(0, 3).map((event: any) => (
<Col key={event.id}>
<Event
event={event}
isLoading={isLoadingEvents}
enrolledNinjas={0}
/>
<Event event={event} isLoading={isLoadingEvents} />
</Col>
))}
</Row>
Expand Down
Loading