Skip to content

Commit

Permalink
refactor: List credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Healy committed May 20, 2020
1 parent a39f956 commit 50579e0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'
import * as Types from '../../types'
import Credential from './Credential'
import { Box, Heading, Text } from 'rimble-ui'
import './Credential.css'
import * as queries from '../../gql/queries'
import { useQuery } from 'react-apollo'
import { useParams } from 'react-router-dom'

const S = require('sugar/string')

interface Props {}

const Component: React.FC<Props> = ({}) => {
const { id } = useParams()
const { data } = useQuery(queries.credentials, { variables: { id } })

return (
<Box>
<Heading as={'h3'} mt={2} mb={3}>
Credentials
</Heading>
{data &&
data.credentials &&
data.credentials.map((credential: any) => {
return (
<Credential
key={credential.hash}
issuer={credential.issuer}
subject={credential.subject}
claims={credential.claims}
jwt={credential.jwt}
/>
)
})}
</Box>
)
}

export default Component
24 changes: 11 additions & 13 deletions examples/react-graphql/client/src/gql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@ export const credential = gql`
`

export const credentials = gql`
query credentials($subject: String!) {
credentials(input: { where: [{ column: subject, value: $subject }] }) {
query credentials($id: String!) {
credentials(input: { where: [{ column: subject, value: [$id] }] }) {
hash
issuanceDate
expirationDate
claims {
type
value
isObj
}
issuer {
subject {
did
shortId: shortDid
profileImage: latestClaimValue(type: "profileImage")
}
subject {
issuer {
did
shortId: shortDid
profileImage: latestClaimValue(type: "profileImage")
}
issuanceDate
type
claims {
hash
type
value
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions examples/react-graphql/client/src/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SidePanel from './SidePanel'
import NavigationLeft from './NavigationLeft'

import Credential from '../components/Credential/Credential'
import CredentialList from '../components/Credential/CredentialList'
import RequestDetail from '../components/Request/Request'
import Settings from '../views/Settings/Settings'

Expand Down Expand Up @@ -76,6 +77,7 @@ const Dashboard: React.FC<DashboardProps> = () => {
<Route path="/identities/user/:id">
<SidePanel title={'Identity'} closeUrl={'/identities'}>
<IdentityDetail />
<CredentialList />
</SidePanel>
</Route>
<Route
Expand Down

0 comments on commit 50579e0

Please sign in to comment.