diff --git a/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.test.tsx b/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.test.tsx index 45eba93..056ec29 100644 --- a/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.test.tsx +++ b/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.test.tsx @@ -56,6 +56,19 @@ describe("Sample Collection Submission Overview", () => { expect(screen.getAllByRole("group")[0]).toHaveAttribute("aria-disabled", "true"); }); + it("should not enable 'edit pre-session information' button if session is locked", async () => { + server.use( + http.get( + "http://localhost/api/shipments/:shipmentId/preSession", + () => HttpResponse.json({ details: {}, isLocked: true }), + { once: true }, + ), + ); + renderWithProviders(await ShipmentHome(baseShipmentParams)); + + expect(screen.getAllByRole("group")[1]).toHaveAttribute("aria-disabled", "true"); + }); + it("should not enable 'print pre-session' button if no pre-session data is available", async () => { server.use( http.get( diff --git a/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.tsx b/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.tsx index 3b03a1b..aad6938 100644 --- a/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.tsx +++ b/src/app/proposals/[proposalId]/sessions/[visitNumber]/shipments/[shipmentId]/(default)/page.tsx @@ -130,7 +130,7 @@ const ShipmentHome = async (props: { params: Promise }) => { Pre-Session Information - {shipmentData.preSessionInfo ? ( + {shipmentData.preSessionInfo?.details ? ( }) => { title={`${shipmentData.preSessionInfo ? "Edit" : "Set"} Pre-Session Information`} as={NextLink} href={`${params.shipmentId}/pre-session`} - isDisabled={!!shipmentData.dispatch.shipmentRequest} + isDisabled={ + !shipmentData.preSessionInfo || + !!shipmentData.preSessionInfo.isLocked + } > Set imaging conditions, grid/data acquisition parameters diff --git a/src/types/schema.d.ts b/src/types/schema.d.ts index 3274487..480f2b3 100644 --- a/src/types/schema.d.ts +++ b/src/types/schema.d.ts @@ -789,6 +789,11 @@ export interface components { PreSessionOut: { /** Details */ details?: Record | null; + /** + * Islocked + * @default false + */ + isLocked: boolean; }; /** SampleIn */ SampleIn: {