-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add UI draft * Add draft org overview * Add verify proof alias * Fix org overview layout * Update org overview * Update proof viewer * Add loading states * Add credential field * Add link API * Update proof check * Chore code * Update link types * Add review fixes * Load and parse proof schema * Parse link ID * Fix orgs includes * Fix review comments
- Loading branch information
Showing
29 changed files
with
583 additions
and
47 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './link' | ||
export * from './orgs' |
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 @@ | ||
export * from './proofs' |
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,87 @@ | ||
import { api, type Proof, type ProofLink } from '@/api' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const DUMMY_PROOFS: Proof[] = [ | ||
{ | ||
id: '550e8400-e29b-41d4-a716-446655440000', | ||
type: 'proofs', | ||
creator: 'did:ethr:0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef', | ||
created_at: '2021-08-12T14:00:00Z', | ||
proof: '{"pub_signals":[...],"proof":{"pi_a":[...],"pi_b":[],"pi_c":[...]}}', | ||
proof_type: 'firstName', | ||
org_id: '550e8400-e29b-41d4-a716-446655440000', | ||
schema_url: | ||
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json', | ||
}, | ||
{ | ||
id: '550e8400-e29b-41d4-a716-446655440001', | ||
type: 'proofs', | ||
creator: 'did:ethr:0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef', | ||
created_at: '2021-08-12T14:00:00Z', | ||
proof: '{"pub_signals":[...],"proof":{"pi_a":[...],"pi_b":[],"pi_c":[...]}}', | ||
proof_type: 'lastName', | ||
org_id: '550e8400-e29b-41d4-a716-446655440000', | ||
schema_url: | ||
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCCountryOfResidenceCredential-v4.json', | ||
}, | ||
{ | ||
id: '550e8400-e29b-41d4-a716-446655440002', | ||
type: 'proofs', | ||
creator: 'did:ethr:0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef', | ||
created_at: '2021-08-12T14:00:00Z', | ||
proof: '{"pub_signals":[...],"proof":{"pi_a":[...],"pi_b":[],"pi_c":[...]}}', | ||
proof_type: 'telegram', | ||
org_id: '550e8400-e29b-41d4-a716-446655440000', | ||
schema_url: | ||
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json', | ||
}, | ||
] | ||
|
||
export const createProof = async (proof: string) => { | ||
const { data } = await api.post<Proof>('/v1/proofs', { | ||
body: { | ||
data: { | ||
type: 'proofs', | ||
proof, | ||
}, | ||
}, | ||
}) | ||
|
||
return data | ||
} | ||
|
||
export const getProofById = async (id: string) => { | ||
const { data } = await api.get<Proof>(`/v1/proofs/${id}`) | ||
|
||
return data | ||
} | ||
|
||
export const createLinkProofs = async (proofIds: string[]) => { | ||
const { data } = await api.post<ProofLink>('/v1/proofs/link', { | ||
body: { | ||
data: { | ||
proofs_ids: proofIds, | ||
}, | ||
}, | ||
}) | ||
|
||
return data | ||
} | ||
|
||
export const getProofsByLinkId = async (linkId: string) => { | ||
const { data } = await api.get<Proof[]>(`/v1/proofs/link/${linkId}`) | ||
|
||
return data | ||
} | ||
|
||
export const getProofsByUserDid = async (userDid: string) => { | ||
const { data } = await api.get<Proof[]>(`/v1/proofs/user/${userDid}`) | ||
|
||
return data | ||
} | ||
|
||
export const getProofLinksByUserDid = async (userDid: string) => { | ||
const { data } = await api.get<ProofLink[]>(`/v1/proofs/user/${userDid}/link`) | ||
|
||
return data | ||
} |
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 @@ | ||
export * from './link-proofs' |
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,29 @@ | ||
import { useCallback } from 'react' | ||
|
||
import { getProofsByLinkId } from '@/api' | ||
import { useLoading } from '@/hooks' | ||
|
||
export const useLinkProofs = (id: string) => { | ||
const loadProofs = useCallback(async () => { | ||
if (!id) return [] | ||
|
||
return getProofsByLinkId(id) | ||
}, [id]) | ||
|
||
const { | ||
data: proofs, | ||
isLoading, | ||
isLoadingError, | ||
isEmpty, | ||
} = useLoading([], loadProofs, { | ||
loadOnMount: !!id, | ||
loadArgs: [id], | ||
}) | ||
|
||
return { | ||
proofs, | ||
isLoading, | ||
isLoadingError, | ||
isEmpty, | ||
} | ||
} |
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,3 @@ | ||
export * from './helpers' | ||
export * from './hooks' | ||
export * from './types' |
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 @@ | ||
export * from './proofs' |
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,17 @@ | ||
export type Proof = { | ||
id: string | ||
type: 'proofs' | ||
creator: string | ||
created_at: string | ||
proof: string | ||
proof_type: string | ||
org_id: string | ||
schema_url: string | ||
} | ||
|
||
export type ProofLink = { | ||
id: string | ||
type: 'proofs' | ||
link: string | ||
created_at: string | ||
} |
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
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
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
29 changes: 29 additions & 0 deletions
29
src/pages/Orgs/pages/OrgsId/pages/OrgCheckProof/components/CheckProofHead.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,29 @@ | ||
import { Box, Stack, Typography, useTheme } from '@mui/material' | ||
import { generatePath, NavLink, useParams } from 'react-router-dom' | ||
|
||
import { RoutePaths } from '@/enums' | ||
import { UiIcon } from '@/ui' | ||
|
||
export default function CheckProofHead() { | ||
const { id = null } = useParams<{ id: string }>() | ||
const { palette, spacing } = useTheme() | ||
|
||
return ( | ||
<Box position={'relative'} mx={-8} px={6} pb={6} borderBottom={1} borderColor={palette.divider}> | ||
<Box position={'absolute'} top={spacing(2)} left={spacing(6)}> | ||
<NavLink to={generatePath(RoutePaths.OrgsId, { id })}> | ||
<Stack direction={'row'} alignItems={'center'} spacing={2} color={palette.text.secondary}> | ||
<UiIcon componentName={'chevronLeft'} size={5} /> | ||
<Typography variant='button' color={'inherit'}> | ||
View organization | ||
</Typography> | ||
</Stack> | ||
</NavLink> | ||
</Box> | ||
|
||
<Typography variant='h6' textAlign={'center'}> | ||
Check Proof | ||
</Typography> | ||
</Box> | ||
) | ||
} |
50 changes: 50 additions & 0 deletions
50
src/pages/Orgs/pages/OrgsId/pages/OrgCheckProof/components/OrgOverview.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,50 @@ | ||
import { Avatar, Box, Divider, Stack, Typography, useTheme } from '@mui/material' | ||
|
||
import { Organization, OrgsStatuses } from '@/api' | ||
import { UiIcon } from '@/ui' | ||
|
||
interface Props { | ||
org: Organization | ||
} | ||
|
||
export default function OrgOverview({ org }: Props) { | ||
const { palette, spacing } = useTheme() | ||
|
||
return ( | ||
<Stack alignItems={'center'}> | ||
<Avatar | ||
src={org.metadata.logoUrl} | ||
alt={org.metadata.name} | ||
sx={{ | ||
width: spacing(20), | ||
height: spacing(20), | ||
borderRadius: 250, | ||
objectFit: 'cover', | ||
}} | ||
/> | ||
|
||
<Stack direction={'row'} spacing={1} alignItems={'center'} mt={4}> | ||
<Typography variant={'h5'}>{org.metadata.name}</Typography> | ||
{org.status.value === OrgsStatuses.Verified && ( | ||
<UiIcon componentName={'verified'} size={5} sx={{ color: palette.success.main }} /> | ||
)} | ||
</Stack> | ||
|
||
<Typography mt={2} variant={'body2'}> | ||
{org.domain} | ||
</Typography> | ||
|
||
<Box mt={6} display={'grid'} gridTemplateColumns={'1fr 1px 1fr'} gap={6} textAlign={'center'}> | ||
<Box> | ||
<Typography variant={'h6'}>{org.members_count}</Typography> | ||
<Typography variant={'body2'}>Associated people</Typography> | ||
</Box> | ||
<Divider orientation={'vertical'} /> | ||
<Box> | ||
<Typography variant={'h6'}>{org.issued_claims_count}</Typography> | ||
<Typography variant={'body2'}>Credentials</Typography> | ||
</Box> | ||
</Box> | ||
</Stack> | ||
) | ||
} |
Oops, something went wrong.