Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
feat: use Grid to display the events link buttons (#2391)
Browse files Browse the repository at this point in the history
Co-authored-by: gikf <60067306+gikf@users.noreply.github.com>
  • Loading branch information
Muhammed Mustafa and gikf committed Jun 8, 2023
1 parent c61cb81 commit cbbfe82
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions client/src/modules/dashboard/shared/components/EventList.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,32 @@
import {
Flex,
Grid,
Heading,
Tag,
Text,
Button,
Menu,
MenuButton,
MenuList,
MenuItem,
} from '@chakra-ui/react';
import { Flex, Grid, Heading, Tag, Text } from '@chakra-ui/react';
import React from 'react';

import { LockIcon } from '@chakra-ui/icons';
import { LinkButton } from 'chakra-next-link';
import { CalendarIcon, LockIcon, SettingsIcon } from '@chakra-ui/icons';

interface Event {
canceled: boolean;
id: number;
invite_only: boolean;
name: string;
}

interface Props {
events: Event[];
emptyText?: string;
title: string;
}

export const EventList = ({ events, emptyText, title }: Props) => {
return (
<>
<Heading as="h2" marginBlock="1em" fontSize="lg">
{title}
</Heading>
{events.length > 0 ? (
<Grid gap="2em">
<Grid gap="4em">
{events.map(({ canceled, id, invite_only, name }) => (
<Flex justifyContent="space-between" key={id}>
<Menu>
<MenuButton as={Button}>{name}</MenuButton>
<MenuList minWidth="200">
<MenuItem as="a" href={`/dashboard/events/${id}`}>
Event dashboard
</MenuItem>
<MenuItem as="a" href={`/events/${id}`}>
Event page
</MenuItem>
</MenuList>
</Menu>

<Flex marginTop="1" gap="1em">
<Grid gap="1rem" key={id} gridTemplateColumns="repeat(4, 1fr)">
<Flex marginTop="1" gap="3em" gridColumn="1 / -1">
<Text>{name}</Text>
{invite_only && (
<Tag
borderRadius="lg"
Expand Down Expand Up @@ -78,7 +55,23 @@ export const EventList = ({ events, emptyText, title }: Props) => {
</Tag>
)}
</Flex>
</Flex>
<LinkButton
gridRow="2"
gridColumn={{ base: '1/ -1', md: '1/3', xl: '1/2' }}
href={`/dashboard/events/${id}`}
>
<Text srOnly>{name}</Text> Dashboard{' '}
<SettingsIcon marginInlineStart=".5em" />
</LinkButton>
<LinkButton
gridRow={{ base: '3', md: '2' }}
gridColumn={{ base: '1/ -1', md: '-3/ -1', xl: '2/3' }}
href={`/events/${id}`}
>
<Text srOnly>{name}</Text> Event Page{' '}
<CalendarIcon marginInlineStart=".5em" />
</LinkButton>
</Grid>
))}
</Grid>
) : (
Expand Down

0 comments on commit cbbfe82

Please sign in to comment.