Skip to content

Commit

Permalink
feat: Delet identity and conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Healy committed Jan 24, 2020
1 parent cc9332c commit 37ca91e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
6 changes: 6 additions & 0 deletions examples/react-graphql/client/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export const createIdentity = gql`
}
`

export const deleteIdentity = gql`
mutation deleteIdentity($type: String, $did: String) {
deleteIdentity(type: $type, did: $did)
}
`

export const actionSignVc = gql`
mutation actionSignVc($did: String!, $data: VerifiableCredentialInput!) {
actionSignVc(did: $did, data: $data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import React, { useContext } from 'react'
import { Box, Heading, Field, Input, Icon, Flash, Button } from 'rimble-ui'
import { Box, Heading, Field, Input, Icon, Flash, Button, Text } from 'rimble-ui'
import { useParams, useHistory } from 'react-router-dom'
import { AppContext } from '../../context/AppProvider'
import { useMutation } from '@apollo/react-hooks'
import * as queries from '../../queries'

const Component = () => {
let { id } = useParams()
let history = useHistory()
const [appState, setDefaultDid] = useContext(AppContext)
const { defaultDid } = appState
const [deleteIdentity] = useMutation(queries.deleteIdentity, {
refetchQueries: [{ query: queries.managedIdentities }],
})

const deleteId = (did: string | undefined) => {
deleteIdentity({
variables: {
type: 'ethr-did-fs',
did: did,
},
})
history.push('/identities')
}

return (
<Box width={450} bg="#1C1C1C" borderLeft={1} borderColor={'#4B4B4B'}>
Expand Down Expand Up @@ -35,9 +50,36 @@ const Component = () => {
{id}
</Box>
</Box>
<Button mt={3} mb={3} mr={3} onClick={() => setDefaultDid(id)} disabled={defaultDid === id}>
Set as default
</Button>
<Box flexDirection={'column'} display={'flex'}>
<Box mb={4}>
<Text>
{defaultDid === id
? 'This is your current default identity'
: 'Set this DID as the default identity'}
</Text>
<Button mt={3} mb={3} mr={3} onClick={() => setDefaultDid(id)} disabled={defaultDid === id}>
Set as default
</Button>
</Box>
<Box>
<Text>
{defaultDid === id
? 'You cannot delete your default identity. Set another identity as your default to delete this identity'
: 'Delete this identity. All data associated with it will be lost.'}
</Text>
<Text></Text>
<Button
variant="danger"
mt={3}
mb={3}
mr={3}
onClick={() => deleteId(id)}
disabled={defaultDid === id}
>
Delete DID
</Button>
</Box>
</Box>
</Box>
</Box>
)
Expand Down

0 comments on commit 37ca91e

Please sign in to comment.