|
| 1 | +import React, { useMemo } from "react"; |
| 2 | +import styled from "styled-components"; |
| 3 | +import { Dispute_Filter } from "../graphql/graphql"; |
| 4 | +import { DisputeDetailsFragment, useCasesQuery } from "queries/useCasesQuery"; |
| 5 | +import DisputeCard from "components/DisputeCard"; |
| 6 | +import { StyledSkeleton } from "components/StyledSkeleton"; |
| 7 | +import { isUndefined } from "utils/index"; |
| 8 | + |
| 9 | +const Container = styled.div` |
| 10 | + margin-top: calc(64px + (80 - 64) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 11 | +`; |
| 12 | + |
| 13 | +const Title = styled.h1` |
| 14 | + margin-bottom: calc(16px + (48 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 15 | +`; |
| 16 | + |
| 17 | +const DisputeContainer = styled.div` |
| 18 | + display: flex; |
| 19 | + gap: 24px; |
| 20 | + flex-wrap: wrap; |
| 21 | + justify-content: center; |
| 22 | +`; |
| 23 | + |
| 24 | +const LatestCases: React.FC<{ filters?: Dispute_Filter }> = ({ filters }) => { |
| 25 | + const { data } = useCasesQuery(0, 3, filters); |
| 26 | + const disputes: DisputeDetailsFragment[] = useMemo(() => data?.disputes as DisputeDetailsFragment[], [data]); |
| 27 | + |
| 28 | + return isUndefined(disputes) || disputes.length > 0 ? ( |
| 29 | + <Container> |
| 30 | + <Title>Latest Cases</Title> |
| 31 | + <DisputeContainer> |
| 32 | + {isUndefined(disputes) |
| 33 | + ? Array.from({ length: 3 }).map((_, index) => <StyledSkeleton key={index} width={312} height={260} />) |
| 34 | + : disputes.map((dispute) => <DisputeCard key={dispute.id} {...dispute} overrideIsList />)} |
| 35 | + </DisputeContainer> |
| 36 | + </Container> |
| 37 | + ) : null; |
| 38 | +}; |
| 39 | + |
| 40 | +export default LatestCases; |
0 commit comments