diff --git a/apps/console/src/hooks/graph/RightsRequestGraph.ts b/apps/console/src/hooks/graph/RightsRequestGraph.ts new file mode 100644 index 000000000..550fe50d0 --- /dev/null +++ b/apps/console/src/hooks/graph/RightsRequestGraph.ts @@ -0,0 +1,194 @@ +import { graphql } from "relay-runtime"; +import { useMutation } from "react-relay"; +import { useConfirm } from "@probo/ui"; +import { useTranslate } from "@probo/i18n"; +import { promisifyMutation, sprintf } from "@probo/helpers"; +import { useMutationWithToasts } from "../useMutationWithToasts"; + +export const RightsRequestsConnectionKey = "RightsRequestsPage_rightsRequests"; + +export const rightsRequestsQuery = graphql` + query RightsRequestGraphListQuery($organizationId: ID!) { + node(id: $organizationId) { + ... on Organization { + ...RightsRequestsPageFragment + } + } + } +`; + +export const rightsRequestNodeQuery = graphql` + query RightsRequestGraphNodeQuery($rightsRequestId: ID!) { + node(id: $rightsRequestId) { + ... on RightsRequest { + id + requestType + requestState + dataSubject + contact + details + deadline + actionTaken + organization { + id + name + } + createdAt + updatedAt + } + } + } +`; + +export const createRightsRequestMutation = graphql` + mutation RightsRequestGraphCreateMutation( + $input: CreateRightsRequestInput! + $connections: [ID!]! + ) { + createRightsRequest(input: $input) { + rightsRequestEdge @prependEdge(connections: $connections) { + node { + id + requestType + requestState + dataSubject + contact + details + deadline + actionTaken + createdAt + } + } + } + } +`; + +export const updateRightsRequestMutation = graphql` + mutation RightsRequestGraphUpdateMutation($input: UpdateRightsRequestInput!) { + updateRightsRequest(input: $input) { + rightsRequest { + id + requestType + requestState + dataSubject + contact + details + deadline + actionTaken + updatedAt + } + } + } +`; + +export const deleteRightsRequestMutation = graphql` + mutation RightsRequestGraphDeleteMutation( + $input: DeleteRightsRequestInput! + $connections: [ID!]! + ) { + deleteRightsRequest(input: $input) { + deletedRightsRequestId @deleteEdge(connections: $connections) + } + } +`; + +export const useDeleteRightsRequest = ( + request: { id: string }, + connectionId: string +) => { + const { __ } = useTranslate(); + const [mutate] = useMutationWithToasts(deleteRightsRequestMutation, { + successMessage: __("Rights request deleted successfully"), + errorMessage: __("Failed to delete rights request"), + }); + const confirm = useConfirm(); + + return () => { + confirm( + () => + mutate({ + variables: { + input: { + rightsRequestId: request.id, + }, + connections: [connectionId], + }, + }), + { + message: sprintf( + __( + "This will permanently delete the rights request. This action cannot be undone." + ) + ), + } + ); + }; +}; + +export const useCreateRightsRequest = (connectionId: string) => { + const [mutate] = useMutation(createRightsRequestMutation); + const { __ } = useTranslate(); + + return (input: { + organizationId: string; + requestType: string; + requestState: string; + dataSubject?: string; + contact?: string; + details?: string; + deadline?: string; + actionTaken?: string; + }) => { + if (!input.organizationId) { + return alert(__("Failed to create rights request: organization is required")); + } + if (!input.requestType) { + return alert(__("Failed to create rights request: request type is required")); + } + if (!input.requestState) { + return alert(__("Failed to create rights request: request state is required")); + } + + return promisifyMutation(mutate)({ + variables: { + input: { + organizationId: input.organizationId, + requestType: input.requestType, + requestState: input.requestState, + dataSubject: input.dataSubject, + contact: input.contact, + details: input.details, + deadline: input.deadline, + actionTaken: input.actionTaken, + }, + connections: [connectionId], + }, + }); + }; +}; + +export const useUpdateRightsRequest = () => { + const [mutate] = useMutation(updateRightsRequestMutation); + const { __ } = useTranslate(); + + return (input: { + id: string; + requestType?: string; + requestState?: string; + dataSubject?: string; + contact?: string; + details?: string; + deadline?: string | null; + actionTaken?: string; + }) => { + if (!input.id) { + return alert(__("Failed to update rights request: ID is required")); + } + + return promisifyMutation(mutate)({ + variables: { + input, + }, + }); + }; +}; diff --git a/apps/console/src/hooks/graph/__generated__/RightsRequestGraphCreateMutation.graphql.ts b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphCreateMutation.graphql.ts new file mode 100644 index 000000000..e985175fc --- /dev/null +++ b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphCreateMutation.graphql.ts @@ -0,0 +1,231 @@ +/** + * @generated SignedSource<<630d2ddf409889a6c1632063d18a2545>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type RightsRequestState = "DONE" | "IN_PROGRESS" | "TODO"; +export type RightsRequestType = "ACCESS" | "DELETION" | "PORTABILITY"; +export type CreateRightsRequestInput = { + actionTaken?: string | null | undefined; + contact?: string | null | undefined; + dataSubject?: string | null | undefined; + deadline?: any | null | undefined; + details?: string | null | undefined; + organizationId: string; + requestState: RightsRequestState; + requestType: RightsRequestType; +}; +export type RightsRequestGraphCreateMutation$variables = { + connections: ReadonlyArray; + input: CreateRightsRequestInput; +}; +export type RightsRequestGraphCreateMutation$data = { + readonly createRightsRequest: { + readonly rightsRequestEdge: { + readonly node: { + readonly actionTaken: string | null | undefined; + readonly contact: string | null | undefined; + readonly createdAt: any; + readonly dataSubject: string | null | undefined; + readonly deadline: any | null | undefined; + readonly details: string | null | undefined; + readonly id: string; + readonly requestState: RightsRequestState; + readonly requestType: RightsRequestType; + }; + }; + }; +}; +export type RightsRequestGraphCreateMutation = { + response: RightsRequestGraphCreateMutation$data; + variables: RightsRequestGraphCreateMutation$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = { + "defaultValue": null, + "kind": "LocalArgument", + "name": "connections" +}, +v1 = { + "defaultValue": null, + "kind": "LocalArgument", + "name": "input" +}, +v2 = [ + { + "kind": "Variable", + "name": "input", + "variableName": "input" + } +], +v3 = { + "alias": null, + "args": null, + "concreteType": "RightsRequestEdge", + "kind": "LinkedField", + "name": "rightsRequestEdge", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "RightsRequest", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestType", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestState", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "dataSubject", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "contact", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "details", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "deadline", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "actionTaken", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "createdAt", + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": [ + (v0/*: any*/), + (v1/*: any*/) + ], + "kind": "Fragment", + "metadata": null, + "name": "RightsRequestGraphCreateMutation", + "selections": [ + { + "alias": null, + "args": (v2/*: any*/), + "concreteType": "CreateRightsRequestPayload", + "kind": "LinkedField", + "name": "createRightsRequest", + "plural": false, + "selections": [ + (v3/*: any*/) + ], + "storageKey": null + } + ], + "type": "Mutation", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [ + (v1/*: any*/), + (v0/*: any*/) + ], + "kind": "Operation", + "name": "RightsRequestGraphCreateMutation", + "selections": [ + { + "alias": null, + "args": (v2/*: any*/), + "concreteType": "CreateRightsRequestPayload", + "kind": "LinkedField", + "name": "createRightsRequest", + "plural": false, + "selections": [ + (v3/*: any*/), + { + "alias": null, + "args": null, + "filters": null, + "handle": "prependEdge", + "key": "", + "kind": "LinkedHandle", + "name": "rightsRequestEdge", + "handleArgs": [ + { + "kind": "Variable", + "name": "connections", + "variableName": "connections" + } + ] + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "2642d9a5f58aa90190df6ccf73e6e06f", + "id": null, + "metadata": {}, + "name": "RightsRequestGraphCreateMutation", + "operationKind": "mutation", + "text": "mutation RightsRequestGraphCreateMutation(\n $input: CreateRightsRequestInput!\n) {\n createRightsRequest(input: $input) {\n rightsRequestEdge {\n node {\n id\n requestType\n requestState\n dataSubject\n contact\n details\n deadline\n actionTaken\n createdAt\n }\n }\n }\n}\n" + } +}; +})(); + +(node as any).hash = "98fa74d3219cf56655e74441af4dc01d"; + +export default node; diff --git a/apps/console/src/hooks/graph/__generated__/RightsRequestGraphDeleteMutation.graphql.ts b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphDeleteMutation.graphql.ts new file mode 100644 index 000000000..cd9c420da --- /dev/null +++ b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphDeleteMutation.graphql.ts @@ -0,0 +1,132 @@ +/** + * @generated SignedSource<<274e16758d468bf7fb911965acca3264>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type DeleteRightsRequestInput = { + rightsRequestId: string; +}; +export type RightsRequestGraphDeleteMutation$variables = { + connections: ReadonlyArray; + input: DeleteRightsRequestInput; +}; +export type RightsRequestGraphDeleteMutation$data = { + readonly deleteRightsRequest: { + readonly deletedRightsRequestId: string; + }; +}; +export type RightsRequestGraphDeleteMutation = { + response: RightsRequestGraphDeleteMutation$data; + variables: RightsRequestGraphDeleteMutation$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = { + "defaultValue": null, + "kind": "LocalArgument", + "name": "connections" +}, +v1 = { + "defaultValue": null, + "kind": "LocalArgument", + "name": "input" +}, +v2 = [ + { + "kind": "Variable", + "name": "input", + "variableName": "input" + } +], +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "deletedRightsRequestId", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": [ + (v0/*: any*/), + (v1/*: any*/) + ], + "kind": "Fragment", + "metadata": null, + "name": "RightsRequestGraphDeleteMutation", + "selections": [ + { + "alias": null, + "args": (v2/*: any*/), + "concreteType": "DeleteRightsRequestPayload", + "kind": "LinkedField", + "name": "deleteRightsRequest", + "plural": false, + "selections": [ + (v3/*: any*/) + ], + "storageKey": null + } + ], + "type": "Mutation", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [ + (v1/*: any*/), + (v0/*: any*/) + ], + "kind": "Operation", + "name": "RightsRequestGraphDeleteMutation", + "selections": [ + { + "alias": null, + "args": (v2/*: any*/), + "concreteType": "DeleteRightsRequestPayload", + "kind": "LinkedField", + "name": "deleteRightsRequest", + "plural": false, + "selections": [ + (v3/*: any*/), + { + "alias": null, + "args": null, + "filters": null, + "handle": "deleteEdge", + "key": "", + "kind": "ScalarHandle", + "name": "deletedRightsRequestId", + "handleArgs": [ + { + "kind": "Variable", + "name": "connections", + "variableName": "connections" + } + ] + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "c81b44380a4647a241c72fe1ca359246", + "id": null, + "metadata": {}, + "name": "RightsRequestGraphDeleteMutation", + "operationKind": "mutation", + "text": "mutation RightsRequestGraphDeleteMutation(\n $input: DeleteRightsRequestInput!\n) {\n deleteRightsRequest(input: $input) {\n deletedRightsRequestId\n }\n}\n" + } +}; +})(); + +(node as any).hash = "e657b62ad808fa4fd5902cf4eea4ca3b"; + +export default node; diff --git a/apps/console/src/hooks/graph/__generated__/RightsRequestGraphListQuery.graphql.ts b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphListQuery.graphql.ts new file mode 100644 index 000000000..26cd91c1c --- /dev/null +++ b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphListQuery.graphql.ts @@ -0,0 +1,295 @@ +/** + * @generated SignedSource<<22e08aea59fb3427d7770d89a44d6e9e>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type RightsRequestGraphListQuery$variables = { + organizationId: string; +}; +export type RightsRequestGraphListQuery$data = { + readonly node: { + readonly " $fragmentSpreads": FragmentRefs<"RightsRequestsPageFragment">; + }; +}; +export type RightsRequestGraphListQuery = { + response: RightsRequestGraphListQuery$data; + variables: RightsRequestGraphListQuery$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "organizationId" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "organizationId" + } +], +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}, +v4 = [ + { + "kind": "Literal", + "name": "first", + "value": 10 + } +]; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "RightsRequestGraphListQuery", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "kind": "InlineFragment", + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "RightsRequestsPageFragment" + } + ], + "type": "Organization", + "abstractKey": null + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "RightsRequestGraphListQuery", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + (v3/*: any*/), + { + "kind": "InlineFragment", + "selections": [ + { + "alias": null, + "args": (v4/*: any*/), + "concreteType": "RightsRequestConnection", + "kind": "LinkedField", + "name": "rightsRequests", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "RightsRequestEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "RightsRequest", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v3/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestType", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestState", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "dataSubject", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "contact", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "details", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "deadline", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "actionTaken", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "createdAt", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "updatedAt", + "storageKey": null + }, + (v2/*: any*/) + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + } + ], + "storageKey": "rightsRequests(first:10)" + }, + { + "alias": null, + "args": (v4/*: any*/), + "filters": null, + "handle": "connection", + "key": "RightsRequestsPage_rightsRequests", + "kind": "LinkedHandle", + "name": "rightsRequests" + } + ], + "type": "Organization", + "abstractKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "77f124136a2da2eb84fb134e5d10396b", + "id": null, + "metadata": {}, + "name": "RightsRequestGraphListQuery", + "operationKind": "query", + "text": "query RightsRequestGraphListQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...RightsRequestsPageFragment\n }\n id\n }\n}\n\nfragment RightsRequestsPageFragment on Organization {\n id\n rightsRequests(first: 10) {\n totalCount\n edges {\n node {\n id\n requestType\n requestState\n dataSubject\n contact\n details\n deadline\n actionTaken\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n" + } +}; +})(); + +(node as any).hash = "6ff83d9e0017a4fb245ad9f13106a439"; + +export default node; diff --git a/apps/console/src/hooks/graph/__generated__/RightsRequestGraphNodeQuery.graphql.ts b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphNodeQuery.graphql.ts new file mode 100644 index 000000000..43c98fced --- /dev/null +++ b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphNodeQuery.graphql.ts @@ -0,0 +1,241 @@ +/** + * @generated SignedSource<<7314c67aea13775f772b81880c524a60>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type RightsRequestState = "DONE" | "IN_PROGRESS" | "TODO"; +export type RightsRequestType = "ACCESS" | "DELETION" | "PORTABILITY"; +export type RightsRequestGraphNodeQuery$variables = { + rightsRequestId: string; +}; +export type RightsRequestGraphNodeQuery$data = { + readonly node: { + readonly actionTaken?: string | null | undefined; + readonly contact?: string | null | undefined; + readonly createdAt?: any; + readonly dataSubject?: string | null | undefined; + readonly deadline?: any | null | undefined; + readonly details?: string | null | undefined; + readonly id?: string; + readonly organization?: { + readonly id: string; + readonly name: string; + }; + readonly requestState?: RightsRequestState; + readonly requestType?: RightsRequestType; + readonly updatedAt?: any; + }; +}; +export type RightsRequestGraphNodeQuery = { + response: RightsRequestGraphNodeQuery$data; + variables: RightsRequestGraphNodeQuery$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "rightsRequestId" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "rightsRequestId" + } +], +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestType", + "storageKey": null +}, +v4 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestState", + "storageKey": null +}, +v5 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "dataSubject", + "storageKey": null +}, +v6 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "contact", + "storageKey": null +}, +v7 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "details", + "storageKey": null +}, +v8 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "deadline", + "storageKey": null +}, +v9 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "actionTaken", + "storageKey": null +}, +v10 = { + "alias": null, + "args": null, + "concreteType": "Organization", + "kind": "LinkedField", + "name": "organization", + "plural": false, + "selections": [ + (v2/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "name", + "storageKey": null + } + ], + "storageKey": null +}, +v11 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "createdAt", + "storageKey": null +}, +v12 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "updatedAt", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "RightsRequestGraphNodeQuery", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "kind": "InlineFragment", + "selections": [ + (v2/*: any*/), + (v3/*: any*/), + (v4/*: any*/), + (v5/*: any*/), + (v6/*: any*/), + (v7/*: any*/), + (v8/*: any*/), + (v9/*: any*/), + (v10/*: any*/), + (v11/*: any*/), + (v12/*: any*/) + ], + "type": "RightsRequest", + "abstractKey": null + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "RightsRequestGraphNodeQuery", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null + }, + (v2/*: any*/), + { + "kind": "InlineFragment", + "selections": [ + (v3/*: any*/), + (v4/*: any*/), + (v5/*: any*/), + (v6/*: any*/), + (v7/*: any*/), + (v8/*: any*/), + (v9/*: any*/), + (v10/*: any*/), + (v11/*: any*/), + (v12/*: any*/) + ], + "type": "RightsRequest", + "abstractKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "93aa5fb44159c0ae2709c34f493bc69f", + "id": null, + "metadata": {}, + "name": "RightsRequestGraphNodeQuery", + "operationKind": "query", + "text": "query RightsRequestGraphNodeQuery(\n $rightsRequestId: ID!\n) {\n node(id: $rightsRequestId) {\n __typename\n ... on RightsRequest {\n id\n requestType\n requestState\n dataSubject\n contact\n details\n deadline\n actionTaken\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n" + } +}; +})(); + +(node as any).hash = "9f7d09c59f937a8de6cfbc0354b42d1b"; + +export default node; diff --git a/apps/console/src/hooks/graph/__generated__/RightsRequestGraphUpdateMutation.graphql.ts b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphUpdateMutation.graphql.ts new file mode 100644 index 000000000..79da668c9 --- /dev/null +++ b/apps/console/src/hooks/graph/__generated__/RightsRequestGraphUpdateMutation.graphql.ts @@ -0,0 +1,178 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type RightsRequestState = "DONE" | "IN_PROGRESS" | "TODO"; +export type RightsRequestType = "ACCESS" | "DELETION" | "PORTABILITY"; +export type UpdateRightsRequestInput = { + actionTaken?: string | null | undefined; + contact?: string | null | undefined; + dataSubject?: string | null | undefined; + deadline?: any | null | undefined; + details?: string | null | undefined; + id: string; + requestState?: RightsRequestState | null | undefined; + requestType?: RightsRequestType | null | undefined; +}; +export type RightsRequestGraphUpdateMutation$variables = { + input: UpdateRightsRequestInput; +}; +export type RightsRequestGraphUpdateMutation$data = { + readonly updateRightsRequest: { + readonly rightsRequest: { + readonly actionTaken: string | null | undefined; + readonly contact: string | null | undefined; + readonly dataSubject: string | null | undefined; + readonly deadline: any | null | undefined; + readonly details: string | null | undefined; + readonly id: string; + readonly requestState: RightsRequestState; + readonly requestType: RightsRequestType; + readonly updatedAt: any; + }; + }; +}; +export type RightsRequestGraphUpdateMutation = { + response: RightsRequestGraphUpdateMutation$data; + variables: RightsRequestGraphUpdateMutation$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "input" + } +], +v1 = [ + { + "alias": null, + "args": [ + { + "kind": "Variable", + "name": "input", + "variableName": "input" + } + ], + "concreteType": "UpdateRightsRequestPayload", + "kind": "LinkedField", + "name": "updateRightsRequest", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "RightsRequest", + "kind": "LinkedField", + "name": "rightsRequest", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestType", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "requestState", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "dataSubject", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "contact", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "details", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "deadline", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "actionTaken", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "updatedAt", + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null + } +]; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "RightsRequestGraphUpdateMutation", + "selections": (v1/*: any*/), + "type": "Mutation", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "RightsRequestGraphUpdateMutation", + "selections": (v1/*: any*/) + }, + "params": { + "cacheID": "4b06cb49236bb946cfa333e95b80f2a8", + "id": null, + "metadata": {}, + "name": "RightsRequestGraphUpdateMutation", + "operationKind": "mutation", + "text": "mutation RightsRequestGraphUpdateMutation(\n $input: UpdateRightsRequestInput!\n) {\n updateRightsRequest(input: $input) {\n rightsRequest {\n id\n requestType\n requestState\n dataSubject\n contact\n details\n deadline\n actionTaken\n updatedAt\n }\n }\n}\n" + } +}; +})(); + +(node as any).hash = "f2f42ebc57de95ec4a760e7d701f90fa"; + +export default node; diff --git a/apps/console/src/layouts/MainLayout.tsx b/apps/console/src/layouts/MainLayout.tsx index 072331665..ef03d61e1 100644 --- a/apps/console/src/layouts/MainLayout.tsx +++ b/apps/console/src/layouts/MainLayout.tsx @@ -224,6 +224,13 @@ function MainLayoutContent({ to={`${prefix}/processing-activities`} /> )} + {isAuthorized("Organization", "listRightsRequests") && ( + + )} {isAuthorized("Organization", "listSnapshots") && ( ; +}; + +export default function RightsRequestDetailsPage(props: Props) { + const data = usePreloadedQuery(rightsRequestNodeQuery, props.queryRef); + const request = data.node; + const { __ } = useTranslate(); + const { toast } = useToast(); + const organizationId = useOrganizationId(); + const { isAuthorized } = use(PermissionsContext); + + const updateRequest = useUpdateRightsRequest(); + + const connectionId = ConnectionHandler.getConnectionID( + organizationId, + RightsRequestsConnectionKey + ); + + const deleteRequest = useDeleteRightsRequest({ id: request.id! }, connectionId); + + const { register, handleSubmit, formState, control } = useFormWithSchema( + updateRequestSchema, + { + defaultValues: { + requestType: request.requestType || "ACCESS", + requestState: request.requestState || "TODO", + dataSubject: request.dataSubject || "", + contact: request.contact || "", + details: request.details || "", + deadline: toDateInput(request.deadline), + actionTaken: request.actionTaken || "", + }, + } + ); + + const onSubmit = handleSubmit(async (formData) => { + try { + await updateRequest({ + id: request.id!, + requestType: formData.requestType, + requestState: formData.requestState, + dataSubject: formData.dataSubject || undefined, + contact: formData.contact || undefined, + details: formData.details || undefined, + deadline: formatDatetime(formData.deadline) ?? null, + actionTaken: formData.actionTaken || undefined, + }); + + toast({ + title: __("Success"), + description: __("Rights request updated successfully"), + variant: "success", + }); + } catch (error) { + toast({ + title: __("Error"), + description: formatError(__("Failed to update rights request"), error as GraphQLError), + variant: "error", + }); + } + }); + + const typeOptions = getRightsRequestTypeOptions(__); + const stateOptions = getRightsRequestStateOptions(__); + + const breadcrumbRequestsUrl = `/organizations/${organizationId}/rights-requests`; + + return ( +
+
+ + {isAuthorized("RightsRequest", "deleteRightsRequest") && ( + + + {__("Delete")} + + + )} +
+ + +
+
+
+

{getRightsRequestTypeLabel(__, request.requestType || "ACCESS")}

+ {getRightsRequestTypeLabel(__, request.requestType || "ACCESS")} + + {getRightsRequestStateLabel(__, request.requestState || "TODO")} + +
+
+ +
+
+ ( +
+ + + {formState.errors.requestType?.message && ( +
+ {formState.errors.requestType.message} +
+ )} +
+ )} + /> + + ( +
+ + + {formState.errors.requestState?.message && ( +
+ {formState.errors.requestState.message} +
+ )} +
+ )} + /> +
+ + + + + +
+ +