-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35bcdf1
commit 472c436
Showing
8 changed files
with
191 additions
and
8 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
explorer/src/pages/Attestation/components/AttestationCard/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { ChevronRight } from "lucide-react"; | ||
import { generatePath, useLocation, useNavigate } from "react-router-dom"; | ||
import { useTernaryDarkMode } from "usehooks-ts"; | ||
|
||
import { Button } from "@/components/Buttons"; | ||
import { EButtonType } from "@/components/Buttons/enum"; | ||
import { useNetworkContext } from "@/providers/network-provider/context"; | ||
import { APP_ROUTES } from "@/routes/constants"; | ||
import { parseDateTime } from "@/utils/dateUtils"; | ||
|
||
import { IAttestationCardProps } from "./interface"; | ||
|
||
export const AttestationCard: React.FC<IAttestationCardProps> = ({ | ||
id, | ||
logo, | ||
logoDark, | ||
name, | ||
description, | ||
issuerName, | ||
issuanceDate, | ||
}) => { | ||
const { | ||
network: { network }, | ||
} = useNetworkContext(); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const { isDarkMode } = useTernaryDarkMode(); | ||
|
||
const handleViewDetailsClick = (id: string) => { | ||
navigate(generatePath(APP_ROUTES.ATTESTATION_BY_ID, { chainId: network, id }), { | ||
state: { from: location.pathname }, | ||
}); | ||
}; | ||
|
||
const displayLogo = () => { | ||
const Logo: React.FC<React.SVGProps<SVGSVGElement>> = isDarkMode && logoDark ? logoDark : logo; | ||
return <Logo className="w-full h-auto max-w-[2.5rem] md:max-w-[3rem] max-h-[2.5rem] md:max-h-[3rem]" />; | ||
}; | ||
|
||
return ( | ||
<div | ||
key={`${id}`} | ||
className="group flex flex-col gap-4 border border-border-card dark:border-border-cardDark rounded-xl p-4 md:p-6 hover:bg-surface-secondary dark:hover:bg-surface-secondaryDark transition md:min-h-[20rem]" | ||
> | ||
<div className="flex items-center gap-3 text-xl md:text-2xl font-semibold text-blackDefault dark:text-whiteDefault"> | ||
<div className="w-[2.5rem] h-[2.5rem] md:w-[3rem] md:h-[3rem] flex items-center justify-center"> | ||
{displayLogo()} | ||
</div> | ||
{name} | ||
</div> | ||
{description && description.trim() ? ( | ||
<div className="text-sm font-normal text-text-darkGrey dark:text-tertiary">{description}</div> | ||
) : null} | ||
<div className="text-sm font-normal text-text-darkGrey dark:text-tertiary"> | ||
<span className="font-bold">Issuer : </span> | ||
{issuerName} | ||
</div> | ||
<div className="text-sm font-normal text-text-darkGrey dark:text-tertiary"> | ||
<span className="font-bold">Date : </span> | ||
{parseDateTime(issuanceDate.toString(), true).stringUTC} | ||
</div> | ||
<div className="flex flex-1 flex-col lg:flex-row lg:items-end gap-4 justify-end lg:justify-start"> | ||
<Button | ||
isSmall | ||
name="View details" | ||
handler={() => handleViewDetailsClick(id)} | ||
buttonType={EButtonType.OUTLINED} | ||
iconRight={<ChevronRight />} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
explorer/src/pages/Attestation/components/AttestationCard/interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface IAttestationCardProps { | ||
id: string; | ||
logo: React.FC<React.SVGProps<SVGSVGElement>>; | ||
logoDark?: React.FC<React.SVGProps<SVGSVGElement>>; | ||
name: string; | ||
description?: string; | ||
issuerName: string; | ||
issuanceDate: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { OrderDirection } from "@verax-attestation-registry/verax-sdk/lib/types/.graphclient"; | ||
import { useParams } from "react-router-dom"; | ||
import useSWR from "swr"; | ||
|
||
import { EQueryParams } from "@/enums/queryParams"; | ||
import { SWRKeys } from "@/interfaces/swr/enum"; | ||
import { useNetworkContext } from "@/providers/network-provider/context"; | ||
|
||
import { AttestationCard } from "../Attestation/components/AttestationCard"; | ||
import { issuersData } from "../Home/data"; | ||
import { IIssuer } from "../Home/interface"; | ||
|
||
export const Subject: React.FC = () => { | ||
const { subject } = useParams(); | ||
const { | ||
sdk, | ||
network: { chain }, | ||
} = useNetworkContext(); | ||
const searchParams = new URLSearchParams(window.location.search); | ||
const sortByDateDirection = searchParams.get(EQueryParams.SORT_BY_DATE); | ||
|
||
const { data: attestationsList } = useSWR( | ||
`${SWRKeys.GET_ATTESTATION_LIST}/${subject}/${sortByDateDirection}/${chain.id}`, | ||
() => | ||
sdk.attestation.findBy( | ||
undefined, | ||
undefined, | ||
{ subject }, | ||
"attestedDate", | ||
(sortByDateDirection as OrderDirection) || "desc", | ||
), | ||
); | ||
|
||
return ( | ||
<div className="flex flex-col gap-14 md:gap-[4.5rem] container mt-14 md:mt-12"> | ||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6"> | ||
{attestationsList && | ||
attestationsList.map((attestation) => { | ||
const issuerData = issuersData.find((issuer) => | ||
issuer.attestationDefinitions.some( | ||
(definition) => | ||
definition.schema === attestation.schema.id && definition.portal === attestation.portal.id, | ||
), | ||
) as IIssuer; | ||
const attestationDefinitions = issuerData?.attestationDefinitions.find( | ||
(definition) => definition.schema === attestation.schema.id, | ||
); | ||
|
||
if (!issuerData) return null; | ||
return ( | ||
<AttestationCard | ||
key={attestation.id} | ||
id={attestation.id} | ||
logo={attestationDefinitions?.logo ?? issuerData?.logo} | ||
logoDark={attestationDefinitions?.logoDark ?? issuerData?.logoDark} | ||
name={attestationDefinitions?.name ?? issuerData?.name} | ||
description={attestationDefinitions?.description ?? ""} | ||
issuerName={issuerData.name} | ||
issuanceDate={attestation.attestedDate} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters