diff --git a/examples/react-graphql/client/src/views/Activity/Activity.tsx b/examples/react-graphql/client/src/views/Activity/Activity.tsx index 45c652a40..0735e70b5 100644 --- a/examples/react-graphql/client/src/views/Activity/Activity.tsx +++ b/examples/react-graphql/client/src/views/Activity/Activity.tsx @@ -1,12 +1,69 @@ -import React from 'react' -import { Flex, Box, Text, Heading, Button, Icon, Table, Field, Input } from 'rimble-ui' +import React, { useContext } from 'react' +import { Flex, Box, Text, Heading, Button, Icon, Table, Field, Input, Card, Loader } from 'rimble-ui' import Panel from '../../components/Panel/Panel' import Page from '../../layout/Page' +import * as queries from '../../queries' +import { AppContext } from '../../context/AppProvider' +import { useQuery } from '@apollo/react-hooks' interface Activity {} const Activity: React.FC = () => { - return + const [appState] = useContext(AppContext) + + const { loading: messagesLoading, data: messagesData } = useQuery(queries.allMessages, { + variables: { activeDid: appState.defaultDid }, + }) + + console.log(messagesData) + + return ( + + + + + + + + + + + + + + + {messagesData?.identity?.messagesAll?.map((msg: any) => ( + + + + + + + + + ))} + +
SenderReceiverTimeTypeClaims
{msg.sender.shortId}{msg.receiver.shortId}{msg.timestamp}{msg.type} + {msg.vc?.map((vc: any) => + vc.fields.map((field: any) => ( +
+ {field.type} = {field.value} +
+ )), + )} +
+ { + // setQrValue(msg.raw) + // setIsQROpen(true) + }} + /> +
+
+
+ ) } export default Activity diff --git a/examples/react-graphql/client/src/views/Issue/Issue.tsx b/examples/react-graphql/client/src/views/Issue/Issue.tsx index 41f15c11d..fbb94debd 100644 --- a/examples/react-graphql/client/src/views/Issue/Issue.tsx +++ b/examples/react-graphql/client/src/views/Issue/Issue.tsx @@ -1,9 +1,136 @@ -import React from 'react' -import { Box, Heading } from 'rimble-ui' +import React, { useState, useContext } from 'react' +import { Box, Heading, Button, Field, Text, Form, Flex, Card, Input, Loader } from 'rimble-ui' import Page from '../../layout/Page' +import Panel from '../../components/Panel/Panel' +import { AppContext } from '../../context/AppProvider' +import { useQuery, useMutation } from '@apollo/react-hooks' +import * as queries from '../../queries' const Component = () => { - return + const [appState] = useContext(AppContext) + const [isSending, setIsSending] = useState(false) + const [receiver, setReceiver] = useState('did:web:uport.me') + const [claimType, setClaimType] = useState('name') + const [claimValue, setClaimValue] = useState('Alice') + + const [signVc] = useMutation(queries.actionSignVc) + const [sendJwt] = useMutation(queries.actionSendJwt, { + refetchQueries: [ + { + query: queries.allMessages, + variables: { activeDid: appState.defaultDid }, + }, + ], + }) + + const send = async () => { + setIsSending(true) + + try { + const credentialSubject: any = {} + credentialSubject[claimType] = claimValue + + const { data } = await signVc({ + variables: { + did: appState.defaultDid, + data: { + sub: receiver, + vc: { + context: ['https://www.w3.org/2018/credentials/v1'], + type: ['VerifiableCredential'], + credentialSubject, + }, + }, + }, + }) + + console.log(data) + + const { data: dataSend } = await sendJwt({ + variables: { + from: appState.defaultDid, + to: receiver, + jwt: data.actionSignVc, + }, + }) + + console.log(dataSend) + + // window.toastProvider.addMessage('Credential sent!', { variant: 'success' }) + } catch (e) { + // window.toastProvider.addMessage(e.message, { variant: 'failure' }) + } + + setIsSending(false) + } + + const handleSubmit = (e: any) => { + e.preventDefault() + send() + } + + return ( + + + +
+ + {appState.defaultDid} + + + + + + setReceiver(e.target.value)} + width={1} + /> + + + + + + + + setClaimType(e.target.value)} + width={1} + /> + + + + + setClaimValue(e.target.value)} + width={1} + /> + + + + + + {isSending ? : } + +
+
+
+
+ ) } export default Component