Fix audit and framework deletion
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -36,6 +36,7 @@ import { getAuditStateLabel, getAuditStateVariant, auditStates, fileSize, sprint
|
||||
import type { AuditGraphNodeQuery } from "/hooks/graph/__generated__/AuditGraphNodeQuery.graphql";
|
||||
import { use } from "react";
|
||||
import { PermissionsContext } from "/providers/PermissionsContext";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
const updateAuditSchema = z.object({
|
||||
name: z.string().nullable().optional(),
|
||||
@@ -54,10 +55,12 @@ export default function AuditDetailsPage(props: Props) {
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
const { isAuthorized } = use(PermissionsContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const deleteAudit = useDeleteAudit(
|
||||
{ id: auditEntry.id!, framework: { name: auditEntry.framework!.name} },
|
||||
ConnectionHandler.getConnectionID(organizationId, "AuditsPage_audits")
|
||||
ConnectionHandler.getConnectionID(organizationId, "AuditsPage_audits"),
|
||||
() => navigate(`/organizations/${organizationId}/audits`)
|
||||
);
|
||||
|
||||
const { control, formState, handleSubmit, register, reset } = useFormWithSchema(updateAuditSchema, {
|
||||
|
||||
@@ -273,9 +273,11 @@ function NonconformityRow({
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
{nonconformity.audit.name
|
||||
? `${nonconformity.audit.framework.name} - ${nonconformity.audit.name}`
|
||||
: nonconformity.audit.framework.name
|
||||
{nonconformity.audit
|
||||
? nonconformity.audit.name
|
||||
? `${nonconformity.audit.framework?.name} - ${nonconformity.audit.name}`
|
||||
: nonconformity.audit.framework?.name
|
||||
: <span className="text-txt-tertiary">{__("No audit")}</span>
|
||||
}
|
||||
</Td>
|
||||
<Td>{nonconformity.owner.fullName}</Td>
|
||||
|
||||
@@ -47,7 +47,7 @@ const updateNonconformitySchema = z.object({
|
||||
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"),
|
||||
auditId: z.string().optional(),
|
||||
});
|
||||
|
||||
type Props = {
|
||||
@@ -198,7 +198,6 @@ export default function NonconformityDetailsPage(props: Props) {
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
disabled={isSnapshotMode}
|
||||
/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<b53ef2729d5b435baeb0d3b068be8cef>>
|
||||
* @generated SignedSource<<310dfd9974ac15af86b8e8ecf21d2b5c>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ export type NonconformitiesPageFragment$data = {
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
} | null | undefined;
|
||||
readonly correctiveAction: string | null | undefined;
|
||||
readonly createdAt: any;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
|
||||
@@ -27,7 +27,7 @@ import { formatDatetime, getStatusOptions } 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"),
|
||||
auditId: z.string().optional(),
|
||||
dateIdentified: z.string().optional(),
|
||||
rootCause: z.string().min(1, "Root cause is required"),
|
||||
correctiveAction: z.string().optional(),
|
||||
@@ -78,7 +78,7 @@ export function CreateNonconformityDialog({
|
||||
organizationId,
|
||||
referenceId: formData.referenceId,
|
||||
description: formData.description || undefined,
|
||||
auditId: formData.auditId,
|
||||
auditId: formData.auditId || undefined,
|
||||
dateIdentified: formatDatetime(formData.dateIdentified),
|
||||
rootCause: formData.rootCause,
|
||||
correctiveAction: formData.correctiveAction || undefined,
|
||||
@@ -128,7 +128,6 @@ export function CreateNonconformityDialog({
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<div className="space-y-2">
|
||||
|
||||
Reference in New Issue
Block a user