From fab06d209e0430869b725f58ff9b68cdaf6d826f Mon Sep 17 00:00:00 2001 From: Jason Healy Date: Tue, 28 Jan 2020 16:00:51 +0000 Subject: [PATCH] feat: Validation in SDR response --- examples/react-graphql/client/package.json | 2 ++ .../ActivityItem.css} | 0 .../ActivityItem.tsx} | 28 ++++++++++++++++--- .../client/src/components/Request/Request.tsx | 19 +++++++------ .../client/src/views/Activity/Activity.tsx | 13 +++++---- .../client/src/views/Request/Request.tsx | 2 +- examples/react-graphql/client/yarn.lock | 14 +++++++++- 7 files changed, 58 insertions(+), 20 deletions(-) rename examples/react-graphql/client/src/components/{MessageItem/MessageItem.css => ActivityItem/ActivityItem.css} (100%) rename examples/react-graphql/client/src/components/{MessageItem/MessageItem.tsx => ActivityItem/ActivityItem.tsx} (75%) diff --git a/examples/react-graphql/client/package.json b/examples/react-graphql/client/package.json index 303c006e9..e58b9a06c 100644 --- a/examples/react-graphql/client/package.json +++ b/examples/react-graphql/client/package.json @@ -9,6 +9,7 @@ "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "apollo-boost": "^0.4.7", + "date-fns": "^2.9.0", "graphql": "^14.5.8", "md5": "^2.2.1", "react": "^16.12.0", @@ -23,6 +24,7 @@ "sugar-inflections": "^2.0.6" }, "devDependencies": { + "@types/date-fns": "^2.6.0", "@types/jest": "^24.0.0", "@types/node": "^12.0.0", "@types/react": "^16.9.0", diff --git a/examples/react-graphql/client/src/components/MessageItem/MessageItem.css b/examples/react-graphql/client/src/components/ActivityItem/ActivityItem.css similarity index 100% rename from examples/react-graphql/client/src/components/MessageItem/MessageItem.css rename to examples/react-graphql/client/src/components/ActivityItem/ActivityItem.css diff --git a/examples/react-graphql/client/src/components/MessageItem/MessageItem.tsx b/examples/react-graphql/client/src/components/ActivityItem/ActivityItem.tsx similarity index 75% rename from examples/react-graphql/client/src/components/MessageItem/MessageItem.tsx rename to examples/react-graphql/client/src/components/ActivityItem/ActivityItem.tsx index a875ca2e5..691bdf911 100644 --- a/examples/react-graphql/client/src/components/MessageItem/MessageItem.tsx +++ b/examples/react-graphql/client/src/components/ActivityItem/ActivityItem.tsx @@ -1,19 +1,34 @@ import React from 'react' import { Box, Heading, Text, Icon, Avatar, Button } from 'rimble-ui' import * as Types from '../../types' +import { formatDistanceToNow } from 'date-fns' -import './MessageItem.css' +import './ActivityItem.css' interface Props { /** - * The activity that is takaing place + * The unique id or message hash + */ + id: string + + /** + * The message type + */ + type: 'w3c.vp' | 'w3c.vc' | 'sdr' | string + + /** + * The timestamp for when this message was recieved or sent + */ + date: number + /** + * The activity that is taking place */ activity?: string /** - * The type of message + * The viewer's did */ - type: string + viewerDid: Types.Identity /** * The issuer of this message item @@ -36,6 +51,7 @@ const Component: React.FC = ({ receiver, type, showRequest, + date, }) => { return ( @@ -58,6 +74,10 @@ const Component: React.FC = ({ )} + + + {formatDistanceToNow(date) + ' ago'} + {type == 'sdr' && ( + Later diff --git a/examples/react-graphql/client/src/views/Activity/Activity.tsx b/examples/react-graphql/client/src/views/Activity/Activity.tsx index 9912a0dc0..839758def 100644 --- a/examples/react-graphql/client/src/views/Activity/Activity.tsx +++ b/examples/react-graphql/client/src/views/Activity/Activity.tsx @@ -1,6 +1,6 @@ import React, { useContext, useState } from 'react' import { Flex } from 'rimble-ui' -import MessageItem from '../../components/MessageItem/MessageItem' +import ActivityItem from '../../components/ActivityItem/ActivityItem' import Page from '../../layout/Page' import Credential from '../../components/Credential/Credential' import * as queries from '../../gql/queries' @@ -12,19 +12,20 @@ interface Activity {} const Activity: React.FC = () => { const [appState] = useContext(AppContext) - const [isQROpen, setIsQROpen] = useState(false) - const [qrValue, setQrValue] = useState('') const history = useHistory() const { url } = useRouteMatch() - const { loading: messagesLoading, data: messagesData } = useQuery(queries.allMessages, { + const { data } = useQuery(queries.allMessages, { variables: { activeDid: appState.defaultDid }, }) return ( - {messagesData?.identity?.messagesAll?.map((msg: any) => ( - ( + { label="Required" my={2} checked={claimTypeRequired} - onClick={() => updateClaimTypeRequired(!claimTypeRequired)} + onChange={() => updateClaimTypeRequired(!claimTypeRequired)} /> diff --git a/examples/react-graphql/client/yarn.lock b/examples/react-graphql/client/yarn.lock index 1c5893daa..907190eda 100644 --- a/examples/react-graphql/client/yarn.lock +++ b/examples/react-graphql/client/yarn.lock @@ -1497,6 +1497,13 @@ dependencies: "@babel/types" "^7.3.0" +"@types/date-fns@^2.6.0": + version "2.6.0" + resolved "https://registry.npmjs.org/@types/date-fns/-/date-fns-2.6.0.tgz#b062ca46562002909be0c63a6467ed173136acc1" + integrity sha1-sGLKRlYgApCb4MY6ZGftFzE2rME= + dependencies: + date-fns "*" + "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" @@ -2075,7 +2082,7 @@ anymatch@^2.0.0: apollo-boost@^0.4.7: version "0.4.7" - resolved "https://registry.yarnpkg.com/apollo-boost/-/apollo-boost-0.4.7.tgz#b0680ab0893e3f8b1ab1058dcfa2b00cb6440d79" + resolved "https://registry.npmjs.org/apollo-boost/-/apollo-boost-0.4.7.tgz#b0680ab0893e3f8b1ab1058dcfa2b00cb6440d79" integrity sha512-jfc3aqO0vpCV+W662EOG5gq4AH94yIsvSgAUuDvS3o/Z+8Joqn4zGC9CgLCDHusK30mFgtsEgwEe0pZoedohsQ== dependencies: apollo-cache "^1.3.4" @@ -3720,6 +3727,11 @@ data-urls@^1.0.0, data-urls@^1.1.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" +date-fns@*, date-fns@^2.9.0: + version "2.9.0" + resolved "https://registry.npmjs.org/date-fns/-/date-fns-2.9.0.tgz#d0b175a5c37ed5f17b97e2272bbc1fa5aec677d2" + integrity sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA== + debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"