From 3181694db55d7e3ebf852ee880d41099a646edf8 Mon Sep 17 00:00:00 2001 From: Andie Swift Date: Thu, 16 Jan 2025 09:24:46 -0600 Subject: [PATCH] fixed the FE to include admin changes, checked if attachments exsist --- lib/lambda/submit/submitNOSO.ts | 6 ++++-- lib/packages/shared-types/opensearch/changelog/index.ts | 3 ++- react-app/src/features/package/admin-changes/index.tsx | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/lambda/submit/submitNOSO.ts b/lib/lambda/submit/submitNOSO.ts index 2a1e7843ef..12c50ba5c7 100644 --- a/lib/lambda/submit/submitNOSO.ts +++ b/lib/lambda/submit/submitNOSO.ts @@ -9,7 +9,7 @@ import { ItemResult } from "shared-types/opensearch/main"; // create admin schemas export const submitNOSOAdminSchema = z .object({ - id: z.string(), + packageId: z.string(), adminChangeType: z.literal("NOSO"), }) .and(z.record(z.string(), z.any())); @@ -17,7 +17,7 @@ export const submitNOSOAdminSchema = z export const transformSubmitValuesSchema = submitNOSOAdminSchema.transform((data) => ({ ...data, event: "NOSO", - packageId: data.id, + packageId: data.packageId, timestamp: Date.now(), })); @@ -83,6 +83,8 @@ const copyAttachments = async ({ console.log(" change log: ", attachPackageChangelog.hits.hits[0]._source); const attachments = attachPackageChangelog.hits.hits.reduce((prev, current) => { + // check that attachments exsists + if (!current._source.attachments) return [...prev]; return [...prev, ...current._source.attachments]; }, []); diff --git a/lib/packages/shared-types/opensearch/changelog/index.ts b/lib/packages/shared-types/opensearch/changelog/index.ts index f6137b4981..bb86f9e5ed 100644 --- a/lib/packages/shared-types/opensearch/changelog/index.ts +++ b/lib/packages/shared-types/opensearch/changelog/index.ts @@ -82,7 +82,8 @@ export type Document = Omit & | "withdraw-rai" | "update-values" | "update-id" - | "delete"; + | "delete" + | "NOSO"; }; export type Response = Res; diff --git a/react-app/src/features/package/admin-changes/index.tsx b/react-app/src/features/package/admin-changes/index.tsx index 0621029cea..00340b4509 100644 --- a/react-app/src/features/package/admin-changes/index.tsx +++ b/react-app/src/features/package/admin-changes/index.tsx @@ -60,12 +60,16 @@ export const AdminChange: FC = (props) => { } return ["Disable formal RAI response withdraw", AC_WithdrawDisabled]; } + case "delete": + case "update-values": + case "update-id": + case "NOSO": case "legacy-admin-change": return [props.changeType || "Manual Update", AC_LegacyAdminChange]; default: return [BLANK_VALUE, AC_Update]; } - }, [props.actionType, props.changeType]); + }, [props.changeType, props.event, props.raiWithdrawEnabled]); return (