Add risk forms

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Jonathan
2025-05-22 12:40:12 +02:00
committed by Sacha Al Himdani
parent 3d4ecf5f8f
commit fc45d2f00d
41 changed files with 2426 additions and 136 deletions

View File

@@ -1,4 +1,4 @@
import type { ComponentProps, JSXElementConstructor } from "react";
import type { ComponentProps, JSX, JSXElementConstructor } from "react";
import { Field } from "@probo/ui";
import { Controller, type Control } from "react-hook-form";
import { Select } from "@probo/ui";

View File

@@ -2,15 +2,15 @@ import { Avatar, Option, Select } from "@probo/ui";
import { Suspense } from "react";
import { useLazyLoadQuery } from "react-relay";
import { graphql } from "relay-runtime";
import type { UserSelectQuery as UserSelectQueryType } from "./__generated__/UserSelectQuery.graphql";
import type { PeopleSelectQuery as PeopleSelectQueryType } from "./__generated__/PeopleSelectQuery.graphql";
import { useTranslate } from "@probo/i18n";
import { Controller, type Control } from "react-hook-form";
const usersQuery = graphql`
query UserSelectQuery($organizationId: ID!) {
const peopleQuery = graphql`
query PeopleSelectQuery($organizationId: ID!) {
organization: node(id: $organizationId) {
... on Organization {
users(first: 100, orderBy: { direction: ASC, field: CREATED_AT }) {
peoples(first: 100, orderBy: { direction: ASC, field: CREATED_AT }) {
edges {
node {
id
@@ -23,7 +23,7 @@ const usersQuery = graphql`
}
`;
export function UserSelect({
export function PeopleSelect({
organization,
name,
control,
@@ -36,7 +36,7 @@ export function UserSelect({
<Suspense
fallback={<Select variant="editor" disabled placeholder="Loading..." />}
>
<UserSelectWithQuery
<PeopleSelectWithQuery
organization={organization}
name={name}
control={control}
@@ -45,7 +45,7 @@ export function UserSelect({
);
}
function UserSelectWithQuery({
function PeopleSelectWithQuery({
organization,
name,
control,
@@ -55,31 +55,33 @@ function UserSelectWithQuery({
control: Control;
}) {
const { __ } = useTranslate();
const data = useLazyLoadQuery<UserSelectQueryType>(usersQuery, {
const data = useLazyLoadQuery<PeopleSelectQueryType>(peopleQuery, {
organizationId: organization,
});
const users = data.organization?.users?.edges.map((edge) => edge.node);
const people = data.organization?.peoples?.edges.map((edge) => edge.node);
return (
<Controller
control={control}
name={name}
render={({ field }) => (
<Select
id={name}
variant="editor"
placeholder={__("Select an user")}
{...field}
>
{users?.map((user) => (
<Option key={user.id} value={user.id}>
<Avatar name={user.fullName} />
{user.fullName}
</Option>
))}
</Select>
)}
/>
<>
<Controller
control={control}
name={name}
render={({ field }) => (
<Select
id={name}
variant="editor"
placeholder={__("Select an owner")}
{...field}
>
{people?.map((p) => (
<Option key={p.id} value={p.id}>
<Avatar name={p.fullName} />
{p.fullName}
</Option>
))}
</Select>
)}
/>
</>
);
}

View File

@@ -0,0 +1,180 @@
/**
* @generated SignedSource<<758e3ece2d7d1d52975886d41b6ae905>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type PeopleSelectQuery$variables = {
organizationId: string;
};
export type PeopleSelectQuery$data = {
readonly organization: {
readonly peoples?: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly fullName: string;
readonly id: string;
};
}>;
};
};
};
export type PeopleSelectQuery = {
response: PeopleSelectQuery$data;
variables: PeopleSelectQuery$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": "id",
"storageKey": null
},
v3 = {
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "first",
"value": 100
},
{
"kind": "Literal",
"name": "orderBy",
"value": {
"direction": "ASC",
"field": "CREATED_AT"
}
}
],
"concreteType": "PeopleConnection",
"kind": "LinkedField",
"name": "peoples",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "PeopleEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": "peoples(first:100,orderBy:{\"direction\":\"ASC\",\"field\":\"CREATED_AT\"})"
}
],
"type": "Organization",
"abstractKey": null
};
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "PeopleSelectQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "PeopleSelectQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
(v3/*: any*/),
(v2/*: any*/)
],
"storageKey": null
}
]
},
"params": {
"cacheID": "4e58fc42b352af93ba7067921531af3e",
"id": null,
"metadata": {},
"name": "PeopleSelectQuery",
"operationKind": "query",
"text": "query PeopleSelectQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n peoples(first: 100, orderBy: {direction: ASC, field: CREATED_AT}) {\n edges {\n node {\n id\n fullName\n }\n }\n }\n }\n id\n }\n}\n"
}
};
})();
(node as any).hash = "77119544e99cf9dd74d8a0f446df108e";
export default node;

View File

@@ -0,0 +1,57 @@
import { useCallback } from "react";
import { useMutation, type UseMutationConfig } from "react-relay";
import { useToast } from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import type { MutationParameters, GraphQLTaggedNode } from "relay-runtime";
/**
* A decorated useMutation hook that emits toast notifications on success or error.
*/
export function useMutationWithToasts<T extends MutationParameters>(
query: GraphQLTaggedNode
) {
const [mutate, isLoading] = useMutation<T>(query);
const { toast } = useToast();
const { __ } = useTranslate();
const mutateWithToast = useCallback(
(
options: UseMutationConfig<T> & {
onSuccess?: () => void;
successMessage: string;
errorMessage?: string;
}
) => {
mutate({
...options,
onCompleted: (_, error) => {
if (error) {
toast({
title: __("Error"),
description:
options.errorMessage ?? __("Failed to commit this operation."),
variant: "error",
});
return;
}
toast({
title: __("Success"),
description: options.successMessage,
variant: "success",
});
options.onSuccess?.();
},
onError: () => {
toast({
title: __("Error"),
description:
options.errorMessage ?? __("Failed to commit this operation."),
variant: "error",
});
},
});
},
[mutate]
);
return [mutateWithToast, isLoading] as const;
}

View File

@@ -37,7 +37,7 @@ export default function OrganizationsPage() {
// Redirect to the first organization if only one exists
useEffect(() => {
if (organizations.length === 1) {
// navigate(`/organizations/${organizations[0].id}`);
navigate(`/organizations/${organizations[0].id}`);
}
}, [organizations]);

View File

@@ -1,5 +1,5 @@
import { useTranslate } from "@probo/i18n";
import { Button, Input, useToast } from "@probo/ui";
import { Button, Field, useToast } from "@probo/ui";
import type { FormEventHandler } from "react";
import { Link, useNavigate } from "react-router";
@@ -46,14 +46,14 @@ export default function LoginPage() {
<p className="text-center text-txt-tertiary mt-1 mb-6">
{__("Enter your email below to login to your account")}
</p>
<Input
<Field
required
placeholder={__("Email")}
name="email"
type="email"
label={__("Email")}
/>
<Input
<Field
required
placeholder={__("Password")}
name="password"

View File

@@ -1,4 +1,4 @@
import { Button, Card, Input, PageHeader, useToast } from "@probo/ui";
import { Button, Card, Field, PageHeader, useToast } from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import { ConnectionHandler, graphql } from "relay-runtime";
import { useLazyLoadQuery, useMutation } from "react-relay";
@@ -98,7 +98,7 @@ export default function NewOrganizationPage() {
<p className="text-txt-tertiary text-sm mb-4">
{__("Enter the basic information about your organization.")}
</p>
<Input
<Field
required
name="name"
type="text"

View File

@@ -13,106 +13,135 @@ import {
PropertyRow,
IconPlusLarge,
Textarea,
useToast,
} from "@probo/ui";
import { useMemo, useState, type ReactNode } from "react";
import { useFetchQuery } from "../../../hooks/useFetchQuery";
import { graphql } from "relay-runtime";
import { UserSelect } from "../../../components/form/UserSelect";
import { ConnectionHandler, graphql } from "relay-runtime";
import { PeopleSelect } from "../../../components/form/PeopleSelect";
import { useOrganizationId } from "../../../hooks/useOrganizationId";
import { useToggle } from "@probo/hooks";
import {
ControlledField,
ControlledSelect,
} from "../../../components/form/ControlledField";
import { useRiskForm, type RiskForm } from "./forms/useRiskForm";
import { useMutation } from "react-relay";
import { useRiskForm, type RiskForm, type RiskKey } from "./forms/useRiskForm";
import type { FieldErrors } from "react-hook-form";
import { useMutationWithToasts } from "../../../hooks/useMutationWithToasts";
import type { FormRiskDialogMutation } from "./__generated__/FormRiskDialogMutation.graphql";
import type { FormRiskDialogUpdateRiskMutation } from "./__generated__/FormRiskDialogUpdateRiskMutation.graphql";
type Props = {
trigger: ReactNode;
trigger?: ReactNode;
open?: boolean;
risk?: RiskKey;
onSuccess?: () => void;
};
type Risk = {
type RiskTemplate = {
category: string;
name: string;
description: string;
};
const createRiskMutation = graphql`
mutation NewRiskDialogMutation(
mutation FormRiskDialogMutation(
$input: CreateRiskInput!
$connections: [ID!]!
) {
createRisk(input: $input) {
riskEdge @prependEdge(connections: $connections) {
node {
id
name
description
category
inherentLikelihood
inherentImpact
residualLikelihood
residualImpact
treatment
createdAt
updatedAt
...useRiskFormFragment
}
}
}
}
`;
export default function NewRiskDialog({ trigger }: Props) {
const updateRiskMutation = graphql`
mutation FormRiskDialogUpdateRiskMutation($input: UpdateRiskInput!) {
updateRisk(input: $input) {
risk {
...useRiskFormFragment
}
}
}
`;
/**
* Dialog to create or update a risk
*/
export default function FormRiskDialog({ trigger, risk, onSuccess }: Props) {
const { __ } = useTranslate();
const organizationId = useOrganizationId();
const { control, handleSubmit, setValue, register, watch, formState } =
useRiskForm(organizationId);
const { control, handleSubmit, setValue, register, watch, formState, reset } =
useRiskForm(risk);
const errors = formState.errors ?? {};
const [createRisk, isLoading] = useMutation(createRiskMutation);
const { toast } = useToast();
const [createRisk, isLoadingCreate] =
useMutationWithToasts<FormRiskDialogMutation>(createRiskMutation);
const [updateRisk, isLoadingUpdate] =
useMutationWithToasts<FormRiskDialogUpdateRiskMutation>(updateRiskMutation);
const isLoading = isLoadingCreate || isLoadingUpdate;
const onTemplateChange = (risk: Risk) => {
const onTemplateChange = (risk: RiskTemplate) => {
setValue("name", risk.name);
setValue("description", risk.description);
};
const onSubmit = handleSubmit((data) => {
if (risk) {
updateRisk({
variables: {
input: {
id: risk.id,
...data,
},
},
successMessage: __("Risk updated successfully."),
errorMessage: __("Failed to update risk. Please try again."),
onSuccess: () => {
setOpen(false);
onSuccess?.();
},
});
return;
}
const connectionID = ConnectionHandler.getConnectionID(
organizationId,
"RisksPage_risks"
);
createRisk({
variables: {
input: data,
input: {
...data,
organizationId,
},
connections: [connectionID],
},
onCompleted: (response, error) => {
if (error) {
toast({
title: __("Error"),
description: __("Failed to create risk. Please try again."),
variant: "error",
});
return;
}
toast({
title: __("Success"),
description: __("Risk created successfully."),
variant: "success",
});
successMessage: __("Risk created successfully."),
errorMessage: __("Failed to create risk. Please try again."),
onSuccess: () => {
setOpen(false);
reset();
onSuccess?.();
},
});
});
const [showNote, toggleNote] = useToggle(false);
const [open, setOpen] = useState(false);
const [open, setOpen] = useState(!!risk);
return (
<Dialog
open={open}
onOpenChange={setOpen}
trigger={trigger}
title={<Breadcrumb items={[__("Risks"), __("New Risk")]}></Breadcrumb>}
title={
<Breadcrumb
items={[__("Risks"), risk ? __("Edit Risk") : __("New Risk")]}
/>
}
>
<form onSubmit={onSubmit}>
<DialogContent className="grid grid-cols-[1fr_420px]">
@@ -124,6 +153,7 @@ export default function NewRiskDialog({ trigger }: Props) {
watch={watch}
/>
<Field
type="text"
{...register("name")}
error={errors.name?.message}
label={__("Risk name")}
@@ -162,7 +192,7 @@ export default function NewRiskDialog({ trigger }: Props) {
label={__("Owner")}
error={errors.ownerId?.message}
>
<UserSelect
<PeopleSelect
name="ownerId"
control={control}
organization={organizationId}
@@ -209,7 +239,7 @@ export default function NewRiskDialog({ trigger }: Props) {
</DialogContent>
<DialogFooter>
<Button type="submit" disabled={isLoading}>
{__("Create risk")}
{risk ? __("Update risk") : __("Create risk")}
</Button>
</DialogFooter>
</form>
@@ -224,9 +254,14 @@ function ImpactAndLikelihood({
errors,
}: {
label: string;
prefix: string;
prefix: "inherent" | "residual";
control: RiskForm["control"];
errors: Record<string, { message: string }>;
errors: FieldErrors<{
inherentImpact: string;
inherentLikelihood: string;
residualImpact: string;
residualLikelihood: string;
}>;
}) {
const { __ } = useTranslate();
return (
@@ -271,14 +306,17 @@ function TemplateSelector({
control,
watch,
}: {
onChange: (risk: Risk) => void;
onChange: (risk: RiskTemplate) => void;
control: RiskForm["control"];
watch: RiskForm["watch"];
}) {
const { __ } = useTranslate();
const { data: risks } = useFetchQuery<Risk[]>("/data/risks/risks.json", {
staleTime: 100_000,
});
const { data: risks } = useFetchQuery<RiskTemplate[]>(
"/data/risks/risks.json",
{
staleTime: 100_000,
}
);
const categories = useMemo(
() => Array.from(new Set(risks?.map((t) => t.category))),

View File

@@ -1,17 +1,193 @@
import { Button, PageHeader } from "@probo/ui";
import {
Button,
PageHeader,
Td,
Tr,
Th,
Thead,
Tbody,
Table,
RiskBadge,
SeverityBadge,
ActionDropdown,
DropdownItem,
IconTrashCan,
IconPencil,
ConfirmDialog,
} from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import { IconPlusLarge } from "@probo/ui";
import NewRiskDialog from "./NewRiskDialog";
import FormRiskDialog from "./FormRiskDialog";
import { ConnectionHandler, graphql } from "relay-runtime";
import { useLazyLoadQuery } from "react-relay";
import type {
RisksPageQuery as RisksPageQueryType,
RiskTreatment,
} from "./__generated__/RisksPageQuery.graphql";
import { useOrganizationId } from "../../../hooks/useOrganizationId";
import { useMemo, useState } from "react";
import { usePageTitle } from "@probo/hooks";
import type { RisksPageDeleteMutation } from "./__generated__/RisksPageDeleteMutation.graphql";
import { useMutationWithToasts } from "../../../hooks/useMutationWithToasts";
import { sprintf } from "@probo/helpers";
import type { ItemOf } from "../../../types";
const risksQuery = graphql`
query RisksPageQuery(
$organizationId: ID!
$first: Int
$after: CursorKey
$last: Int
$before: CursorKey
) {
organization: node(id: $organizationId) {
... on Organization {
risks(first: $first, after: $after, last: $last, before: $before)
@connection(key: "RisksPage_risks") {
edges {
node {
id
name
category
treatment
inherentLikelihood
inherentImpact
residualLikelihood
residualImpact
inherentSeverity
...useRiskFormFragment
}
}
}
}
}
}
`;
const deleteRiskMutation = graphql`
mutation RisksPageDeleteMutation(
$input: DeleteRiskInput!
$connections: [ID!]!
) {
deleteRisk(input: $input) {
deletedRiskId @deleteEdge(connections: $connections)
}
}
`;
export default function RisksPage() {
const { __ } = useTranslate();
const data = useLazyLoadQuery<RisksPageQueryType>(risksQuery, {
organizationId: useOrganizationId(),
});
const risks = data.organization?.risks?.edges.map((edge) => edge.node);
const [editedRisk, setEditedRisk] = useState<ItemOf<typeof risks> | null>(
null
);
const treatmentLabels = useMemo(() => {
return {
MITIGATED: __("Mitigate"),
ACCEPTED: __("Accept"),
TRANSFERRED: __("Transfer"),
AVOIDED: __("Avoid"),
} as Record<RiskTreatment, string>;
}, [__]);
const organizationId = useOrganizationId();
const [deleteRisk] =
useMutationWithToasts<RisksPageDeleteMutation>(deleteRiskMutation);
const onDelete = (riskId: string) => {
const connectionId = ConnectionHandler.getConnectionID(
organizationId,
"RisksPage_risks"
);
deleteRisk({
variables: {
input: { riskId },
connections: [connectionId],
},
successMessage: __("Risk deleted successfully."),
errorMessage: __("Failed to delete risk. Please try again."),
});
};
usePageTitle(__("Risks"));
return (
<div className="space-y-6">
<PageHeader title={__("Risks")}>
<NewRiskDialog
<FormRiskDialog
trigger={<Button icon={IconPlusLarge}>{__("New Risk")}</Button>}
/>
</PageHeader>
{editedRisk && (
<FormRiskDialog
risk={editedRisk}
onSuccess={() => setEditedRisk(null)}
/>
)}
<Table>
<Thead>
<Tr>
<Th>{__("Risk name")}</Th>
<Th>{__("Category")}</Th>
<Th>{__("Treatment")}</Th>
<Th>{__("Initial Risk")}</Th>
<Th>{__("Residual Risk")}</Th>
<Th>{__("Severity")}</Th>
<Th></Th>
</Tr>
</Thead>
<Tbody>
{risks?.map((risk) => (
<Tr
key={risk.id}
to={`/organizations/${organizationId}/risks/${risk.id}`}
>
<Td>{risk.name}</Td>
<Td>{risk.category}</Td>
<Td>{treatmentLabels[risk.treatment]}</Td>
<Td>
<RiskBadge
score={risk.inherentLikelihood * risk.inherentImpact}
/>
</Td>
<Td>
<RiskBadge
score={risk.residualLikelihood * risk.residualImpact}
/>
</Td>
<Td>
<SeverityBadge severity={risk.inherentSeverity} />
</Td>
<Td noLink>
<ActionDropdown>
<DropdownItem
icon={IconPencil}
onClick={() => setEditedRisk(risk)}
>
{__("Edit")}
</DropdownItem>
<ConfirmDialog
message={sprintf(
__(
'This will permanently delete the risk "%s". This action cannot be undone.'
),
risk.name
)}
onConfirm={() => onDelete(risk.id)}
>
<DropdownItem variant="danger" icon={IconTrashCan}>
{__("Delete")}
</DropdownItem>
</ConfirmDialog>
</ActionDropdown>
</Td>
</Tr>
))}
</Tbody>
</Table>
</div>
);
}

View File

@@ -0,0 +1,271 @@
/**
* @generated SignedSource<<05dd3d535fb39d12fc0c015864a85d31>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type RiskTreatment = "ACCEPTED" | "AVOIDED" | "MITIGATED" | "TRANSFERRED" | "%future added value";
export type CreateRiskInput = {
category: string;
description: string;
inherentImpact: number;
inherentLikelihood: number;
name: string;
note?: string | null | undefined;
organizationId: string;
ownerId?: string | null | undefined;
residualImpact?: number | null | undefined;
residualLikelihood?: number | null | undefined;
treatment: RiskTreatment;
};
export type FormRiskDialogMutation$variables = {
connections: ReadonlyArray<string>;
input: CreateRiskInput;
};
export type FormRiskDialogMutation$data = {
readonly createRisk: {
readonly riskEdge: {
readonly node: {
readonly " $fragmentSpreads": FragmentRefs<"useRiskFormFragment">;
};
};
};
};
export type FormRiskDialogMutation = {
response: FormRiskDialogMutation$data;
variables: FormRiskDialogMutation$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": "id",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "FormRiskDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateRiskPayload",
"kind": "LinkedField",
"name": "createRisk",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "RiskEdge",
"kind": "LinkedField",
"name": "riskEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "useRiskFormFragment"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "FormRiskDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateRiskPayload",
"kind": "LinkedField",
"name": "createRisk",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "RiskEdge",
"kind": "LinkedField",
"name": "riskEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "category",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "treatment",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"key": "",
"kind": "LinkedHandle",
"name": "riskEdge",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "e2131409b62d6cd6bd8a6d008f2ac1f5",
"id": null,
"metadata": {},
"name": "FormRiskDialogMutation",
"operationKind": "mutation",
"text": "mutation FormRiskDialogMutation(\n $input: CreateRiskInput!\n) {\n createRisk(input: $input) {\n riskEdge {\n node {\n ...useRiskFormFragment\n id\n }\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n note\n owner {\n id\n }\n}\n"
}
};
})();
(node as any).hash = "0429ad2b3af194de47f4b5af4231e22b";
export default node;

View File

@@ -0,0 +1,221 @@
/**
* @generated SignedSource<<71792ccd18aa886a5df0ecfa8a23fda9>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type RiskTreatment = "ACCEPTED" | "AVOIDED" | "MITIGATED" | "TRANSFERRED" | "%future added value";
export type UpdateRiskInput = {
category?: string | null | undefined;
description?: string | null | undefined;
id: string;
inherentImpact?: number | null | undefined;
inherentLikelihood?: number | null | undefined;
name?: string | null | undefined;
note?: string | null | undefined;
ownerId?: string | null | undefined;
residualImpact?: number | null | undefined;
residualLikelihood?: number | null | undefined;
treatment?: RiskTreatment | null | undefined;
};
export type FormRiskDialogUpdateRiskMutation$variables = {
input: UpdateRiskInput;
};
export type FormRiskDialogUpdateRiskMutation$data = {
readonly updateRisk: {
readonly risk: {
readonly " $fragmentSpreads": FragmentRefs<"useRiskFormFragment">;
};
};
};
export type FormRiskDialogUpdateRiskMutation = {
response: FormRiskDialogUpdateRiskMutation$data;
variables: FormRiskDialogUpdateRiskMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
}
],
v1 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v2 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "FormRiskDialogUpdateRiskMutation",
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateRiskPayload",
"kind": "LinkedField",
"name": "updateRisk",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "risk",
"plural": false,
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "useRiskFormFragment"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "FormRiskDialogUpdateRiskMutation",
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateRiskPayload",
"kind": "LinkedField",
"name": "updateRisk",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "risk",
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "category",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "treatment",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v2/*: any*/)
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "546b1e60a2e87bf71a1851ca76485767",
"id": null,
"metadata": {},
"name": "FormRiskDialogUpdateRiskMutation",
"operationKind": "mutation",
"text": "mutation FormRiskDialogUpdateRiskMutation(\n $input: UpdateRiskInput!\n) {\n updateRisk(input: $input) {\n risk {\n ...useRiskFormFragment\n id\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n note\n owner {\n id\n }\n}\n"
}
};
})();
(node as any).hash = "0299493042b2b5e7e464c991bab94375";
export default node;

View File

@@ -0,0 +1,132 @@
/**
* @generated SignedSource<<b410e2d0b99401f7ad86c1d4f7a0fcfe>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type DeleteRiskInput = {
riskId: string;
};
export type RisksPageDeleteMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteRiskInput;
};
export type RisksPageDeleteMutation$data = {
readonly deleteRisk: {
readonly deletedRiskId: string;
};
};
export type RisksPageDeleteMutation = {
response: RisksPageDeleteMutation$data;
variables: RisksPageDeleteMutation$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": "deletedRiskId",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "RisksPageDeleteMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteRiskPayload",
"kind": "LinkedField",
"name": "deleteRisk",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "RisksPageDeleteMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteRiskPayload",
"kind": "LinkedField",
"name": "deleteRisk",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"key": "",
"kind": "ScalarHandle",
"name": "deletedRiskId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "a08977dc1d81b5ab63e431014b2d2b41",
"id": null,
"metadata": {},
"name": "RisksPageDeleteMutation",
"operationKind": "mutation",
"text": "mutation RisksPageDeleteMutation(\n $input: DeleteRiskInput!\n) {\n deleteRisk(input: $input) {\n deletedRiskId\n }\n}\n"
}
};
})();
(node as any).hash = "fb17a17779665063283d3d73fcb39785";
export default node;

View File

@@ -0,0 +1,441 @@
/**
* @generated SignedSource<<5ce40300f73da895316795164a9bcf88>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type RiskTreatment = "ACCEPTED" | "AVOIDED" | "MITIGATED" | "TRANSFERRED" | "%future added value";
export type RisksPageQuery$variables = {
after?: any | null | undefined;
before?: any | null | undefined;
first?: number | null | undefined;
last?: number | null | undefined;
organizationId: string;
};
export type RisksPageQuery$data = {
readonly organization: {
readonly risks?: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly category: string;
readonly id: string;
readonly inherentImpact: number;
readonly inherentLikelihood: number;
readonly inherentSeverity: number;
readonly name: string;
readonly residualImpact: number;
readonly residualLikelihood: number;
readonly treatment: RiskTreatment;
readonly " $fragmentSpreads": FragmentRefs<"useRiskFormFragment">;
};
}>;
};
};
};
export type RisksPageQuery = {
response: RisksPageQuery$data;
variables: RisksPageQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
v2 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
v3 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
v4 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "organizationId"
},
v5 = [
{
"kind": "Variable",
"name": "id",
"variableName": "organizationId"
}
],
v6 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v7 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
v8 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "category",
"storageKey": null
},
v9 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "treatment",
"storageKey": null
},
v10 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentLikelihood",
"storageKey": null
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentImpact",
"storageKey": null
},
v12 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualLikelihood",
"storageKey": null
},
v13 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualImpact",
"storageKey": null
},
v14 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentSeverity",
"storageKey": null
},
v15 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v16 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
},
v17 = {
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
}
],
"storageKey": null
},
v18 = [
{
"kind": "Variable",
"name": "after",
"variableName": "after"
},
{
"kind": "Variable",
"name": "before",
"variableName": "before"
},
{
"kind": "Variable",
"name": "first",
"variableName": "first"
},
{
"kind": "Variable",
"name": "last",
"variableName": "last"
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "RisksPageQuery",
"selections": [
{
"alias": "organization",
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"kind": "InlineFragment",
"selections": [
{
"alias": "risks",
"args": null,
"concreteType": "RiskConnection",
"kind": "LinkedField",
"name": "__RisksPage_risks_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "RiskEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
(v11/*: any*/),
(v12/*: any*/),
(v13/*: any*/),
(v14/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
"name": "useRiskFormFragment"
},
(v15/*: any*/)
],
"storageKey": null
},
(v16/*: any*/)
],
"storageKey": null
},
(v17/*: any*/)
],
"storageKey": null
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v4/*: any*/),
(v2/*: any*/),
(v0/*: any*/),
(v3/*: any*/),
(v1/*: any*/)
],
"kind": "Operation",
"name": "RisksPageQuery",
"selections": [
{
"alias": "organization",
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v15/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v18/*: any*/),
"concreteType": "RiskConnection",
"kind": "LinkedField",
"name": "risks",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "RiskEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
(v11/*: any*/),
(v12/*: any*/),
(v13/*: any*/),
(v14/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v6/*: any*/)
],
"storageKey": null
},
(v15/*: any*/)
],
"storageKey": null
},
(v16/*: any*/)
],
"storageKey": null
},
(v17/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": (v18/*: any*/),
"filters": null,
"handle": "connection",
"key": "RisksPage_risks",
"kind": "LinkedHandle",
"name": "risks"
}
],
"type": "Organization",
"abstractKey": null
},
(v6/*: any*/)
],
"storageKey": null
}
]
},
"params": {
"cacheID": "6bc1d32f53846f76f66d3dd065f5b038",
"id": null,
"metadata": {
"connection": [
{
"count": null,
"cursor": null,
"direction": "bidirectional",
"path": [
"organization",
"risks"
]
}
]
},
"name": "RisksPageQuery",
"operationKind": "query",
"text": "query RisksPageQuery(\n $organizationId: ID!\n $first: Int\n $after: CursorKey\n $last: Int\n $before: CursorKey\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n risks(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n category\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentSeverity\n ...useRiskFormFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n id\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n note\n owner {\n id\n }\n}\n"
}
};
})();
(node as any).hash = "bf112f97f377b95f3b83ec949e5d5e2f";
export default node;

