diff --git a/dashboard/src/components/ActionModal.js b/dashboard/src/components/ActionModal.js index 30b728d2f..3fe7b02c8 100644 --- a/dashboard/src/components/ActionModal.js +++ b/dashboard/src/components/ActionModal.js @@ -4,7 +4,7 @@ import { useRecoilValue, useSetRecoilState } from 'recoil'; import { useHistory, useLocation } from 'react-router-dom'; import { actionsState, allowedActionFieldsInHistory, CANCEL, DONE, prepareActionForEncryption, TODO } from '../recoil/actions'; import { currentTeamState, organisationState, teamsState, userState } from '../recoil/auth'; -import { dayjsInstance, now, outOfBoundariesDate } from '../services/date'; +import { dayjsInstance, formatDateWithNameOfDay, now, outOfBoundariesDate } from '../services/date'; import API from '../services/api'; import SelectPerson from './SelectPerson'; import SelectStatus from './SelectStatus'; @@ -350,7 +350,7 @@ function ActionContent({ onClose, action, personId = null, personIds = null, isM ` (créée par ${name})`} + wrapper={(name) => ` (créée par ${name} le ${formatDateWithNameOfDay(action.createdAt)})`} /> )} diff --git a/dashboard/src/components/ActionsSortableList.js b/dashboard/src/components/ActionsSortableList.js index 7e380a8c2..e0db4d041 100644 --- a/dashboard/src/components/ActionsSortableList.js +++ b/dashboard/src/components/ActionsSortableList.js @@ -20,7 +20,7 @@ import useSearchParamState from '../services/useSearchParamState'; import DescriptionIcon from './DescriptionIcon'; import { AgendaMutedIcon } from '../assets/icons/AgendaMutedIcon'; -const ActionsSortableList = ({ data, limit }) => { +const ActionsSortableList = ({ data, limit, showCreatedAt }) => { useTitle('Agenda'); const history = useHistory(); const user = useRecoilValue(userState); @@ -154,7 +154,18 @@ const ActionsSortableList = ({ data, limit }) => { ); }, }, - ]} + { + title: 'Créée le', + dataKey: 'createdAt', + onSortOrder: setSortOrder, + onSortBy: setSortBy, + sortBy, + sortOrder, + render: (action) => { + return ; + }, + }, + ].filter((e) => showCreatedAt || e.dataKey !== 'createdAt')} /> {limit > 0 && setPage(page, true)} />} diff --git a/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js b/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js index 420c96c03..2d8074e55 100644 --- a/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js +++ b/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js @@ -11,14 +11,46 @@ import { useRecoilValue } from 'recoil'; import { userState } from '../../../recoil/auth'; import { dayjsInstance } from '../../../services/date'; -export const ActionsOrConsultationsReport = ({ actions, consultations, period }) => { +const formatEcheanceLabelPeriod = (period) => { + if (!!period.startDate && !!period.endDate) { + const start = dayjsInstance(period.startDate); + const end = dayjsInstance(period.endDate); + const today = dayjsInstance(); + const showYear = start.year() !== end.year() || start.year() !== today.year(); + const startFormatted = dayjsInstance(period.startDate).format(showYear ? 'D MMM YYYY' : 'D MMM'); + const endFormatted = dayjsInstance(period.endDate).format(showYear ? 'D MMM YYYY' : 'D MMM'); + if (startFormatted === endFormatted) return `le ${startFormatted}`; + return `entre le ${startFormatted} et le ${endFormatted}`; + } + return ''; +}; + +export const ActionsOrConsultationsReport = ({ + actionsDueOrCompletedAt, + actionsCreatedAt, + consultationsDueOrCompletedAt, + consultationsCreatedAt, + period, +}) => { const [activeTab, setActiveTab] = useLocalStorage('reports-actions-consultation-toggle', 'Actions'); const [fullScreen, setFullScreen] = useState(false); - const [filterStatus, setFilterStatus] = useState([]); - const filteredActions = actions.filter((item) => !filterStatus.length || filterStatus.includes(item.status)); - const filteredConsultations = consultations.filter((item) => !filterStatus.length || filterStatus.includes(item.status)); + const [switchCreatedAt, setSwitchCreatedAt] = useLocalStorage('reports-actions-switch-created-at', 'dueOrCompletedAt'); // 'createdAt' or 'dueOrCompletedAt' + const [filterStatus, setFilterStatus] = useLocalStorage('reports-actions-filter-status', []); + + const actions = switchCreatedAt === 'createdAt' ? actionsCreatedAt : actionsDueOrCompletedAt; + const consultations = switchCreatedAt === 'createdAt' ? consultationsCreatedAt : consultationsDueOrCompletedAt; const data = activeTab.includes('Actions') ? actions : consultations; + + const filteredActionsDueOrCompletedAt = actionsDueOrCompletedAt.filter((item) => !filterStatus.length || filterStatus.includes(item.status)); + const filteredActionsCreatedAt = actionsCreatedAt.filter((item) => !filterStatus.length || filterStatus.includes(item.status)); + const filteredConsultationsDueOrCompletedAt = consultationsDueOrCompletedAt.filter( + (item) => !filterStatus.length || filterStatus.includes(item.status) + ); + const filteredConsultationsCreatedAt = consultationsCreatedAt.filter((item) => !filterStatus.length || filterStatus.includes(item.status)); + const filteredActions = switchCreatedAt === 'createdAt' ? filteredActionsCreatedAt : filteredActionsDueOrCompletedAt; + const filteredConsultations = switchCreatedAt === 'createdAt' ? filteredConsultationsCreatedAt : filteredConsultationsDueOrCompletedAt; const filteredData = activeTab.includes('Actions') ? filteredActions : filteredConsultations; + const history = useHistory(); const user = useRecoilValue(userState); @@ -67,8 +99,15 @@ export const ActionsOrConsultationsReport = ({ actions, consultations, period }) -
- +
+
@@ -78,7 +117,30 @@ export const ActionsOrConsultationsReport = ({ actions, consultations, period }) aria-hidden="true" className="printonly tw-flex tw-h-full tw-flex-col tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-shadow">
-

Actions ({filteredActions.length})

+

+ Actions À FAIRE/FAITE/ANNULÉE {formatEcheanceLabelPeriod(period)} ({filteredActionsDueOrCompletedAt.length}) +

+ {filterStatus.length > 0 && ( +

+ Filtrées par status:{' '} + {mappedIdsToLabels + .filter((s) => filterStatus.includes(s._id)) + .map((status) => status.name) + .join(', ')} +

+ )} +
+
+ +
+ + + + setFullScreen(false)}> setFullScreen(false)}> -
- +
+
- +