Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ScrollArea } from '~/components/generic/ScrollArea';
import { Separator } from '~/components/generic/Separator';
import { Spinner } from '~/components/generic/Spinner';
import { MatchResultCard } from '~/components/MatchResultCard';
import { MatchResultCreateDialog, useMatchResultCreateDialog } from '~/components/MatchResultCreateDialog';
import { useGetMatchResults } from '~/services/matchResults';
import { PATHS } from '~/settings';

Expand All @@ -21,54 +22,58 @@ export const MatchResultsCard = ({
}: MatchResultsCardProps): JSX.Element => {
const navigate = useNavigate();
const { data: matchResults, loading } = useGetMatchResults({});
const { open } = useMatchResultCreateDialog();

const handleViewMore = (): void => {
navigate(PATHS.matchResults);
};

const handleCreate = (): void => {
navigate(PATHS.tournamentCreate);
open();
};

return (
<div className={clsx(styles.MatchResultsCard, className)}>
{loading ? (
<div className={styles.MatchResultsCard_Loading}>
<Spinner /> Loading...
</div>
) : (
<>
<div className={styles.MatchResultsCard_Header}>
<h2>
Recent Matches
</h2>
<div className={styles.MatchResultsCard_Header_Actions}>
<Button variant="secondary" onClick={handleViewMore}>
<ChevronRight />
</Button>
</div>
<>
<div className={clsx(styles.MatchResultsCard, className)}>
{loading ? (
<div className={styles.MatchResultsCard_Loading}>
<Spinner /> Loading...
</div>
<Separator />
{(matchResults ?? []).length ? (
<ScrollArea className={styles.MatchResultsCard_ScrollArea}>
<div className={styles.MatchResultsCard_List}>
{(matchResults ?? []).map((matchResult) => (
<MatchResultCard key={matchResult._id} matchResult={matchResult} />
))}
<div className={styles.MatchResultsCard_List_ViewAllButton} onClick={handleViewMore}>
<Button>View All<ChevronRight /></Button>
</div>
) : (
<>
<div className={styles.MatchResultsCard_Header}>
<h2>
Recent Matches
</h2>
<div className={styles.MatchResultsCard_Header_Actions}>
<Button variant="secondary" onClick={handleViewMore}>
<ChevronRight />
</Button>
</div>
</ScrollArea>
) : (
<div className={styles.MatchResultsCard_EmptyState}>
<Button onClick={handleCreate}>
Check-In<Plus />
</Button>
</div>
)}
</>
)}
</div>
<Separator />
{(matchResults ?? []).length ? (
<ScrollArea className={styles.MatchResultsCard_ScrollArea}>
<div className={styles.MatchResultsCard_List}>
{(matchResults ?? []).map((matchResult) => (
<MatchResultCard key={matchResult._id} matchResult={matchResult} />
))}
<div className={styles.MatchResultsCard_List_ViewAllButton} onClick={handleViewMore}>
<Button>View All<ChevronRight /></Button>
</div>
</div>
</ScrollArea>
) : (
<div className={styles.MatchResultsCard_EmptyState}>
<Button onClick={handleCreate}>
Check-In<Plus />
</Button>
</div>
)}
</>
)}
</div>
<MatchResultCreateDialog />
</>
);
};