-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ #498 - feat: show details tab on destruction list toolbar
- Loading branch information
1 parent
a7bc9c9
commit 546e245
Showing
5 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
59 changes: 48 additions & 11 deletions
59
frontend/src/components/DestructionListAuditLog/DestructionListAuditLog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,62 @@ | ||
import { DataGrid } from "@maykin-ui/admin-ui"; | ||
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"; | ||
|
||
/** | ||
* Shows the destruction list's audit log (if passed). | ||
*/ | ||
export function DestructionListAuditLog({ | ||
destructionList, | ||
export function DestructionListAuditLogHistory({ | ||
logItems, | ||
}: { | ||
destructionList?: DestructionList; | ||
logItems: AuditLogItem[]; | ||
}) { | ||
const logItems = useAuditLog(destructionList); | ||
|
||
const objectList = logItems.map((logItem) => ({ | ||
const historyObjectList = logItems.map((logItem) => ({ | ||
Datum: formatDateAndTime(logItem.timestamp), | ||
"Gewijzigd door": formatUser(logItem.user), | ||
Wijziging: logItem.message, | ||
})); | ||
|
||
return <DataGrid objectList={objectList} sort={true} />; | ||
return <DataGrid objectList={historyObjectList} sort={true} />; | ||
} | ||
|
||
export function DestructionListAuditLogDetails({ | ||
destructionList, | ||
}: { | ||
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 = { | ||
Auteur: formatUser(readyForFirstReviewLogItem.user), | ||
...(extraData && { | ||
"Min/Max archiefactiedatum": `van ${ | ||
extraData.minArchiefactiedatum && | ||
formatDateAndTime(extraData.minArchiefactiedatum) | ||
} tot ${extraData.maxArchiefactiedatum && formatDateAndTime(extraData.maxArchiefactiedatum)}`, | ||
Zaaktypen: extraData.zaaktypen | ||
?.map((zaaktype) => zaaktype.label) | ||
.join(", "), | ||
Resultaten: extraData.resultaten | ||
?.map((resultaat) => resultaat.label) | ||
.join(", "), | ||
Archiefnominaties: extraData.archiefnominaties?.join(", "), | ||
Comment: extraData.comment, | ||
"Hoeveelheid Zaken": extraData.numberOfZaken, | ||
}), | ||
}; | ||
|
||
return <AttributeTable object={detailsObjectList} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters