diff --git a/frontend/src/components/DestructionListAuditLog/DestructionListAuditLog.tsx b/frontend/src/components/DestructionListAuditLog/DestructionListAuditLog.tsx index 571146bf..0cae90b0 100644 --- a/frontend/src/components/DestructionListAuditLog/DestructionListAuditLog.tsx +++ b/frontend/src/components/DestructionListAuditLog/DestructionListAuditLog.tsx @@ -1,6 +1,8 @@ import { AttributeTable, DataGrid } from "@maykin-ui/admin-ui"; +import { useAuditLog } from "../../hooks"; import { AuditLogItem } from "../../lib/api/auditLog"; +import { DestructionList } from "../../lib/api/destructionLists"; import { formatDateAndTime } from "../../lib/format/date"; import { formatUser } from "../../lib/format/user"; @@ -19,10 +21,23 @@ export function DestructionListAuditLogHistory({ } export function DestructionListAuditLogDetails({ - readyForFirstReviewLogItem, + destructionList, }: { - readyForFirstReviewLogItem: AuditLogItem; + destructionList?: DestructionList; }) { + const logItemsReadyForFirstReview = useAuditLog( + destructionList, + "destruction_list_ready_for_first_review", + ); + const readyForFirstReviewLogItem = + logItemsReadyForFirstReview.length > 0 + ? logItemsReadyForFirstReview[0] + : null; + + if (!readyForFirstReviewLogItem) { + return null; + } + const extraData = readyForFirstReviewLogItem.extraData; const detailsObjectList = { "Record Manager": formatUser(readyForFirstReviewLogItem.user), diff --git a/frontend/src/components/DestructionListToolbar/DestructionListToolbar.tsx b/frontend/src/components/DestructionListToolbar/DestructionListToolbar.tsx index 4c22fe75..f3dc4ff9 100644 --- a/frontend/src/components/DestructionListToolbar/DestructionListToolbar.tsx +++ b/frontend/src/components/DestructionListToolbar/DestructionListToolbar.tsx @@ -44,10 +44,6 @@ export function DestructionListToolbar({ review, }: DestructionListToolbarProps) { const logItems = useAuditLog(destructionList); - const logItemsReadyForFirstReview = useAuditLog( - destructionList, - "destruction_list_ready_for_first_review", - ); const reviewResponse = useLatestReviewResponse(review); const properties = ( @@ -146,9 +142,7 @@ export function DestructionListToolbar({ - + ) : (