This commit is contained in:
Ahmed Bouhuolia
2025-11-12 21:34:30 +02:00
parent a0bc9db9a6
commit 2383091b6e
29 changed files with 279 additions and 78 deletions

View File

@@ -33,6 +33,7 @@ import { DRAWERS } from '@/constants/drawers';
function ManualJournalsDataTable({
// #withManualJournalsActions
setManualJournalsTableState,
setManualJournalsSelectedRows,
// #withAlertsActions
openAlert,
@@ -67,31 +68,26 @@ function ManualJournalsDataTable({
const handlePublishJournal = ({ id }) => {
openAlert('journal-publish', { manualJournalId: id });
};
// Handle the journal edit action.
const handleEditJournal = ({ id }) => {
history.push(`/manual-journals/${id}/edit`);
};
// Handle the journal delete action.
const handleDeleteJournal = ({ id }) => {
openAlert('journal-delete', { manualJournalId: id });
};
// Handle view detail journal.
const handleViewDetailJournal = ({ id }) => {
openDrawer(DRAWERS.JOURNAL_DETAILS, {
manualJournalId: id,
});
};
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer(DRAWERS.JOURNAL_DETAILS, {
manualJournalId: cell.row.original.id,
});
};
// Local storage memorizing columns widths.
const [initialColumnsWidths, , handleColumnResizing] =
useMemorizedColumnsWidths(TABLES.MANUAL_JOURNALS);
@@ -107,6 +103,12 @@ function ManualJournalsDataTable({
},
[setManualJournalsTableState],
);
// Handle selected rows change.
const handleSelectedRowsChange = (selectedFlatRows) => {
const selectedIds = selectedFlatRows?.map((row) => row.original.id) || [];
setManualJournalsSelectedRows(selectedIds);
};
// Display manual journal empty status instead of the table.
if (isEmptyStatus) {
@@ -130,6 +132,7 @@ function ManualJournalsDataTable({
pagesCount={pagination.pagesCount}
autoResetSortBy={false}
autoResetPage={false}
onSelectedRowsChange={handleSelectedRowsChange}
TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu}