Add nonconformity registries
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
107
apps/console/src/components/form/AuditSelectField.tsx
Normal file
107
apps/console/src/components/form/AuditSelectField.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
import { Field, Option, Select, Badge } from "@probo/ui";
|
||||
import { Suspense, type ComponentProps } from "react";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { type Control, Controller, type FieldValues, type Path } from "react-hook-form";
|
||||
import { useLazyLoadQuery, graphql } from "react-relay";
|
||||
import { getAuditStateVariant, getAuditStateLabel } from "@probo/helpers";
|
||||
import type { AuditSelectFieldQuery } from "./__generated__/AuditSelectFieldQuery.graphql";
|
||||
|
||||
const auditsQuery = graphql`
|
||||
query AuditSelectFieldQuery($organizationId: ID!) {
|
||||
organization: node(id: $organizationId) {
|
||||
... on Organization {
|
||||
audits(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
state
|
||||
validFrom
|
||||
validUntil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
type Props<T extends FieldValues = FieldValues> = {
|
||||
organizationId: string;
|
||||
control: Control<T>;
|
||||
name: Path<T>;
|
||||
label?: string;
|
||||
error?: string;
|
||||
} & ComponentProps<typeof Field>;
|
||||
|
||||
export function AuditSelectField<T extends FieldValues = FieldValues>({
|
||||
organizationId,
|
||||
control,
|
||||
...props
|
||||
}: Props<T>) {
|
||||
return (
|
||||
<Field {...props}>
|
||||
<Suspense
|
||||
fallback={<Select variant="editor" loading placeholder="Loading..." />}
|
||||
>
|
||||
<AuditSelectWithQuery
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name={props.name}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
</Suspense>
|
||||
</Field>
|
||||
);
|
||||
}
|
||||
|
||||
function AuditSelectWithQuery<T extends FieldValues = FieldValues>(
|
||||
props: Pick<Props<T>, "organizationId" | "control" | "name" | "disabled">
|
||||
) {
|
||||
const { __ } = useTranslate();
|
||||
const { name, organizationId, control } = props;
|
||||
const data = useLazyLoadQuery<AuditSelectFieldQuery>(auditsQuery, { organizationId });
|
||||
const audits = data?.organization?.audits?.edges?.map((edge) => edge.node).filter((node) => node !== null) ?? [];
|
||||
|
||||
return (
|
||||
<Controller
|
||||
control={control}
|
||||
name={name}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
disabled={props.disabled}
|
||||
id={name}
|
||||
variant="editor"
|
||||
placeholder={__("Select an audit")}
|
||||
onValueChange={field.onChange}
|
||||
key={audits?.length.toString() ?? "0"}
|
||||
{...field}
|
||||
className="w-full"
|
||||
value={field.value ?? ""}
|
||||
>
|
||||
{audits?.map((audit) => (
|
||||
<Option key={audit.id} value={audit.id}>
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<span>
|
||||
{audit.name
|
||||
? `${audit.framework.name} - ${audit.name}`
|
||||
: audit.framework.name
|
||||
}
|
||||
</span>
|
||||
<div className="ml-3">
|
||||
<Badge variant={getAuditStateVariant(audit.state)}>
|
||||
{getAuditStateLabel(__, audit.state)}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
215
apps/console/src/components/form/__generated__/AuditSelectFieldQuery.graphql.ts
generated
Normal file
215
apps/console/src/components/form/__generated__/AuditSelectFieldQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
* @generated SignedSource<<21026731cd2ebaf80c8c2e251b9a57f8>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||
export type AuditSelectFieldQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type AuditSelectFieldQuery$data = {
|
||||
readonly organization: {
|
||||
readonly audits?: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
readonly state: AuditState;
|
||||
readonly validFrom: any | null | undefined;
|
||||
readonly validUntil: any | null | undefined;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
};
|
||||
};
|
||||
export type AuditSelectFieldQuery = {
|
||||
response: AuditSelectFieldQuery$data;
|
||||
variables: AuditSelectFieldQuery$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 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 100
|
||||
}
|
||||
],
|
||||
"concreteType": "AuditConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "audits",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "AuditEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "state",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "validFrom",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "validUntil",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "audits(first:100)"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "AuditSelectFieldQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": "organization",
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "AuditSelectFieldQuery",
|
||||
"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
|
||||
},
|
||||
(v4/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "339c5438bb684c44887cc9cb53fb2c6a",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "AuditSelectFieldQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query AuditSelectFieldQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n audits(first: 100) {\n edges {\n node {\n id\n name\n framework {\n id\n name\n }\n state\n validFrom\n validUntil\n }\n }\n }\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "2bde1a04326144fe1b133672870807eb";
|
||||
|
||||
export default node;
|
||||
243
apps/console/src/hooks/graph/NonconformityRegistryGraph.ts
Normal file
243
apps/console/src/hooks/graph/NonconformityRegistryGraph.ts
Normal file
@@ -0,0 +1,243 @@
|
||||
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 RegistriesConnectionKey = "RegistriesPage_nonconformityRegistries";
|
||||
|
||||
export const nonconformityRegistriesQuery = graphql`
|
||||
query NonconformityRegistryGraphListQuery($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
...RegistriesPageFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const nonconformityRegistryNodeQuery = graphql`
|
||||
query NonconformityRegistryGraphNodeQuery($nonconformityRegistryId: ID!) {
|
||||
node(id: $nonconformityRegistryId) {
|
||||
... on NonconformityRegistry {
|
||||
id
|
||||
referenceId
|
||||
description
|
||||
dateIdentified
|
||||
rootCause
|
||||
correctiveAction
|
||||
dueDate
|
||||
status
|
||||
effectivenessCheck
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
organization {
|
||||
id
|
||||
name
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const createNonconformityRegistryMutation = graphql`
|
||||
mutation NonconformityRegistryGraphCreateMutation(
|
||||
$input: CreateNonconformityRegistryInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
createNonconformityRegistry(input: $input) {
|
||||
nonconformityRegistryEdge @prependEdge(connections: $connections) {
|
||||
node {
|
||||
id
|
||||
referenceId
|
||||
description
|
||||
status
|
||||
dateIdentified
|
||||
dueDate
|
||||
rootCause
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const updateNonconformityRegistryMutation = graphql`
|
||||
mutation NonconformityRegistryGraphUpdateMutation($input: UpdateNonconformityRegistryInput!) {
|
||||
updateNonconformityRegistry(input: $input) {
|
||||
nonconformityRegistry {
|
||||
id
|
||||
referenceId
|
||||
description
|
||||
dateIdentified
|
||||
rootCause
|
||||
correctiveAction
|
||||
dueDate
|
||||
status
|
||||
effectivenessCheck
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const deleteNonconformityRegistryMutation = graphql`
|
||||
mutation NonconformityRegistryGraphDeleteMutation(
|
||||
$input: DeleteNonconformityRegistryInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteNonconformityRegistry(input: $input) {
|
||||
deletedNonconformityRegistryId @deleteEdge(connections: $connections)
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const useDeleteNonconformityRegistry = (
|
||||
registry: { id: string; referenceId: string },
|
||||
connectionId: string
|
||||
) => {
|
||||
const { __ } = useTranslate();
|
||||
const [mutate] = useMutationWithToasts(deleteNonconformityRegistryMutation, {
|
||||
successMessage: __("Non conformity registry entry deleted successfully"),
|
||||
errorMessage: __("Failed to delete non conformity registry entry"),
|
||||
});
|
||||
const confirm = useConfirm();
|
||||
|
||||
return () => {
|
||||
confirm(
|
||||
() =>
|
||||
mutate({
|
||||
variables: {
|
||||
input: {
|
||||
nonconformityRegistryId: registry.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
}),
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
"This will permanently delete the non conformity registry entry %s. This action cannot be undone."
|
||||
),
|
||||
registry.referenceId
|
||||
),
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const useCreateNonconformityRegistry = (connectionId: string) => {
|
||||
const [mutate] = useMutation(createNonconformityRegistryMutation);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
return (input: {
|
||||
organizationId: string;
|
||||
referenceId: string;
|
||||
description?: string;
|
||||
auditId: string;
|
||||
dateIdentified?: string;
|
||||
rootCause: string;
|
||||
correctiveAction?: string;
|
||||
ownerId: string;
|
||||
dueDate?: string;
|
||||
status: string;
|
||||
effectivenessCheck?: string;
|
||||
}) => {
|
||||
if (!input.organizationId) {
|
||||
return alert(__("Failed to create non conformity registry entry: organization is required"));
|
||||
}
|
||||
if (!input.referenceId) {
|
||||
return alert(__("Failed to create non conformity registry entry: reference ID is required"));
|
||||
}
|
||||
if (!input.auditId) {
|
||||
return alert(__("Failed to create non conformity registry entry: audit is required"));
|
||||
}
|
||||
if (!input.ownerId) {
|
||||
return alert(__("Failed to create non conformity registry entry: owner is required"));
|
||||
}
|
||||
if (!input.rootCause) {
|
||||
return alert(__("Failed to create non conformity registry entry: root cause is required"));
|
||||
}
|
||||
|
||||
return promisifyMutation(mutate)({
|
||||
variables: {
|
||||
input: {
|
||||
organizationId: input.organizationId,
|
||||
referenceId: input.referenceId,
|
||||
description: input.description,
|
||||
auditId: input.auditId,
|
||||
dateIdentified: input.dateIdentified,
|
||||
rootCause: input.rootCause,
|
||||
correctiveAction: input.correctiveAction,
|
||||
ownerId: input.ownerId,
|
||||
dueDate: input.dueDate,
|
||||
status: input.status || "OPEN",
|
||||
effectivenessCheck: input.effectivenessCheck,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const useUpdateNonconformityRegistry = () => {
|
||||
const [mutate] = useMutation(updateNonconformityRegistryMutation);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
return (input: {
|
||||
id: string;
|
||||
referenceId?: string;
|
||||
description?: string;
|
||||
dateIdentified?: string;
|
||||
rootCause?: string;
|
||||
correctiveAction?: string;
|
||||
ownerId?: string;
|
||||
auditId?: string;
|
||||
dueDate?: string;
|
||||
status?: string;
|
||||
effectivenessCheck?: string;
|
||||
}) => {
|
||||
if (!input.id) {
|
||||
return alert(__("Failed to update non conformity registry entry: registry ID is required"));
|
||||
}
|
||||
|
||||
return promisifyMutation(mutate)({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
348
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphCreateMutation.graphql.ts
generated
Normal file
348
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphCreateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,348 @@
|
||||
/**
|
||||
* @generated SignedSource<<a656bb20110ce8110b251091f80f27c0>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type CreateNonconformityRegistryInput = {
|
||||
auditId: string;
|
||||
correctiveAction?: string | null | undefined;
|
||||
dateIdentified?: any | null | undefined;
|
||||
description?: string | null | undefined;
|
||||
dueDate?: any | null | undefined;
|
||||
effectivenessCheck?: string | null | undefined;
|
||||
organizationId: string;
|
||||
ownerId: string;
|
||||
referenceId: string;
|
||||
rootCause: string;
|
||||
status: NonconformityRegistryStatus;
|
||||
};
|
||||
export type NonconformityRegistryGraphCreateMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: CreateNonconformityRegistryInput;
|
||||
};
|
||||
export type NonconformityRegistryGraphCreateMutation$data = {
|
||||
readonly createNonconformityRegistry: {
|
||||
readonly nonconformityRegistryEdge: {
|
||||
readonly node: {
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
};
|
||||
readonly createdAt: any;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
readonly description: string | null | undefined;
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly id: string;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly rootCause: string;
|
||||
readonly status: NonconformityRegistryStatus;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export type NonconformityRegistryGraphCreateMutation = {
|
||||
response: NonconformityRegistryGraphCreateMutation$data;
|
||||
variables: NonconformityRegistryGraphCreateMutation$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
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
v6 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
v8 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v9 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v11 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "NonconformityRegistryGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateNonconformityRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createNonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistryEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v10/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "NonconformityRegistryGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateNonconformityRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createNonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistryEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v10/*: any*/),
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "prependEdge",
|
||||
"key": "",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "nonconformityRegistryEdge",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "de251873fde439228e9a1db5928682d3",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityRegistryGraphCreateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NonconformityRegistryGraphCreateMutation(\n $input: CreateNonconformityRegistryInput!\n) {\n createNonconformityRegistry(input: $input) {\n nonconformityRegistryEdge {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n audit {\n id\n framework {\n name\n id\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "249806dbd8c7c28908461d20b3a0ec52";
|
||||
|
||||
export default node;
|
||||
132
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphDeleteMutation.graphql.ts
generated
Normal file
132
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphDeleteMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @generated SignedSource<<eb0bdb8e311cea402d1aa11b79c2c1a5>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DeleteNonconformityRegistryInput = {
|
||||
nonconformityRegistryId: string;
|
||||
};
|
||||
export type NonconformityRegistryGraphDeleteMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: DeleteNonconformityRegistryInput;
|
||||
};
|
||||
export type NonconformityRegistryGraphDeleteMutation$data = {
|
||||
readonly deleteNonconformityRegistry: {
|
||||
readonly deletedNonconformityRegistryId: string;
|
||||
};
|
||||
};
|
||||
export type NonconformityRegistryGraphDeleteMutation = {
|
||||
response: NonconformityRegistryGraphDeleteMutation$data;
|
||||
variables: NonconformityRegistryGraphDeleteMutation$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": "deletedNonconformityRegistryId",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "NonconformityRegistryGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteNonconformityRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteNonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "NonconformityRegistryGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteNonconformityRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteNonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "deleteEdge",
|
||||
"key": "",
|
||||
"kind": "ScalarHandle",
|
||||
"name": "deletedNonconformityRegistryId",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "733821706945a20396447b1134615a0e",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityRegistryGraphDeleteMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NonconformityRegistryGraphDeleteMutation(\n $input: DeleteNonconformityRegistryInput!\n) {\n deleteNonconformityRegistry(input: $input) {\n deletedNonconformityRegistryId\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "99bc5c0c79ffa8de365ab541c960fc84";
|
||||
|
||||
export default node;
|
||||
354
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphListQuery.graphql.ts
generated
Normal file
354
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphListQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,354 @@
|
||||
/**
|
||||
* @generated SignedSource<<a023a856e21a5db125c12185ae6a6009>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type NonconformityRegistryGraphListQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type NonconformityRegistryGraphListQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"RegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type NonconformityRegistryGraphListQuery = {
|
||||
response: NonconformityRegistryGraphListQuery$data;
|
||||
variables: NonconformityRegistryGraphListQuery$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
|
||||
}
|
||||
],
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "NonconformityRegistryGraphListQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "RegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "NonconformityRegistryGraphListQuery",
|
||||
"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": "NonconformityRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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": "nonconformityRegistries(first:10)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "RegistriesPage_nonconformityRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "nonconformityRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "c46e924846c9edfbc065055ee875c979",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityRegistryGraphListQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query NonconformityRegistryGraphListQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...RegistriesPageFragment\n }\n id\n }\n}\n\nfragment RegistriesPageFragment on Organization {\n id\n nonconformityRegistries(first: 10) {\n totalCount\n edges {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "eb05763f0b78e8a91640f863bc335378";
|
||||
|
||||
export default node;
|
||||
307
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphNodeQuery.graphql.ts
generated
Normal file
307
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphNodeQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* @generated SignedSource<<7b7982ce6c305e82103ca4422bbb7c2f>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type NonconformityRegistryGraphNodeQuery$variables = {
|
||||
nonconformityRegistryId: string;
|
||||
};
|
||||
export type NonconformityRegistryGraphNodeQuery$data = {
|
||||
readonly node: {
|
||||
readonly audit?: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
};
|
||||
readonly correctiveAction?: string | null | undefined;
|
||||
readonly createdAt?: any;
|
||||
readonly dateIdentified?: any | null | undefined;
|
||||
readonly description?: string | null | undefined;
|
||||
readonly dueDate?: any | null | undefined;
|
||||
readonly effectivenessCheck?: string | null | undefined;
|
||||
readonly id?: string;
|
||||
readonly organization?: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly owner?: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId?: string;
|
||||
readonly rootCause?: string;
|
||||
readonly status?: NonconformityRegistryStatus;
|
||||
readonly updatedAt?: any;
|
||||
};
|
||||
};
|
||||
export type NonconformityRegistryGraphNodeQuery = {
|
||||
response: NonconformityRegistryGraphNodeQuery$data;
|
||||
variables: NonconformityRegistryGraphNodeQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "nonconformityRegistryId"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "id",
|
||||
"variableName": "nonconformityRegistryId"
|
||||
}
|
||||
],
|
||||
v2 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
v6 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
v8 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v9 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"storageKey": null
|
||||
},
|
||||
v11 = [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": (v11/*: any*/),
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v13 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v14 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Organization",
|
||||
"kind": "LinkedField",
|
||||
"name": "organization",
|
||||
"plural": false,
|
||||
"selections": (v11/*: any*/),
|
||||
"storageKey": null
|
||||
},
|
||||
v15 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v16 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "NonconformityRegistryGraphNodeQuery",
|
||||
"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*/),
|
||||
(v12/*: any*/),
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/)
|
||||
],
|
||||
"type": "NonconformityRegistry",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "NonconformityRegistryGraphNodeQuery",
|
||||
"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*/),
|
||||
(v12/*: any*/),
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/)
|
||||
],
|
||||
"type": "NonconformityRegistry",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "fd9bf2453d001f33ed1e32ad5784b647",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityRegistryGraphNodeQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query NonconformityRegistryGraphNodeQuery(\n $nonconformityRegistryId: ID!\n) {\n node(id: $nonconformityRegistryId) {\n __typename\n ... on NonconformityRegistry {\n id\n referenceId\n description\n dateIdentified\n rootCause\n correctiveAction\n dueDate\n status\n effectivenessCheck\n audit {\n id\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "3395719bf2203fba19ccc94d6f740014";
|
||||
|
||||
export default node;
|
||||
250
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphUpdateMutation.graphql.ts
generated
Normal file
250
apps/console/src/hooks/graph/__generated__/NonconformityRegistryGraphUpdateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
* @generated SignedSource<<19732d1bd6a2a118a8e813058693bad0>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type UpdateNonconformityRegistryInput = {
|
||||
auditId?: string | null | undefined;
|
||||
correctiveAction?: string | null | undefined;
|
||||
dateIdentified?: any | null | undefined;
|
||||
description?: string | null | undefined;
|
||||
dueDate?: any | null | undefined;
|
||||
effectivenessCheck?: string | null | undefined;
|
||||
id: string;
|
||||
ownerId?: string | null | undefined;
|
||||
referenceId?: string | null | undefined;
|
||||
rootCause?: string | null | undefined;
|
||||
status?: NonconformityRegistryStatus | null | undefined;
|
||||
};
|
||||
export type NonconformityRegistryGraphUpdateMutation$variables = {
|
||||
input: UpdateNonconformityRegistryInput;
|
||||
};
|
||||
export type NonconformityRegistryGraphUpdateMutation$data = {
|
||||
readonly updateNonconformityRegistry: {
|
||||
readonly nonconformityRegistry: {
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
};
|
||||
readonly correctiveAction: string | null | undefined;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
readonly description: string | null | undefined;
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly effectivenessCheck: string | null | undefined;
|
||||
readonly id: string;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly rootCause: string;
|
||||
readonly status: NonconformityRegistryStatus;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
export type NonconformityRegistryGraphUpdateMutation = {
|
||||
response: NonconformityRegistryGraphUpdateMutation$data;
|
||||
variables: NonconformityRegistryGraphUpdateMutation$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": "UpdateNonconformityRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "updateNonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"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
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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": "NonconformityRegistryGraphUpdateMutation",
|
||||
"selections": (v2/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "NonconformityRegistryGraphUpdateMutation",
|
||||
"selections": (v2/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "a76545f5642f914e8e8206160e1d8839",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityRegistryGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NonconformityRegistryGraphUpdateMutation(\n $input: UpdateNonconformityRegistryInput!\n) {\n updateNonconformityRegistry(input: $input) {\n nonconformityRegistry {\n id\n referenceId\n description\n dateIdentified\n rootCause\n correctiveAction\n dueDate\n status\n effectivenessCheck\n owner {\n id\n fullName\n }\n audit {\n id\n framework {\n id\n name\n }\n }\n updatedAt\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "456b4f3b6f36c0b518bd3eb870e0d2c5";
|
||||
|
||||
export default node;
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
DropdownSeparator,
|
||||
IconArrowBoxLeft,
|
||||
IconBank,
|
||||
IconBook,
|
||||
IconCircleQuestionmark,
|
||||
IconFire3,
|
||||
IconGroup1,
|
||||
@@ -138,6 +139,11 @@ export function MainLayout() {
|
||||
icon={IconCheckmark1}
|
||||
to={`${prefix}/audits`}
|
||||
/>
|
||||
<SidebarItem
|
||||
label={__("Nonconformity Registries")}
|
||||
icon={IconBook}
|
||||
to={`${prefix}/nonconformityRegistries`}
|
||||
/>
|
||||
<SidebarItem
|
||||
label={__("Trust Center")}
|
||||
icon={IconShield}
|
||||
|
||||
@@ -38,7 +38,7 @@ function SignatureList(props: { version: Version }) {
|
||||
const { __ } = useTranslate();
|
||||
const signatureMap = new Map(signatures.map((s) => [s.signedBy.id, s]));
|
||||
const organizationId = useOrganizationId();
|
||||
const people = usePeople(organizationId);
|
||||
const people = usePeople(organizationId, { excludeContractEnded: true });
|
||||
const signable = props.version.status === "PUBLISHED";
|
||||
|
||||
if (!props.version.signatures) {
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
import {
|
||||
Button,
|
||||
IconPlusLarge,
|
||||
PageHeader,
|
||||
Card,
|
||||
Thead,
|
||||
Tbody,
|
||||
Tr,
|
||||
Th,
|
||||
Td,
|
||||
Badge,
|
||||
ActionDropdown,
|
||||
DropdownItem,
|
||||
IconTrashCan,
|
||||
Table,
|
||||
useConfirm,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { usePageTitle } from "@probo/hooks";
|
||||
import {
|
||||
graphql,
|
||||
usePaginationFragment,
|
||||
usePreloadedQuery,
|
||||
useMutation,
|
||||
ConnectionHandler,
|
||||
type PreloadedQuery,
|
||||
} from "react-relay";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import { CreateNonconformityRegistryDialog } from "./dialogs/CreateNonconformityRegistryDialog";
|
||||
import { deleteNonconformityRegistryMutation, RegistriesConnectionKey } from "../../../hooks/graph/NonconformityRegistryGraph";
|
||||
import { sprintf, promisifyMutation, getStatusVariant, getStatusLabel } from "@probo/helpers";
|
||||
import type { RegistriesPageQuery } from "./__generated__/RegistriesPageQuery.graphql";
|
||||
import type {
|
||||
RegistriesPageFragment$key,
|
||||
RegistriesPageFragment$data,
|
||||
} from "./__generated__/RegistriesPageFragment.graphql";
|
||||
|
||||
type NonconformityRegistry = RegistriesPageFragment$data['nonconformityRegistries']['edges'][number]['node'];
|
||||
|
||||
interface NonconformityRegistriesPageProps {
|
||||
queryRef: PreloadedQuery<RegistriesPageQuery>;
|
||||
}
|
||||
|
||||
const registriesPageFragment = graphql`
|
||||
fragment RegistriesPageFragment on Organization
|
||||
@refetchable(queryName: "RegistriesPageRefetchQuery")
|
||||
@argumentDefinitions(
|
||||
first: { type: "Int", defaultValue: 10 }
|
||||
after: { type: "CursorKey" }
|
||||
) {
|
||||
id
|
||||
nonconformityRegistries(first: $first, after: $after)
|
||||
@connection(key: "RegistriesPage_nonconformityRegistries") {
|
||||
__id
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
referenceId
|
||||
description
|
||||
status
|
||||
dateIdentified
|
||||
dueDate
|
||||
rootCause
|
||||
correctiveAction
|
||||
effectivenessCheck
|
||||
audit {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function NonconformityRegistriesPage({ queryRef }: NonconformityRegistriesPageProps) {
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
|
||||
usePageTitle(__("Nonconformity Registries"));
|
||||
|
||||
const organization = usePreloadedQuery(
|
||||
graphql`
|
||||
query RegistriesPageQuery($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
...RegistriesPageFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
queryRef
|
||||
);
|
||||
|
||||
const { data: registriesData, loadNext, hasNext } = usePaginationFragment(
|
||||
registriesPageFragment,
|
||||
organization.node as RegistriesPageFragment$key
|
||||
);
|
||||
|
||||
const connectionId = ConnectionHandler.getConnectionID(organizationId, RegistriesConnectionKey);
|
||||
const registries: NonconformityRegistry[] = registriesData?.nonconformityRegistries?.edges?.map((edge) => edge.node) ?? [];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<PageHeader
|
||||
title={__("Nonconformity Registries")}
|
||||
description={__(
|
||||
"Manage your organization's non conformity registries."
|
||||
)}
|
||||
>
|
||||
<CreateNonconformityRegistryDialog organizationId={organizationId} connection={connectionId}>
|
||||
<Button icon={IconPlusLarge}>{__("Add nonconformity registry")}</Button>
|
||||
</CreateNonconformityRegistryDialog>
|
||||
</PageHeader>
|
||||
|
||||
{registries.length === 0 ? (
|
||||
<Card padded>
|
||||
<div className="text-center py-12">
|
||||
<h3 className="text-lg font-semibold mb-2">
|
||||
{__("No non conformity registry entries yet")}
|
||||
</h3>
|
||||
<p className="text-txt-tertiary mb-4">
|
||||
{__("Create your first non conformity registry entry to get started.")}
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<Card>
|
||||
<Table>
|
||||
<Thead>
|
||||
<Tr>
|
||||
<Th>{__("Reference ID")}</Th>
|
||||
<Th>{__("Description")}</Th>
|
||||
<Th>{__("Status")}</Th>
|
||||
<Th>{__("Audit")}</Th>
|
||||
<Th>{__("Owner")}</Th>
|
||||
<Th>{__("Due Date")}</Th>
|
||||
<Th>{__("Actions")}</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{registries.map((registry) => (
|
||||
<RegistryRow
|
||||
key={registry.id}
|
||||
registry={registry}
|
||||
connectionId={connectionId}
|
||||
/>
|
||||
))}
|
||||
</Tbody>
|
||||
</Table>
|
||||
|
||||
{hasNext && (
|
||||
<div className="p-4 border-t">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => loadNext(10)}
|
||||
disabled={!hasNext}
|
||||
>
|
||||
{__("Load more")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RegistryRow({
|
||||
registry,
|
||||
connectionId,
|
||||
}: {
|
||||
registry: NonconformityRegistry;
|
||||
connectionId: string;
|
||||
}) {
|
||||
const organizationId = useOrganizationId();
|
||||
const { __ } = useTranslate();
|
||||
const confirm = useConfirm();
|
||||
const [deleteRegistry] = useMutation(deleteNonconformityRegistryMutation);
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
return new Date(dateString).toLocaleDateString();
|
||||
};
|
||||
|
||||
const handleDeleteRegistry = (registry: NonconformityRegistry) => {
|
||||
if (!connectionId) return;
|
||||
|
||||
confirm(
|
||||
() => {
|
||||
return promisifyMutation(deleteRegistry)({
|
||||
variables: {
|
||||
input: {
|
||||
nonconformityRegistryId: registry.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
});
|
||||
},
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
"This will permanently delete the registry entry %s. This action cannot be undone."
|
||||
),
|
||||
registry.referenceId
|
||||
),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Tr to={`/organizations/${organizationId}/nonconformityRegistries/${registry.id}`}>
|
||||
<Td>
|
||||
<span className="font-mono text-sm">{registry.referenceId}</span>
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="min-w-0">
|
||||
<p className="whitespace-pre-wrap break-words">
|
||||
{registry.description || __("No description")}
|
||||
</p>
|
||||
</div>
|
||||
</Td>
|
||||
<Td>
|
||||
<Badge variant={getStatusVariant(registry.status)}>
|
||||
{getStatusLabel(registry.status)}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
{registry.audit.name
|
||||
? `${registry.audit.framework.name} - ${registry.audit.name}`
|
||||
: registry.audit.framework.name
|
||||
}
|
||||
</Td>
|
||||
<Td>{registry.owner.fullName}</Td>
|
||||
<Td>
|
||||
{registry.dueDate ? (
|
||||
<time dateTime={registry.dueDate}>
|
||||
{formatDate(registry.dueDate)}
|
||||
</time>
|
||||
) : (
|
||||
<span className="text-txt-tertiary">{__("No due date")}</span>
|
||||
)}
|
||||
</Td>
|
||||
<Td noLink width={50} className="text-end">
|
||||
<ActionDropdown>
|
||||
<DropdownItem
|
||||
icon={IconTrashCan}
|
||||
variant="danger"
|
||||
onSelect={() => handleDeleteRegistry(registry)}
|
||||
>
|
||||
{__("Delete")}
|
||||
</DropdownItem>
|
||||
</ActionDropdown>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
import {
|
||||
ConnectionHandler,
|
||||
usePreloadedQuery,
|
||||
type PreloadedQuery,
|
||||
} from "react-relay";
|
||||
import {
|
||||
nonconformityRegistryNodeQuery,
|
||||
useDeleteNonconformityRegistry,
|
||||
useUpdateNonconformityRegistry,
|
||||
RegistriesConnectionKey,
|
||||
} from "../../../hooks/graph/NonconformityRegistryGraph";
|
||||
import {
|
||||
ActionDropdown,
|
||||
Badge,
|
||||
Breadcrumb,
|
||||
Button,
|
||||
DropdownItem,
|
||||
Field,
|
||||
IconTrashCan,
|
||||
Option,
|
||||
Input,
|
||||
Card,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import { ControlledField } from "/components/form/ControlledField";
|
||||
import { PeopleSelectField } from "/components/form/PeopleSelectField";
|
||||
import { AuditSelectField } from "/components/form/AuditSelectField";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import z from "zod";
|
||||
import { getStatusVariant, getStatusLabel, formatDatetime, getNonconformityRegistryStatusOptions } from "@probo/helpers";
|
||||
import type { NonconformityRegistryGraphNodeQuery } from "/hooks/graph/__generated__/NonconformityRegistryGraphNodeQuery.graphql";
|
||||
|
||||
const updateRegistrySchema = z.object({
|
||||
referenceId: z.string().min(1, "Reference ID is required"),
|
||||
description: z.string().optional(),
|
||||
dateIdentified: z.string().optional(),
|
||||
dueDate: z.string().optional(),
|
||||
rootCause: z.string().min(1, "Root cause is required"),
|
||||
correctiveAction: z.string().optional(),
|
||||
effectivenessCheck: z.string().optional(),
|
||||
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
|
||||
ownerId: z.string().min(1, "Owner is required"),
|
||||
auditId: z.string().min(1, "Audit is required"),
|
||||
});
|
||||
|
||||
type Props = {
|
||||
queryRef: PreloadedQuery<NonconformityRegistryGraphNodeQuery>;
|
||||
};
|
||||
|
||||
export default function NonconformityRegistryDetailsPage(props: Props) {
|
||||
const data = usePreloadedQuery<NonconformityRegistryGraphNodeQuery>(
|
||||
nonconformityRegistryNodeQuery,
|
||||
props.queryRef
|
||||
);
|
||||
const registry = data.node;
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
|
||||
const deleteRegistry = useDeleteNonconformityRegistry(
|
||||
{ id: registry.id!, referenceId: registry.referenceId! },
|
||||
ConnectionHandler.getConnectionID(organizationId, RegistriesConnectionKey)
|
||||
);
|
||||
|
||||
const { control, formState, handleSubmit, register, reset } = useFormWithSchema(
|
||||
updateRegistrySchema,
|
||||
{
|
||||
defaultValues: {
|
||||
referenceId: registry.referenceId || "",
|
||||
description: registry.description || "",
|
||||
dateIdentified: registry.dateIdentified?.split('T')[0] || "",
|
||||
dueDate: registry.dueDate?.split('T')[0] || "",
|
||||
rootCause: registry.rootCause || "",
|
||||
correctiveAction: registry.correctiveAction || "",
|
||||
effectivenessCheck: registry.effectivenessCheck || "",
|
||||
status: registry.status || "OPEN",
|
||||
ownerId: registry.owner?.id || "",
|
||||
auditId: registry.audit?.id || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRegistry = useUpdateNonconformityRegistry();
|
||||
const { toast } = useToast();
|
||||
|
||||
const onSubmit = handleSubmit(async (formData) => {
|
||||
if (!registry.id) return;
|
||||
|
||||
try {
|
||||
await updateRegistry({
|
||||
id: registry.id,
|
||||
referenceId: formData.referenceId,
|
||||
description: formData.description,
|
||||
dateIdentified: formatDatetime(formData.dateIdentified),
|
||||
dueDate: formatDatetime(formData.dueDate),
|
||||
rootCause: formData.rootCause,
|
||||
correctiveAction: formData.correctiveAction,
|
||||
effectivenessCheck: formData.effectivenessCheck,
|
||||
status: formData.status,
|
||||
ownerId: formData.ownerId,
|
||||
auditId: formData.auditId,
|
||||
});
|
||||
reset(formData);
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Non conformity registry entry updated successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: error instanceof Error ? error.message : __("Failed to update non conformity registry entry"),
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const statusOptions = getNonconformityRegistryStatusOptions(__);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{
|
||||
label: __("Nonconformity Registries"),
|
||||
to: `/organizations/${organizationId}/nonconformityRegistries`,
|
||||
},
|
||||
{
|
||||
label: registry.referenceId || __("Unknown Nonconformity Registry"),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
<div className="flex justify-between items-start">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="text-2xl font-semibold">
|
||||
{registry.referenceId}
|
||||
</div>
|
||||
<Badge variant={getStatusVariant(registry.status || "OPEN")}>
|
||||
{getStatusLabel(registry.status || "OPEN")}
|
||||
</Badge>
|
||||
</div>
|
||||
<ActionDropdown variant="secondary">
|
||||
<DropdownItem
|
||||
variant="danger"
|
||||
icon={IconTrashCan}
|
||||
onClick={deleteRegistry}
|
||||
>
|
||||
{__("Delete")}
|
||||
</DropdownItem>
|
||||
</ActionDropdown>
|
||||
</div>
|
||||
|
||||
<div className="max-w-4xl">
|
||||
<Card padded>
|
||||
<form onSubmit={onSubmit} className="space-y-6">
|
||||
<h3 className="text-lg font-medium">{__("Nonconformity Registry")}</h3>
|
||||
|
||||
<Field
|
||||
label={__("Reference ID")}
|
||||
required
|
||||
error={formState.errors.referenceId?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("referenceId")}
|
||||
placeholder={__("Enter reference ID")}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<AuditSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<Field label={__("Description")}>
|
||||
<Textarea
|
||||
{...register("description")}
|
||||
placeholder={__("Enter description")}
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<ControlledField
|
||||
control={control}
|
||||
name="status"
|
||||
type="select"
|
||||
label={__("Status")}
|
||||
required
|
||||
>
|
||||
{statusOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</Option>
|
||||
))}
|
||||
</ControlledField>
|
||||
|
||||
<PeopleSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="ownerId"
|
||||
label={__("Owner")}
|
||||
error={formState.errors.ownerId?.message}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field label={__("Date Identified")}>
|
||||
<Input {...register("dateIdentified")} type="date" />
|
||||
</Field>
|
||||
|
||||
<Field label={__("Due Date")}>
|
||||
<Input {...register("dueDate")} type="date" />
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<Field
|
||||
label={__("Root Cause")}
|
||||
required
|
||||
error={formState.errors.rootCause?.message}
|
||||
>
|
||||
<Textarea
|
||||
{...register("rootCause")}
|
||||
placeholder={__("Enter root cause")}
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label={__("Corrective Action")}>
|
||||
<Textarea
|
||||
{...register("correctiveAction")}
|
||||
placeholder={__("Enter corrective action")}
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label={__("Effectiveness Check")}>
|
||||
<Textarea
|
||||
{...register("effectivenessCheck")}
|
||||
placeholder={__("Enter effectiveness check details")}
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<div className="flex justify-end">
|
||||
{formState.isDirty && (
|
||||
<Button type="submit" disabled={formState.isSubmitting}>
|
||||
{formState.isSubmitting ? __("Updating...") : __("Update")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
/**
|
||||
* @generated SignedSource<<662110a9800f0ef9f952778126fdbd96>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type RegistriesPageFragment$data = {
|
||||
readonly id: string;
|
||||
readonly nonconformityRegistries: {
|
||||
readonly __id: string;
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
readonly correctiveAction: string | null | undefined;
|
||||
readonly createdAt: any;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
readonly description: string | null | undefined;
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly effectivenessCheck: string | null | undefined;
|
||||
readonly id: string;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly rootCause: string;
|
||||
readonly status: NonconformityRegistryStatus;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
}>;
|
||||
readonly pageInfo: {
|
||||
readonly endCursor: any | null | undefined;
|
||||
readonly hasNextPage: boolean;
|
||||
};
|
||||
readonly totalCount: number;
|
||||
};
|
||||
readonly " $fragmentType": "RegistriesPageFragment";
|
||||
};
|
||||
export type RegistriesPageFragment$key = {
|
||||
readonly " $data"?: RegistriesPageFragment$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"RegistriesPageFragment">;
|
||||
};
|
||||
|
||||
import RegistriesPageRefetchQuery_graphql from './RegistriesPageRefetchQuery.graphql';
|
||||
|
||||
const node: ReaderFragment = (function(){
|
||||
var v0 = [
|
||||
"nonconformityRegistries"
|
||||
],
|
||||
v1 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v2 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"argumentDefinitions": [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "after"
|
||||
},
|
||||
{
|
||||
"defaultValue": 10,
|
||||
"kind": "LocalArgument",
|
||||
"name": "first"
|
||||
}
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": {
|
||||
"connection": [
|
||||
{
|
||||
"count": "first",
|
||||
"cursor": "after",
|
||||
"direction": "forward",
|
||||
"path": (v0/*: any*/)
|
||||
}
|
||||
],
|
||||
"refetch": {
|
||||
"connection": {
|
||||
"forward": {
|
||||
"count": "first",
|
||||
"cursor": "after"
|
||||
},
|
||||
"backward": null,
|
||||
"path": (v0/*: any*/)
|
||||
},
|
||||
"fragmentPathInResult": [
|
||||
"node"
|
||||
],
|
||||
"operation": RegistriesPageRefetchQuery_graphql,
|
||||
"identifierInfo": {
|
||||
"identifierField": "id",
|
||||
"identifierQueryVariableName": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "RegistriesPageFragment",
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": "nonconformityRegistries",
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "__RegistriesPage_nonconformityRegistries_connection",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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": null
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c582c6c8fa10073ddc1ad8dc33939a1f";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,354 @@
|
||||
/**
|
||||
* @generated SignedSource<<8c45aba43e3ecb3c9e59f9fe5bb0a630>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type RegistriesPageQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type RegistriesPageQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"RegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type RegistriesPageQuery = {
|
||||
response: RegistriesPageQuery$data;
|
||||
variables: RegistriesPageQuery$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
|
||||
}
|
||||
],
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "RegistriesPageQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "RegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "RegistriesPageQuery",
|
||||
"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": "NonconformityRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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": "nonconformityRegistries(first:10)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "RegistriesPage_nonconformityRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "nonconformityRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "738deaeb3219a79ae2ba0957d37aeb32",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "RegistriesPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query RegistriesPageQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...RegistriesPageFragment\n }\n id\n }\n}\n\nfragment RegistriesPageFragment on Organization {\n id\n nonconformityRegistries(first: 10) {\n totalCount\n edges {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "663123fc3652212b1b9e3fecac857d67";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @generated SignedSource<<539eadc93287b3c8055c4f60c2198ef3>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type RegistriesPageRefetchQuery$variables = {
|
||||
after?: any | null | undefined;
|
||||
first?: number | null | undefined;
|
||||
id: string;
|
||||
};
|
||||
export type RegistriesPageRefetchQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"RegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type RegistriesPageRefetchQuery = {
|
||||
response: RegistriesPageRefetchQuery$data;
|
||||
variables: RegistriesPageRefetchQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "after"
|
||||
},
|
||||
{
|
||||
"defaultValue": 10,
|
||||
"kind": "LocalArgument",
|
||||
"name": "first"
|
||||
},
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "id"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "id",
|
||||
"variableName": "id"
|
||||
}
|
||||
],
|
||||
v2 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "after",
|
||||
"variableName": "after"
|
||||
},
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "first",
|
||||
"variableName": "first"
|
||||
}
|
||||
],
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "RegistriesPageRefetchQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"args": (v2/*: any*/),
|
||||
"kind": "FragmentSpread",
|
||||
"name": "RegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "RegistriesPageRefetchQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "NonconformityRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformityRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "NonconformityRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dateIdentified",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "rootCause",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "correctiveAction",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "effectivenessCheck",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
(v3/*: 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": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "RegistriesPage_nonconformityRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "nonconformityRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ada17041dda08a01108cc7fa6bc9015e",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "RegistriesPageRefetchQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query RegistriesPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RegistriesPageFragment_2HEEH6\n id\n }\n}\n\nfragment RegistriesPageFragment_2HEEH6 on Organization {\n id\n nonconformityRegistries(first: $first, after: $after) {\n totalCount\n edges {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c582c6c8fa10073ddc1ad8dc33939a1f";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,249 @@
|
||||
import { type ReactNode } from "react";
|
||||
import {
|
||||
Button,
|
||||
Field,
|
||||
useToast,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
useDialogRef,
|
||||
Textarea,
|
||||
Breadcrumb,
|
||||
Label,
|
||||
Select,
|
||||
Option,
|
||||
Input,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { z } from "zod";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import { useCreateNonconformityRegistry } from "../../../../hooks/graph/NonconformityRegistryGraph";
|
||||
import { PeopleSelectField } from "/components/form/PeopleSelectField";
|
||||
import { AuditSelectField } from "/components/form/AuditSelectField";
|
||||
import { Controller } from "react-hook-form";
|
||||
import { formatDatetime, getNonconformityRegistryStatusOptions } from "@probo/helpers";
|
||||
|
||||
|
||||
|
||||
const schema = z.object({
|
||||
referenceId: z.string().min(1, "Reference ID is required"),
|
||||
description: z.string().optional(),
|
||||
auditId: z.string().min(1, "Audit is required"),
|
||||
dateIdentified: z.string().optional(),
|
||||
rootCause: z.string().min(1, "Root cause is required"),
|
||||
correctiveAction: z.string().optional(),
|
||||
ownerId: z.string().min(1, "Owner is required"),
|
||||
dueDate: z.string().optional(),
|
||||
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
|
||||
effectivenessCheck: z.string().optional(),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof schema>;
|
||||
|
||||
interface CreateNonconformityRegistryDialogProps {
|
||||
children: ReactNode;
|
||||
connection?: string;
|
||||
organizationId: string;
|
||||
}
|
||||
|
||||
export function CreateNonconformityRegistryDialog({
|
||||
children,
|
||||
organizationId,
|
||||
connection,
|
||||
}: CreateNonconformityRegistryDialogProps) {
|
||||
const { __ } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const dialogRef = useDialogRef();
|
||||
|
||||
const createRegistry = useCreateNonconformityRegistry(connection || "");
|
||||
const statusOptions = getNonconformityRegistryStatusOptions(__);
|
||||
|
||||
const { register, handleSubmit, formState, reset, control } = useFormWithSchema(schema, {
|
||||
defaultValues: {
|
||||
referenceId: "",
|
||||
description: "",
|
||||
auditId: "",
|
||||
dateIdentified: "",
|
||||
rootCause: "",
|
||||
correctiveAction: "",
|
||||
ownerId: "",
|
||||
dueDate: "",
|
||||
status: "OPEN" as const,
|
||||
effectivenessCheck: "",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = handleSubmit(async (formData: FormData) => {
|
||||
try {
|
||||
await createRegistry({
|
||||
organizationId,
|
||||
referenceId: formData.referenceId,
|
||||
description: formData.description || undefined,
|
||||
auditId: formData.auditId,
|
||||
dateIdentified: formatDatetime(formData.dateIdentified),
|
||||
rootCause: formData.rootCause,
|
||||
correctiveAction: formData.correctiveAction || undefined,
|
||||
ownerId: formData.ownerId,
|
||||
dueDate: formatDatetime(formData.dueDate),
|
||||
status: formData.status,
|
||||
effectivenessCheck: formData.effectivenessCheck || undefined,
|
||||
});
|
||||
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Non conformity registry entry created successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
|
||||
reset();
|
||||
dialogRef.current?.close();
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: __("Failed to create non conformity registry entry"),
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
ref={dialogRef}
|
||||
trigger={children}
|
||||
title={<Breadcrumb items={[__("Registries"), __("Create Entry")]} />}
|
||||
className="max-w-2xl"
|
||||
>
|
||||
<form onSubmit={onSubmit}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Field
|
||||
label={__("Reference ID")}
|
||||
{...register("referenceId")}
|
||||
placeholder="NC-001"
|
||||
error={formState.errors.referenceId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<AuditSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="description">{__("Description")}</Label>
|
||||
<Textarea
|
||||
id="description"
|
||||
{...register("description")}
|
||||
placeholder={__("Brief description of the nonconformity...")}
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field label={__("Status")}>
|
||||
<Controller
|
||||
control={control}
|
||||
name="status"
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
variant="editor"
|
||||
placeholder={__("Select status")}
|
||||
onValueChange={field.onChange}
|
||||
value={field.value}
|
||||
className="w-full"
|
||||
>
|
||||
{statusOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{formState.errors.status && (
|
||||
<p className="text-sm text-red-500 mt-1">{formState.errors.status.message}</p>
|
||||
)}
|
||||
</Field>
|
||||
|
||||
<PeopleSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="ownerId"
|
||||
label={__("Owner")}
|
||||
error={formState.errors.ownerId?.message}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="dateIdentified">{__("Date Identified")}</Label>
|
||||
<Input
|
||||
id="dateIdentified"
|
||||
type="date"
|
||||
{...register("dateIdentified")}
|
||||
/>
|
||||
{formState.errors.dateIdentified && (
|
||||
<p className="text-sm text-red-500">{formState.errors.dateIdentified.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="dueDate">{__("Due Date")}</Label>
|
||||
<Input
|
||||
id="dueDate"
|
||||
type="date"
|
||||
{...register("dueDate")}
|
||||
/>
|
||||
{formState.errors.dueDate && (
|
||||
<p className="text-sm text-red-500">{formState.errors.dueDate.message}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="rootCause">{__("Root Cause")} *</Label>
|
||||
<Textarea
|
||||
id="rootCause"
|
||||
{...register("rootCause")}
|
||||
placeholder={__("Detailed analysis of the root cause...")}
|
||||
rows={3}
|
||||
/>
|
||||
{formState.errors.rootCause && (
|
||||
<p className="text-sm text-red-500">{formState.errors.rootCause.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="correctiveAction">{__("Corrective Action")}</Label>
|
||||
<Textarea
|
||||
id="correctiveAction"
|
||||
{...register("correctiveAction")}
|
||||
placeholder={__("Proposed corrective actions...")}
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="effectivenessCheck">{__("Effectiveness Check")}</Label>
|
||||
<Textarea
|
||||
id="effectivenessCheck"
|
||||
{...register("effectivenessCheck")}
|
||||
placeholder={__("Assessment of corrective action effectiveness...")}
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
</DialogContent>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="submit" disabled={formState.isSubmitting}>
|
||||
{formState.isSubmitting ? __("Creating...") : __("Create Nonconformity Registry Entry")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import { dataRoutes } from "./routes/dataRoutes.ts";
|
||||
import { assetRoutes } from "./routes/assetRoutes.ts";
|
||||
import { auditRoutes } from "./routes/auditRoutes.ts";
|
||||
import { trustCenterRoutes } from "./routes/trustCenterRoutes.ts";
|
||||
import { nonconformityRegistryRoutes } from "./routes/nonconformityRegistryRoutes.ts";
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
|
||||
export type AppRoute = Omit<RouteObject, "Component" | "children"> & {
|
||||
@@ -149,6 +150,7 @@ const routes = [
|
||||
...assetRoutes,
|
||||
...dataRoutes,
|
||||
...auditRoutes,
|
||||
...nonconformityRegistryRoutes,
|
||||
...trustCenterRoutes,
|
||||
{
|
||||
path: "*",
|
||||
|
||||
29
apps/console/src/routes/nonconformityRegistryRoutes.ts
Normal file
29
apps/console/src/routes/nonconformityRegistryRoutes.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { loadQuery } from "react-relay";
|
||||
import { relayEnvironment } from "/providers/RelayProviders";
|
||||
import { PageSkeleton } from "/components/skeletons/PageSkeleton";
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
import { nonconformityRegistriesQuery, nonconformityRegistryNodeQuery } from "/hooks/graph/NonconformityRegistryGraph";
|
||||
import type { AppRoute } from "/routes";
|
||||
|
||||
export const nonconformityRegistryRoutes= [
|
||||
{
|
||||
path: "nonconformityRegistries",
|
||||
fallback: PageSkeleton,
|
||||
queryLoader: ({ organizationId }: { organizationId: string }) =>
|
||||
loadQuery(relayEnvironment, nonconformityRegistriesQuery, { organizationId }),
|
||||
Component: lazy(
|
||||
() => import("/pages/organizations/nonconformityRegistries/NonconformityRegistriesPage")
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "nonconformityRegistries/:registryId",
|
||||
fallback: PageSkeleton,
|
||||
queryLoader: (params: Record<string, string>) =>
|
||||
loadQuery(relayEnvironment, nonconformityRegistryNodeQuery, {
|
||||
nonconformityRegistryId: params.registryId
|
||||
}),
|
||||
Component: lazy(
|
||||
() => import("/pages/organizations/nonconformityRegistries/NonconformityRegistryDetailsPage")
|
||||
),
|
||||
},
|
||||
] satisfies AppRoute[];
|
||||
@@ -16,6 +16,7 @@ export { availableFrameworks } from "./frameworks";
|
||||
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
||||
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
||||
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
|
||||
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, registryStatuses } from "./registryStatus";
|
||||
export { promisifyMutation } from "./relay";
|
||||
export { fileType, fileSize } from "./file";
|
||||
export { formatDatetime } from "./date";
|
||||
|
||||
46
packages/helpers/src/registryStatus.ts
Normal file
46
packages/helpers/src/registryStatus.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
type Translator = (s: string) => string;
|
||||
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
|
||||
export const registryStatuses = [
|
||||
"OPEN",
|
||||
"IN_PROGRESS",
|
||||
"CLOSED",
|
||||
] as const;
|
||||
|
||||
export const getStatusVariant = (status: NonconformityRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "danger" as const;
|
||||
case "IN_PROGRESS":
|
||||
return "warning" as const;
|
||||
case "CLOSED":
|
||||
return "success" as const;
|
||||
default:
|
||||
return "neutral" as const;
|
||||
}
|
||||
};
|
||||
|
||||
export const getStatusLabel = (status: NonconformityRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "Open";
|
||||
case "IN_PROGRESS":
|
||||
return "In Progress";
|
||||
case "CLOSED":
|
||||
return "Closed";
|
||||
default:
|
||||
return status;
|
||||
}
|
||||
};
|
||||
|
||||
export function getNonconformityRegistryStatusOptions(__: Translator) {
|
||||
return registryStatuses.map((status) => ({
|
||||
value: status,
|
||||
label: __({
|
||||
"OPEN": "Open",
|
||||
"IN_PROGRESS": "In Progress",
|
||||
"CLOSED": "Closed",
|
||||
}[status]),
|
||||
}));
|
||||
}
|
||||
@@ -43,4 +43,5 @@ const (
|
||||
FileEntityType
|
||||
VendorContactEntityType
|
||||
VendorDataPrivacyAgreementEntityType
|
||||
NonconformityRegistryEntityType
|
||||
)
|
||||
|
||||
41
pkg/coredata/migrations/20250814T091852Z.sql
Normal file
41
pkg/coredata/migrations/20250814T091852Z.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
CREATE TYPE nonconformity_registries_status AS ENUM (
|
||||
'OPEN',
|
||||
'IN_PROGRESS',
|
||||
'CLOSED'
|
||||
);
|
||||
|
||||
CREATE TABLE nonconformity_registries (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
organization_id TEXT NOT NULL,
|
||||
reference_id TEXT NOT NULL,
|
||||
description TEXT,
|
||||
audit_id TEXT NOT NULL,
|
||||
date_identified DATE,
|
||||
root_cause TEXT NOT NULL,
|
||||
corrective_action TEXT,
|
||||
owner_id TEXT NOT NULL,
|
||||
due_date DATE,
|
||||
status nonconformity_registries_status NOT NULL,
|
||||
effectiveness_check TEXT,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT nonconformity_registries_organization_id_fkey
|
||||
FOREIGN KEY (organization_id)
|
||||
REFERENCES organizations(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT nonconformity_registries_owner_id_fkey
|
||||
FOREIGN KEY (owner_id)
|
||||
REFERENCES peoples(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT,
|
||||
|
||||
CONSTRAINT nonconformity_registries_audit_id_fkey
|
||||
FOREIGN KEY (audit_id)
|
||||
REFERENCES audits(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
341
pkg/coredata/nonconformity_registry.go
Normal file
341
pkg/coredata/nonconformity_registry.go
Normal file
@@ -0,0 +1,341 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type (
|
||||
NonconformityRegistry struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
ReferenceID string `db:"reference_id"`
|
||||
Description *string `db:"description"`
|
||||
AuditID gid.GID `db:"audit_id"`
|
||||
DateIdentified *time.Time `db:"date_identified"`
|
||||
RootCause string `db:"root_cause"`
|
||||
CorrectiveAction *string `db:"corrective_action"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
DueDate *time.Time `db:"due_date"`
|
||||
Status NonconformityRegistryStatus `db:"status"`
|
||||
EffectivenessCheck *string `db:"effectiveness_check"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
NonconformityRegistries []*NonconformityRegistry
|
||||
)
|
||||
|
||||
func (nr *NonconformityRegistry) CursorKey(field NonconformityRegistryOrderField) page.CursorKey {
|
||||
switch field {
|
||||
case NonconformityRegistryOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(nr.ID, nr.CreatedAt)
|
||||
case NonconformityRegistryOrderFieldDateIdentified:
|
||||
return page.NewCursorKey(nr.ID, nr.DateIdentified)
|
||||
case NonconformityRegistryOrderFieldDueDate:
|
||||
return page.NewCursorKey(nr.ID, nr.DueDate)
|
||||
case NonconformityRegistryOrderFieldStatus:
|
||||
return page.NewCursorKey(nr.ID, nr.Status)
|
||||
case NonconformityRegistryOrderFieldReferenceId:
|
||||
return page.NewCursorKey(nr.ID, nr.ReferenceID)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||
}
|
||||
|
||||
func (nr *NonconformityRegistry) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
nonconformityRegistryID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
date_identified,
|
||||
root_cause,
|
||||
corrective_action,
|
||||
owner_id,
|
||||
due_date,
|
||||
status,
|
||||
effectiveness_check,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
nonconformity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND id = @nonconformity_registry_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"nonconformity_registry_id": nonconformityRegistryID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
registry, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[NonconformityRegistry])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
*nr = registry
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nrs *NonconformityRegistries) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM
|
||||
nonconformity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (nrs *NonconformityRegistries) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[NonconformityRegistryOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
date_identified,
|
||||
root_cause,
|
||||
corrective_action,
|
||||
owner_id,
|
||||
due_date,
|
||||
status,
|
||||
effectiveness_check,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
nonconformity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
registries, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[NonconformityRegistry])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
*nrs = registries
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nr *NonconformityRegistry) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
INSERT INTO nonconformity_registries (
|
||||
id,
|
||||
tenant_id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
date_identified,
|
||||
root_cause,
|
||||
corrective_action,
|
||||
owner_id,
|
||||
due_date,
|
||||
status,
|
||||
effectiveness_check,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@id,
|
||||
@tenant_id,
|
||||
@organization_id,
|
||||
@reference_id,
|
||||
@description,
|
||||
@audit_id,
|
||||
@date_identified,
|
||||
@root_cause,
|
||||
@corrective_action,
|
||||
@owner_id,
|
||||
@due_date,
|
||||
@status,
|
||||
@effectiveness_check,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": nr.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": nr.OrganizationID,
|
||||
"reference_id": nr.ReferenceID,
|
||||
"description": nr.Description,
|
||||
"audit_id": nr.AuditID,
|
||||
"date_identified": nr.DateIdentified,
|
||||
"root_cause": nr.RootCause,
|
||||
"corrective_action": nr.CorrectiveAction,
|
||||
"owner_id": nr.OwnerID,
|
||||
"due_date": nr.DueDate,
|
||||
"status": nr.Status,
|
||||
"effectiveness_check": nr.EffectivenessCheck,
|
||||
"created_at": nr.CreatedAt,
|
||||
"updated_at": nr.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nr *NonconformityRegistry) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
UPDATE nonconformity_registries
|
||||
SET
|
||||
reference_id = @reference_id,
|
||||
description = @description,
|
||||
date_identified = @date_identified,
|
||||
root_cause = @root_cause,
|
||||
corrective_action = @corrective_action,
|
||||
due_date = @due_date,
|
||||
status = @status,
|
||||
effectiveness_check = @effectiveness_check,
|
||||
owner_id = @owner_id,
|
||||
audit_id = @audit_id,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": nr.ID,
|
||||
"reference_id": nr.ReferenceID,
|
||||
"description": nr.Description,
|
||||
"date_identified": nr.DateIdentified,
|
||||
"root_cause": nr.RootCause,
|
||||
"corrective_action": nr.CorrectiveAction,
|
||||
"due_date": nr.DueDate,
|
||||
"status": nr.Status,
|
||||
"effectiveness_check": nr.EffectivenessCheck,
|
||||
"owner_id": nr.OwnerID,
|
||||
"audit_id": nr.AuditID,
|
||||
"updated_at": nr.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nr *NonconformityRegistry) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM nonconformity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"id": nr.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
55
pkg/coredata/nonconformity_registry_order_field.go
Normal file
55
pkg/coredata/nonconformity_registry_order_field.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type NonconformityRegistryOrderField string
|
||||
|
||||
const (
|
||||
NonconformityRegistryOrderFieldCreatedAt NonconformityRegistryOrderField = "CREATED_AT"
|
||||
NonconformityRegistryOrderFieldDateIdentified NonconformityRegistryOrderField = "DATE_IDENTIFIED"
|
||||
NonconformityRegistryOrderFieldDueDate NonconformityRegistryOrderField = "DUE_DATE"
|
||||
NonconformityRegistryOrderFieldStatus NonconformityRegistryOrderField = "STATUS"
|
||||
NonconformityRegistryOrderFieldReferenceId NonconformityRegistryOrderField = "REFERENCE_ID"
|
||||
)
|
||||
|
||||
func (p NonconformityRegistryOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p NonconformityRegistryOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p NonconformityRegistryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *NonconformityRegistryOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(NonconformityRegistryOrderFieldCreatedAt),
|
||||
string(NonconformityRegistryOrderFieldDateIdentified),
|
||||
string(NonconformityRegistryOrderFieldDueDate),
|
||||
string(NonconformityRegistryOrderFieldStatus),
|
||||
string(NonconformityRegistryOrderFieldReferenceId):
|
||||
*p = NonconformityRegistryOrderField(val)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid NonconformityRegistryOrderField value: %q", val)
|
||||
}
|
||||
60
pkg/coredata/nonconformity_registry_status.go
Normal file
60
pkg/coredata/nonconformity_registry_status.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type NonconformityRegistryStatus string
|
||||
|
||||
const (
|
||||
NonconformityRegistryStatusOpen NonconformityRegistryStatus = "OPEN"
|
||||
NonconformityRegistryStatusInProgress NonconformityRegistryStatus = "IN_PROGRESS"
|
||||
NonconformityRegistryStatusClosed NonconformityRegistryStatus = "CLOSED"
|
||||
)
|
||||
|
||||
func (nrs NonconformityRegistryStatus) String() string {
|
||||
return string(nrs)
|
||||
}
|
||||
|
||||
func (nrs *NonconformityRegistryStatus) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for NonconformityRegistryStatus: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "OPEN":
|
||||
*nrs = NonconformityRegistryStatusOpen
|
||||
case "IN_PROGRESS":
|
||||
*nrs = NonconformityRegistryStatusInProgress
|
||||
case "CLOSED":
|
||||
*nrs = NonconformityRegistryStatusClosed
|
||||
default:
|
||||
return fmt.Errorf("invalid NonconformityRegistryStatus value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nrs NonconformityRegistryStatus) Value() (driver.Value, error) {
|
||||
return nrs.String(), nil
|
||||
}
|
||||
270
pkg/probo/nonconformity_registry_service.go
Normal file
270
pkg/probo/nonconformity_registry_service.go
Normal file
@@ -0,0 +1,270 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package probo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type NonconformityRegistryService struct {
|
||||
svc *TenantService
|
||||
}
|
||||
|
||||
type (
|
||||
CreateNonconformityRegistryRequest struct {
|
||||
OrganizationID gid.GID
|
||||
ReferenceID string
|
||||
Description *string
|
||||
AuditID gid.GID
|
||||
DateIdentified *time.Time
|
||||
RootCause string
|
||||
CorrectiveAction *string
|
||||
OwnerID gid.GID
|
||||
DueDate *time.Time
|
||||
Status *coredata.NonconformityRegistryStatus
|
||||
EffectivenessCheck *string
|
||||
}
|
||||
|
||||
UpdateNonconformityRegistryRequest struct {
|
||||
ID gid.GID
|
||||
ReferenceID *string
|
||||
Description **string
|
||||
DateIdentified **time.Time
|
||||
RootCause *string
|
||||
CorrectiveAction **string
|
||||
OwnerID *gid.GID
|
||||
AuditID *gid.GID
|
||||
DueDate **time.Time
|
||||
Status *coredata.NonconformityRegistryStatus
|
||||
EffectivenessCheck **string
|
||||
}
|
||||
)
|
||||
|
||||
func (s NonconformityRegistryService) Get(
|
||||
ctx context.Context,
|
||||
nonconformityRegistryID gid.GID,
|
||||
) (*coredata.NonconformityRegistry, error) {
|
||||
registry := &coredata.NonconformityRegistry{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return registry.LoadByID(ctx, conn, s.svc.scope, nonconformityRegistryID)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s *NonconformityRegistryService) Create(
|
||||
ctx context.Context,
|
||||
req *CreateNonconformityRegistryRequest,
|
||||
) (*coredata.NonconformityRegistry, error) {
|
||||
now := time.Now()
|
||||
|
||||
registry := &coredata.NonconformityRegistry{
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.NonconformityRegistryEntityType),
|
||||
OrganizationID: req.OrganizationID,
|
||||
ReferenceID: req.ReferenceID,
|
||||
Description: req.Description,
|
||||
AuditID: req.AuditID,
|
||||
DateIdentified: req.DateIdentified,
|
||||
RootCause: req.RootCause,
|
||||
CorrectiveAction: req.CorrectiveAction,
|
||||
OwnerID: req.OwnerID,
|
||||
DueDate: req.DueDate,
|
||||
Status: coredata.NonconformityRegistryStatusOpen,
|
||||
EffectivenessCheck: req.EffectivenessCheck,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.Status != nil {
|
||||
registry.Status = *req.Status
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
organization := &coredata.Organization{}
|
||||
if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
audit := &coredata.Audit{}
|
||||
if err := audit.LoadByID(ctx, conn, s.svc.scope, req.AuditID); err != nil {
|
||||
return fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
}
|
||||
|
||||
if err := registry.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot insert nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s *NonconformityRegistryService) Update(
|
||||
ctx context.Context,
|
||||
req *UpdateNonconformityRegistryRequest,
|
||||
) (*coredata.NonconformityRegistry, error) {
|
||||
registry := &coredata.NonconformityRegistry{}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
if err := registry.LoadByID(ctx, conn, s.svc.scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
if req.ReferenceID != nil {
|
||||
registry.ReferenceID = *req.ReferenceID
|
||||
}
|
||||
if req.Description != nil {
|
||||
registry.Description = *req.Description
|
||||
}
|
||||
if req.DateIdentified != nil {
|
||||
registry.DateIdentified = *req.DateIdentified
|
||||
}
|
||||
if req.RootCause != nil {
|
||||
registry.RootCause = *req.RootCause
|
||||
}
|
||||
if req.CorrectiveAction != nil {
|
||||
registry.CorrectiveAction = *req.CorrectiveAction
|
||||
}
|
||||
if req.OwnerID != nil {
|
||||
registry.OwnerID = *req.OwnerID
|
||||
}
|
||||
if req.AuditID != nil {
|
||||
registry.AuditID = *req.AuditID
|
||||
}
|
||||
if req.DueDate != nil {
|
||||
registry.DueDate = *req.DueDate
|
||||
}
|
||||
if req.Status != nil {
|
||||
registry.Status = *req.Status
|
||||
}
|
||||
if req.EffectivenessCheck != nil {
|
||||
registry.EffectivenessCheck = *req.EffectivenessCheck
|
||||
}
|
||||
|
||||
registry.UpdatedAt = time.Now()
|
||||
|
||||
if err := registry.Update(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot update nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s NonconformityRegistryService) Delete(
|
||||
ctx context.Context,
|
||||
nonconformityRegistryID gid.GID,
|
||||
) error {
|
||||
registry := coredata.NonconformityRegistry{ID: nonconformityRegistryID}
|
||||
return s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := registry.Delete(ctx, conn, s.svc.scope)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete nonconformity registry: %w", err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (s NonconformityRegistryService) ListForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.NonconformityRegistryOrderField],
|
||||
) (*page.Page[*coredata.NonconformityRegistry, coredata.NonconformityRegistryOrderField], error) {
|
||||
var registries coredata.NonconformityRegistries
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := registries.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(registries, cursor), nil
|
||||
}
|
||||
|
||||
func (s NonconformityRegistryService) CountForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) (err error) {
|
||||
registries := coredata.NonconformityRegistries{}
|
||||
count, err = registries.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
@@ -81,6 +81,7 @@ type (
|
||||
Reports *ReportService
|
||||
TrustCenters *TrustCenterService
|
||||
TrustCenterAccesses *TrustCenterAccessService
|
||||
NonconformityRegistries *NonconformityRegistryService
|
||||
}
|
||||
)
|
||||
|
||||
@@ -173,5 +174,6 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
svc: tenantService,
|
||||
usrmgr: s.usrmgr,
|
||||
}
|
||||
tenantService.NonconformityRegistries = &NonconformityRegistryService{svc: tenantService}
|
||||
return tenantService
|
||||
}
|
||||
|
||||
@@ -151,6 +151,22 @@ enum AuditState
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityRegistryStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryStatus") {
|
||||
OPEN
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryStatusOpen"
|
||||
)
|
||||
IN_PROGRESS
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryStatusInProgress"
|
||||
)
|
||||
CLOSED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryStatusClosed"
|
||||
)
|
||||
}
|
||||
|
||||
# Order Field Enums
|
||||
enum UserOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.UserOrderField") {
|
||||
@@ -584,6 +600,30 @@ enum AuditOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityRegistryOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderField") {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderFieldCreatedAt"
|
||||
)
|
||||
REFERENCE_ID
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderFieldReferenceId"
|
||||
)
|
||||
DATE_IDENTIFIED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderFieldDateIdentified"
|
||||
)
|
||||
DUE_DATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderFieldDueDate"
|
||||
)
|
||||
STATUS
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.NonconformityRegistryOrderFieldStatus"
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterAccessOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterAccessOrderField") {
|
||||
CREATED_AT
|
||||
@@ -673,6 +713,14 @@ input AuditOrder
|
||||
field: AuditOrderField!
|
||||
}
|
||||
|
||||
input NonconformityRegistryOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.NonconformityRegistryOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: NonconformityRegistryOrderField!
|
||||
}
|
||||
|
||||
input TrustCenterAccessOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.TrustCenterAccessOrderBy"
|
||||
@@ -888,6 +936,14 @@ type Organization implements Node {
|
||||
orderBy: AuditOrder
|
||||
): AuditConnection! @goField(forceResolver: true)
|
||||
|
||||
nonconformityRegistries(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: NonconformityRegistryOrder
|
||||
): NonconformityRegistryConnection! @goField(forceResolver: true)
|
||||
|
||||
trustCenter: TrustCenter @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
@@ -1280,6 +1336,23 @@ type Audit implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type NonconformityRegistry implements Node {
|
||||
id: ID!
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
referenceId: String!
|
||||
description: String
|
||||
audit: Audit! @goField(forceResolver: true)
|
||||
dateIdentified: Datetime
|
||||
rootCause: String!
|
||||
correctiveAction: String
|
||||
owner: People! @goField(forceResolver: true)
|
||||
dueDate: Datetime
|
||||
status: NonconformityRegistryStatus!
|
||||
effectivenessCheck: String
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Report implements Node {
|
||||
id: ID!
|
||||
objectKey: String!
|
||||
@@ -1563,6 +1636,20 @@ type AuditEdge {
|
||||
node: Audit!
|
||||
}
|
||||
|
||||
type NonconformityRegistryConnection
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.NonconformityRegistryConnection"
|
||||
) {
|
||||
totalCount: Int! @goField(forceResolver: true)
|
||||
edges: [NonconformityRegistryEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type NonconformityRegistryEdge {
|
||||
cursor: CursorKey!
|
||||
node: NonconformityRegistry!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -1782,6 +1869,17 @@ type Mutation {
|
||||
deleteAudit(input: DeleteAuditInput!): DeleteAuditPayload!
|
||||
uploadAuditReport(input: UploadAuditReportInput!): UploadAuditReportPayload!
|
||||
deleteAuditReport(input: DeleteAuditReportInput!): DeleteAuditReportPayload!
|
||||
|
||||
# Nonconformity Registry mutations
|
||||
createNonconformityRegistry(
|
||||
input: CreateNonconformityRegistryInput!
|
||||
): CreateNonconformityRegistryPayload!
|
||||
updateNonconformityRegistry(
|
||||
input: UpdateNonconformityRegistryInput!
|
||||
): UpdateNonconformityRegistryPayload!
|
||||
deleteNonconformityRegistry(
|
||||
input: DeleteNonconformityRegistryInput!
|
||||
): DeleteNonconformityRegistryPayload!
|
||||
}
|
||||
|
||||
# Input Types
|
||||
@@ -2243,6 +2341,39 @@ input DeleteAuditReportInput {
|
||||
auditId: ID!
|
||||
}
|
||||
|
||||
# Nonconformity Registry input types
|
||||
input CreateNonconformityRegistryInput {
|
||||
organizationId: ID!
|
||||
referenceId: String!
|
||||
description: String
|
||||
auditId: ID!
|
||||
dateIdentified: Datetime
|
||||
rootCause: String!
|
||||
correctiveAction: String
|
||||
ownerId: ID!
|
||||
dueDate: Datetime
|
||||
status: NonconformityRegistryStatus!
|
||||
effectivenessCheck: String
|
||||
}
|
||||
|
||||
input UpdateNonconformityRegistryInput {
|
||||
id: ID!
|
||||
referenceId: String
|
||||
description: String
|
||||
dateIdentified: Datetime
|
||||
rootCause: String
|
||||
correctiveAction: String
|
||||
ownerId: ID
|
||||
auditId: ID
|
||||
dueDate: Datetime
|
||||
status: NonconformityRegistryStatus
|
||||
effectivenessCheck: String
|
||||
}
|
||||
|
||||
input DeleteNonconformityRegistryInput {
|
||||
nonconformityRegistryId: ID!
|
||||
}
|
||||
|
||||
# Payload Types
|
||||
type CreateOrganizationPayload {
|
||||
organizationEdge: OrganizationEdge!
|
||||
@@ -2911,3 +3042,16 @@ type UploadAuditReportPayload {
|
||||
type DeleteAuditReportPayload {
|
||||
audit: Audit!
|
||||
}
|
||||
|
||||
# Nonconformity Registry payload types
|
||||
type CreateNonconformityRegistryPayload {
|
||||
nonconformityRegistryEdge: NonconformityRegistryEdge!
|
||||
}
|
||||
|
||||
type UpdateNonconformityRegistryPayload {
|
||||
nonconformityRegistry: NonconformityRegistry!
|
||||
}
|
||||
|
||||
type DeleteNonconformityRegistryPayload {
|
||||
deletedNonconformityRegistryId: ID!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
76
pkg/server/api/console/v1/types/nonconformity_registry.go
Normal file
76
pkg/server/api/console/v1/types/nonconformity_registry.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
NonconformityRegistryOrderBy OrderBy[coredata.NonconformityRegistryOrderField]
|
||||
|
||||
NonconformityRegistryConnection struct {
|
||||
TotalCount int
|
||||
Edges []*NonconformityRegistryEdge
|
||||
PageInfo PageInfo
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
}
|
||||
)
|
||||
|
||||
func NewNonconformityRegistryConnection(
|
||||
p *page.Page[*coredata.NonconformityRegistry, coredata.NonconformityRegistryOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
) *NonconformityRegistryConnection {
|
||||
edges := make([]*NonconformityRegistryEdge, len(p.Data))
|
||||
for i, registry := range p.Data {
|
||||
edges[i] = NewNonconformityRegistryEdge(registry, p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &NonconformityRegistryConnection{
|
||||
Edges: edges,
|
||||
PageInfo: *NewPageInfo(p),
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
}
|
||||
}
|
||||
|
||||
func NewNonconformityRegistry(nr *coredata.NonconformityRegistry) *NonconformityRegistry {
|
||||
return &NonconformityRegistry{
|
||||
ID: nr.ID,
|
||||
ReferenceID: nr.ReferenceID,
|
||||
Description: nr.Description,
|
||||
DateIdentified: nr.DateIdentified,
|
||||
RootCause: nr.RootCause,
|
||||
CorrectiveAction: nr.CorrectiveAction,
|
||||
DueDate: nr.DueDate,
|
||||
Status: nr.Status,
|
||||
EffectivenessCheck: nr.EffectivenessCheck,
|
||||
CreatedAt: nr.CreatedAt,
|
||||
UpdatedAt: nr.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewNonconformityRegistryEdge(nr *coredata.NonconformityRegistry, orderField coredata.NonconformityRegistryOrderField) *NonconformityRegistryEdge {
|
||||
return &NonconformityRegistryEdge{
|
||||
Node: NewNonconformityRegistry(nr),
|
||||
Cursor: nr.CursorKey(orderField),
|
||||
}
|
||||
}
|
||||
@@ -306,6 +306,24 @@ type CreateMeasurePayload struct {
|
||||
MeasureEdge *MeasureEdge `json:"measureEdge"`
|
||||
}
|
||||
|
||||
type CreateNonconformityRegistryInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
DateIdentified *time.Time `json:"dateIdentified,omitempty"`
|
||||
RootCause string `json:"rootCause"`
|
||||
CorrectiveAction *string `json:"correctiveAction,omitempty"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status coredata.NonconformityRegistryStatus `json:"status"`
|
||||
EffectivenessCheck *string `json:"effectivenessCheck,omitempty"`
|
||||
}
|
||||
|
||||
type CreateNonconformityRegistryPayload struct {
|
||||
NonconformityRegistryEdge *NonconformityRegistryEdge `json:"nonconformityRegistryEdge"`
|
||||
}
|
||||
|
||||
type CreateOrganizationInput struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -571,6 +589,14 @@ type DeleteMeasurePayload struct {
|
||||
DeletedMeasureID gid.GID `json:"deletedMeasureId"`
|
||||
}
|
||||
|
||||
type DeleteNonconformityRegistryInput struct {
|
||||
NonconformityRegistryID gid.GID `json:"nonconformityRegistryId"`
|
||||
}
|
||||
|
||||
type DeleteNonconformityRegistryPayload struct {
|
||||
DeletedNonconformityRegistryID gid.GID `json:"deletedNonconformityRegistryId"`
|
||||
}
|
||||
|
||||
type DeleteOrganizationInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
}
|
||||
@@ -895,26 +921,52 @@ type MeasureFilter struct {
|
||||
type Mutation struct {
|
||||
}
|
||||
|
||||
type NonconformityRegistry struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Organization *Organization `json:"organization"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Audit *Audit `json:"audit"`
|
||||
DateIdentified *time.Time `json:"dateIdentified,omitempty"`
|
||||
RootCause string `json:"rootCause"`
|
||||
CorrectiveAction *string `json:"correctiveAction,omitempty"`
|
||||
Owner *People `json:"owner"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status coredata.NonconformityRegistryStatus `json:"status"`
|
||||
EffectivenessCheck *string `json:"effectivenessCheck,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (NonconformityRegistry) IsNode() {}
|
||||
func (this NonconformityRegistry) GetID() gid.GID { return this.ID }
|
||||
|
||||
type NonconformityRegistryEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *NonconformityRegistry `json:"node"`
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
LogoURL *string `json:"logoUrl,omitempty"`
|
||||
Users *UserConnection `json:"users"`
|
||||
Connectors *ConnectorConnection `json:"connectors"`
|
||||
Frameworks *FrameworkConnection `json:"frameworks"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
Peoples *PeopleConnection `json:"peoples"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Risks *RiskConnection `json:"risks"`
|
||||
Tasks *TaskConnection `json:"tasks"`
|
||||
Assets *AssetConnection `json:"assets"`
|
||||
Data *DatumConnection `json:"data"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
LogoURL *string `json:"logoUrl,omitempty"`
|
||||
Users *UserConnection `json:"users"`
|
||||
Connectors *ConnectorConnection `json:"connectors"`
|
||||
Frameworks *FrameworkConnection `json:"frameworks"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
Peoples *PeopleConnection `json:"peoples"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Risks *RiskConnection `json:"risks"`
|
||||
Tasks *TaskConnection `json:"tasks"`
|
||||
Assets *AssetConnection `json:"assets"`
|
||||
Data *DatumConnection `json:"data"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
NonconformityRegistries *NonconformityRegistryConnection `json:"nonconformityRegistries"`
|
||||
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Organization) IsNode() {}
|
||||
@@ -1251,6 +1303,24 @@ type UpdateMeasurePayload struct {
|
||||
Measure *Measure `json:"measure"`
|
||||
}
|
||||
|
||||
type UpdateNonconformityRegistryInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID *string `json:"referenceId,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
DateIdentified *time.Time `json:"dateIdentified,omitempty"`
|
||||
RootCause *string `json:"rootCause,omitempty"`
|
||||
CorrectiveAction *string `json:"correctiveAction,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
AuditID *gid.GID `json:"auditId,omitempty"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status *coredata.NonconformityRegistryStatus `json:"status,omitempty"`
|
||||
EffectivenessCheck *string `json:"effectivenessCheck,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateNonconformityRegistryPayload struct {
|
||||
NonconformityRegistry *NonconformityRegistry `json:"nonconformityRegistry"`
|
||||
}
|
||||
|
||||
type UpdateOrganizationInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
@@ -2713,6 +2713,143 @@ func (r *mutationResolver) DeleteAuditReport(ctx context.Context, input types.De
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateNonconformityRegistry is the resolver for the createNonconformityRegistry field.
|
||||
func (r *mutationResolver) CreateNonconformityRegistry(ctx context.Context, input types.CreateNonconformityRegistryInput) (*types.CreateNonconformityRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.CreateNonconformityRegistryRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Description: input.Description,
|
||||
AuditID: input.AuditID,
|
||||
DateIdentified: input.DateIdentified,
|
||||
RootCause: input.RootCause,
|
||||
CorrectiveAction: input.CorrectiveAction,
|
||||
OwnerID: input.OwnerID,
|
||||
DueDate: input.DueDate,
|
||||
Status: &input.Status,
|
||||
EffectivenessCheck: input.EffectivenessCheck,
|
||||
}
|
||||
|
||||
registry, err := prb.NonconformityRegistries.Create(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return &types.CreateNonconformityRegistryPayload{
|
||||
NonconformityRegistryEdge: types.NewNonconformityRegistryEdge(registry, coredata.NonconformityRegistryOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateNonconformityRegistry is the resolver for the updateNonconformityRegistry field.
|
||||
func (r *mutationResolver) UpdateNonconformityRegistry(ctx context.Context, input types.UpdateNonconformityRegistryInput) (*types.UpdateNonconformityRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateNonconformityRegistryRequest{
|
||||
ID: input.ID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Description: &input.Description,
|
||||
DateIdentified: &input.DateIdentified,
|
||||
RootCause: input.RootCause,
|
||||
CorrectiveAction: &input.CorrectiveAction,
|
||||
OwnerID: input.OwnerID,
|
||||
AuditID: input.AuditID,
|
||||
DueDate: &input.DueDate,
|
||||
Status: input.Status,
|
||||
EffectivenessCheck: &input.EffectivenessCheck,
|
||||
}
|
||||
|
||||
registry, err := prb.NonconformityRegistries.Update(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot update nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return &types.UpdateNonconformityRegistryPayload{
|
||||
NonconformityRegistry: types.NewNonconformityRegistry(registry),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteNonconformityRegistry is the resolver for the deleteNonconformityRegistry field.
|
||||
func (r *mutationResolver) DeleteNonconformityRegistry(ctx context.Context, input types.DeleteNonconformityRegistryInput) (*types.DeleteNonconformityRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.NonconformityRegistryID.TenantID())
|
||||
|
||||
err := prb.NonconformityRegistries.Delete(ctx, input.NonconformityRegistryID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot delete nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
return &types.DeleteNonconformityRegistryPayload{
|
||||
DeletedNonconformityRegistryID: input.NonconformityRegistryID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *nonconformityRegistryResolver) Organization(ctx context.Context, obj *types.NonconformityRegistry) (*types.Organization, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.NonconformityRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
organization, err := prb.Organizations.Get(ctx, registry.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry organization: %w", err)
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Audit is the resolver for the audit field.
|
||||
func (r *nonconformityRegistryResolver) Audit(ctx context.Context, obj *types.NonconformityRegistry) (*types.Audit, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.NonconformityRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Get(ctx, registry.AuditID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry audit: %w", err)
|
||||
}
|
||||
|
||||
return types.NewAudit(audit), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *nonconformityRegistryResolver) Owner(ctx context.Context, obj *types.NonconformityRegistry) (*types.People, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.NonconformityRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry: %w", err)
|
||||
}
|
||||
|
||||
people, err := prb.Peoples.Get(ctx, registry.OwnerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get nonconformity registry owner: %w", err)
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *nonconformityRegistryConnectionResolver) TotalCount(ctx context.Context, obj *types.NonconformityRegistryConnection) (int, error) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.NonconformityRegistries.CountForOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count nonconformity registries: %w", err)
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
return 0, fmt.Errorf("unsupported resolver: %T", obj.Resolver)
|
||||
}
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3068,6 +3205,31 @@ func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organizati
|
||||
return types.NewAuditConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// NonconformityRegistries is the resolver for the nonconformityRegistries field.
|
||||
func (r *organizationResolver) NonconformityRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.NonconformityRegistryOrderBy) (*types.NonconformityRegistryConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.NonconformityRegistryOrderField]{
|
||||
Field: coredata.NonconformityRegistryOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.NonconformityRegistryOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.NonconformityRegistries.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list organization nonconformity registries: %w", err)
|
||||
}
|
||||
|
||||
return types.NewNonconformityRegistryConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// TrustCenter is the resolver for the trustCenter field.
|
||||
func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organization) (*types.TrustCenter, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3211,6 +3373,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get audit: %w", err))
|
||||
}
|
||||
return types.NewAudit(audit), nil
|
||||
case coredata.NonconformityRegistryEntityType:
|
||||
nonconformityRegistry, err := prb.NonconformityRegistries.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get nonconformity registry: %w", err))
|
||||
}
|
||||
return types.NewNonconformityRegistry(nonconformityRegistry), nil
|
||||
case coredata.ReportEntityType:
|
||||
report, err := prb.Reports.Get(ctx, id)
|
||||
if err != nil {
|
||||
@@ -3970,6 +4138,16 @@ func (r *Resolver) MeasureConnection() schema.MeasureConnectionResolver {
|
||||
// Mutation returns schema.MutationResolver implementation.
|
||||
func (r *Resolver) Mutation() schema.MutationResolver { return &mutationResolver{r} }
|
||||
|
||||
// NonconformityRegistry returns schema.NonconformityRegistryResolver implementation.
|
||||
func (r *Resolver) NonconformityRegistry() schema.NonconformityRegistryResolver {
|
||||
return &nonconformityRegistryResolver{r}
|
||||
}
|
||||
|
||||
// NonconformityRegistryConnection returns schema.NonconformityRegistryConnectionResolver implementation.
|
||||
func (r *Resolver) NonconformityRegistryConnection() schema.NonconformityRegistryConnectionResolver {
|
||||
return &nonconformityRegistryConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Organization returns schema.OrganizationResolver implementation.
|
||||
func (r *Resolver) Organization() schema.OrganizationResolver { return &organizationResolver{r} }
|
||||
|
||||
@@ -4055,6 +4233,8 @@ type frameworkConnectionResolver struct{ *Resolver }
|
||||
type measureResolver struct{ *Resolver }
|
||||
type measureConnectionResolver struct{ *Resolver }
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type nonconformityRegistryResolver struct{ *Resolver }
|
||||
type nonconformityRegistryConnectionResolver struct{ *Resolver }
|
||||
type organizationResolver struct{ *Resolver }
|
||||
type peopleConnectionResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user