Fix audit and framework deletion

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-12-09 10:04:47 +01:00
parent c355f1c307
commit 3169fa3c0a
21 changed files with 95 additions and 74 deletions

View File

@@ -112,7 +112,8 @@ export const deleteAuditMutation = graphql`
export const useDeleteAudit = (
audit: { id: string; framework: { name: string } },
connectionId: string
connectionId: string,
onSuccess?: () => void
) => {
const { __ } = useTranslate();
const [mutate] = useMutationWithToasts(deleteAuditMutation, {
@@ -123,15 +124,17 @@ export const useDeleteAudit = (
return () => {
confirm(
() =>
mutate({
async () => {
await mutate({
variables: {
input: {
auditId: audit.id!,
},
connections: [connectionId],
},
}),
});
onSuccess?.();
},
{
message: sprintf(
__(

View File

@@ -168,7 +168,7 @@ export const useCreateNonconformity = (connectionId: string) => {
organizationId: string;
referenceId: string;
description?: string;
auditId: string;
auditId?: string;
dateIdentified?: string;
rootCause: string;
correctiveAction?: string;
@@ -183,9 +183,6 @@ export const useCreateNonconformity = (connectionId: string) => {
if (!input.referenceId) {
return alert(__("Failed to create nonconformity: reference ID is required"));
}
if (!input.auditId) {
return alert(__("Failed to create nonconformity: audit is required"));
}
if (!input.ownerId) {
return alert(__("Failed to create nonconformity: owner is required"));
}
@@ -199,7 +196,7 @@ export const useCreateNonconformity = (connectionId: string) => {
organizationId: input.organizationId,
referenceId: input.referenceId,
description: input.description,
auditId: input.auditId,
auditId: input.auditId || undefined,
dateIdentified: input.dateIdentified,
rootCause: input.rootCause,
correctiveAction: input.correctiveAction,
@@ -226,7 +223,7 @@ export const useUpdateNonconformity = () => {
rootCause?: string;
correctiveAction?: string;
ownerId?: string;
auditId?: string;
auditId?: string | null;
dueDate?: string | null;
status?: string;
effectivenessCheck?: string;
@@ -237,7 +234,10 @@ export const useUpdateNonconformity = () => {
return promisifyMutation(mutate)({
variables: {
input,
input: {
...input,
auditId: input.auditId || null,
},
},
});
};

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<a7d4ac5eee7f07fadad4e2c1f25e87e5>>
* @generated SignedSource<<db7fca9f154989ebab9e5c9b0f5bfd85>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -11,7 +11,7 @@
import { ConcreteRequest } from 'relay-runtime';
export type NonconformityStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
export type CreateNonconformityInput = {
auditId: string;
auditId?: string | null | undefined;
correctiveAction?: string | null | undefined;
dateIdentified?: any | null | undefined;
description?: string | null | undefined;
@@ -36,7 +36,7 @@ export type NonconformityGraphCreateMutation$data = {
readonly name: string;
};
readonly id: string;
};
} | null | undefined;
readonly createdAt: any;
readonly dateIdentified: any | null | undefined;
readonly description: string | null | undefined;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<125cf1d460b37ac442d0f30c14e5af11>>
* @generated SignedSource<<526115183274c5c81a5a70c16012591e>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -21,7 +21,7 @@ export type NonconformityGraphNodeQuery$data = {
readonly name: string;
};
readonly id: string;
};
} | null | undefined;
readonly correctiveAction?: string | null | undefined;
readonly createdAt?: any;
readonly dateIdentified?: any | null | undefined;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<9c7a235f3dc4f691c8f9d036536cf272>>
* @generated SignedSource<<2f4ca0549a2e01d68d9fb752298beb4c>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -35,7 +35,7 @@ export type NonconformityGraphUpdateMutation$data = {
readonly name: string;
};
readonly id: string;
};
} | null | undefined;
readonly correctiveAction: string | null | undefined;
readonly dateIdentified: any | null | undefined;
readonly description: string | null | undefined;