From 37ca91e223f25ef1ca14cea8cc61531643571650 Mon Sep 17 00:00:00 2001 From: Jason Healy Date: Thu, 23 Jan 2020 14:26:29 +0000 Subject: [PATCH] feat: Delet identity and conditions --- examples/react-graphql/client/src/queries.ts | 6 +++ .../src/views/Identity/IdentityDetail.tsx | 50 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/examples/react-graphql/client/src/queries.ts b/examples/react-graphql/client/src/queries.ts index 971fc1308..2d0d439f5 100644 --- a/examples/react-graphql/client/src/queries.ts +++ b/examples/react-graphql/client/src/queries.ts @@ -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) diff --git a/examples/react-graphql/client/src/views/Identity/IdentityDetail.tsx b/examples/react-graphql/client/src/views/Identity/IdentityDetail.tsx index a17b0d9ef..1c1e1bfb0 100644 --- a/examples/react-graphql/client/src/views/Identity/IdentityDetail.tsx +++ b/examples/react-graphql/client/src/views/Identity/IdentityDetail.tsx @@ -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 ( @@ -35,9 +50,36 @@ const Component = () => { {id} - + + + + {defaultDid === id + ? 'This is your current default identity' + : 'Set this DID as the default identity'} + + + + + + {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.'} + + + + + )