View File

@@ -0,0 +1,220 @@
/**
* @generated SignedSource<<78e5a6f1db510ffe28be99140539b234>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type RiskTreatment = "ACCEPTED" | "AVOIDED" | "MITIGATED" | "TRANSFERRED" | "%future added value";
export type UpdateRiskInput = {
category?: string | null | undefined;
description?: string | null | undefined;
id: string;
inherentImpact?: number | null | undefined;
inherentLikelihood?: number | null | undefined;
name?: string | null | undefined;
note?: string | null | undefined;
ownerId?: string | null | undefined;
residualImpact?: number | null | undefined;
residualLikelihood?: number | null | undefined;
treatment?: RiskTreatment | null | undefined;
};
export type RisksPageUpdateRiskMutation$variables = {
input: UpdateRiskInput;
};
export type RisksPageUpdateRiskMutation$data = {
readonly updateRisk: {
readonly risk: {
readonly category: string;
readonly description: string;
readonly id: string;
readonly inherentImpact: number;
readonly inherentLikelihood: number;
readonly name: string;
readonly note: string;
readonly owner: {
readonly fullName: string;
readonly id: string;
} | null | undefined;
readonly residualImpact: number;
readonly residualLikelihood: number;
readonly treatment: RiskTreatment;
readonly updatedAt: any;
};
};
};
export type RisksPageUpdateRiskMutation = {
response: RisksPageUpdateRiskMutation$data;
variables: RisksPageUpdateRiskMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
}
],
v1 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v2 = [
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
"concreteType": "UpdateRiskPayload",
"kind": "LinkedField",
"name": "updateRisk",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Risk",
"kind": "LinkedField",
"name": "risk",
"plural": false,
"selections": [
(v1/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "category",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "treatment",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v1/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
];
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "RisksPageUpdateRiskMutation",
"selections": (v2/*: any*/),
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "RisksPageUpdateRiskMutation",
"selections": (v2/*: any*/)
},
"params": {
"cacheID": "a3c421bf079967f96acf2215e72cf8a7",
"id": null,
"metadata": {},
"name": "RisksPageUpdateRiskMutation",
"operationKind": "mutation",
"text": "mutation RisksPageUpdateRiskMutation(\n $input: UpdateRiskInput!\n) {\n updateRisk(input: $input) {\n risk {\n id\n name\n description\n category\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n treatment\n note\n updatedAt\n owner {\n id\n fullName\n }\n }\n }\n}\n"
}
};
})();
(node as any).hash = "e3c8daa449e937742695adf8deb6dbe5";
export default node;

