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

Common event list #1640

Merged
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
64 changes: 64 additions & 0 deletions src/features/events/components/EventSignUpCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { FC } from 'react';
import {
Button,
Card,
CardActions,
CardContent,
CardMedia,
Typography,
useTheme,
} from '@mui/material';

import { ZetkinEvent } from 'utils/types/zetkin';

type EventSignUpCardProps = {
event: ZetkinEvent;
};

const EventSignUpCard: FC<EventSignUpCardProps> = ({ event }) => {
const theme = useTheme();
// TODO: Instead of always using the en-US .toLocaleString, update to match the user settings.
const startTime = new Date(event.start_time).toLocaleString('sv-SE', {
hour: 'numeric',
minute: 'numeric',
});

return (
<Card sx={{ marginTop: '2rem' }}>
<CardMedia
alt={event.title || undefined}
component="img"
height="140"
image="https://zetkin.org/assets/img/hero.jpg"
/>
<CardContent>
<Typography component="div" gutterBottom variant="h5">
{event.title}
</Typography>
<Typography
component="p"
gutterBottom
sx={{ color: theme.palette.secondary.main, fontSize: '.7rem' }}
>
{startTime} - {event.location?.title}
</Typography>
<Typography color={theme.palette.secondary.main} variant="body2">
{event.info_text}
</Typography>
</CardContent>
<CardActions sx={{ justifyContent: 'space-between' }}>
<Button
href={`/o/${event.organization.id}/projects/${event.id}`}
size="small"
>
Read more
</Button>
<Button size="small" variant="contained">
Count me in!
</Button>
</CardActions>
</Card>
);
};

export default EventSignUpCard;
21 changes: 21 additions & 0 deletions src/features/events/components/EventSignUpList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Box } from '@mui/material';
import { FC } from 'react';

import EventSignUpCard from './EventSignUpCard';
import { ZetkinEvent } from 'utils/types/zetkin';

type EventSignUpListProps = {
events: ZetkinEvent[];
};

const EventSignUpList: FC<EventSignUpListProps> = ({ events }) => {
return (
<Box>
{events.map((event) => {
return <EventSignUpCard key={event.id} event={event} />;
})}
</Box>
);
};

export default EventSignUpList;
Loading