View File

@@ -0,0 +1,133 @@
/**
* @generated SignedSource<<6cf0470d3c2e5d8d9d6ca52bf3375026>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
export type RiskTreatment = "ACCEPTED" | "AVOIDED" | "MITIGATED" | "TRANSFERRED" | "%future added value";
import { FragmentRefs } from "relay-runtime";
export type useRiskFormFragment$data = {
readonly category: string;
readonly description: string;
readonly id: string;
readonly inherentImpact: number;
readonly inherentLikelihood: number;
readonly name: string;
readonly note: string;
readonly owner: {
readonly id: string;
} | null | undefined;
readonly residualImpact: number;
readonly residualLikelihood: number;
readonly treatment: RiskTreatment;
readonly " $fragmentType": "useRiskFormFragment";
};
export type useRiskFormFragment$key = {
readonly " $data"?: useRiskFormFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"useRiskFormFragment">;
};
const node: ReaderFragment = (function(){
var v0 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "useRiskFormFragment",
"selections": [
(v0/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "category",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "treatment",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualLikelihood",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v0/*: any*/)
],
"storageKey": null
}
],
"type": "Risk",
"abstractKey": null
};
})();
(node as any).hash = "7ad9386b4049af3f139d7269bb5229c2";
export default node;

View File

@@ -1,38 +1,77 @@
import { z } from "zod";
import { useFormWithSchema } from "../../../../hooks/useFormWithSchema";
import { graphql } from "relay-runtime";
import type {
useRiskFormFragment$data,
useRiskFormFragment$key,
} from "./__generated__/useRiskFormFragment.graphql";
import { useFragment } from "react-relay";
const RiskFragment = graphql`
fragment useRiskFormFragment on Risk {
id
name
category
description
treatment
inherentLikelihood
inherentImpact
residualLikelihood
residualImpact
note
owner {
id
}
}
`;
export type RiskNode = useRiskFormFragment$data;
export type RiskKey = useRiskFormFragment$key & { id: string };
// Export the schema so it can be used elsewhere
export const riskSchema = z.object({
category: z.string(),
name: z.string(),
description: z.string(),
organizationId: z.string(),
ownerId: z.string(),
treatment: z.enum(["AVOIDED", "MITIGATED", "TRANSFERRED", "ACCEPTED"]),
inherentLikelihood: z.number().min(1).max(5),
inherentImpact: z.number().min(1).max(5),
residualLikelihood: z.number().min(1).max(5),
residualImpact: z.number().min(1).max(5),
treatment: z.enum([
"AVOIDED",
"MITIGATED",
"TRANSFERRED",
"ACCEPTED",
"%future added value",
]),
inherentLikelihood: z.number({ coerce: true }).min(1).max(5),
inherentImpact: z.number({ coerce: true }).min(1).max(5),
residualLikelihood: z.number({ coerce: true }).min(1).max(5),
residualImpact: z.number({ coerce: true }).min(1).max(5),
note: z.string(),
});
export const useRiskForm = (organizationId: string) => {
export const useRiskForm = (riskKey?: RiskKey) => {
const risk = useFragment(RiskFragment, riskKey);
return useFormWithSchema(riskSchema, {
defaultValues: {
category: "Compliance & Legal",
name: "Contractual risk due to poorly drafted agreements",
description:
"Weak contracts leads to disputes, missed deliverables, or revenue leakage",
organizationId: organizationId,
ownerId: "a_YJLJ5RAAIACAAAAZbuSmzPhFPhoMEQ",
treatment: "MITIGATED",
inherentLikelihood: 5,
inherentImpact: 5,
residualLikelihood: 5,
residualImpact: 5,
note: "Hello worlds this is a test",
},
defaultValues: risk
? {
...risk,
ownerId: risk.owner?.id,
}
: {
category: "Compliance & Legal",
name: "Contractual risk due to poorly drafted agreements",
description:
"Weak contracts leads to disputes, missed deliverables, or revenue leakage",
ownerId: "a_YJLJ5RAAIACAAAAZbuSmzPhFPhoMEQ",
treatment: "MITIGATED",
inherentLikelihood: 5,
inherentImpact: 5,
residualLikelihood: 5,
residualImpact: 5,
note: "Hello worlds this is a test",
},
});
};
export type RiskForm = ReturnType<typeof useRiskForm>;
export type RiskData = z.infer<typeof riskSchema>;

View File

@@ -71,11 +71,12 @@ const routes = [
*/
function routeTransformer(route: Route): RouteObject {
if ("fallback" in route && route.fallback) {
const fallback = <route.fallback />;
return {
...route,
children: route.children?.map(routeTransformer),
Component: () => (
<Suspense fallback={<route.fallback />}>
<Suspense fallback={fallback}>
<route.Component />
</Suspense>
),

View File

@@ -0,0 +1,7 @@
export type NodeOf<T> = T extends
| { readonly edges: ReadonlyArray<{ readonly node: infer U }> }
| undefined
? U
: never;
export type ItemOf<T> = T extends (infer U)[] ? U : never;