diff --git a/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js b/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js
index 3251113bc..754c705ba 100644
--- a/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js
+++ b/dashboard/src/scenes/report/components/ActionsOrConsultationsReport.js
@@ -10,6 +10,7 @@ import { useLocalStorage } from '../../../services/useLocalStorage';
import { useRecoilValue } from 'recoil';
import { userState } from '../../../recoil/auth';
import { dayjsInstance } from '../../../services/date';
+import EyeIcon from '../../../assets/icons/EyeIcon';
const formatEcheanceLabelPeriod = (period) => {
if (!!period.startDate && !!period.endDate) {
@@ -26,52 +27,54 @@ const formatEcheanceLabelPeriod = (period) => {
};
export const ActionsOrConsultationsReport = ({
- actionsDueOrCompletedAt,
+ actionsCompletedAt,
+ actionsCanceledAt,
actionsCreatedAt,
- consultationsDueOrCompletedAt,
+ consultationsCompletedAt,
+ consultationsCanceledAt,
consultationsCreatedAt,
period,
}) => {
const history = useHistory();
const user = useRecoilValue(userState);
- const [activeTab, setActiveTab] = useLocalStorage('reports-actions-consultation-toggle', 'Actions');
+ const [activeTab, setActiveTab] = useLocalStorage('reports-actions-consultations-todo-done-toggle', 'Faites');
const canSeeMedicalData = ['admin', 'normal'].includes(user.role) && !!user.healthcareProfessional;
+ const [showActions, setShowActions] = useLocalStorage('reports-actions-consultations-show-actions', true);
+ const [showConsultations, setShowConsultations] = useLocalStorage('reports-actions-consultations-show-consults', canSeeMedicalData);
const activeTabIndex = useMemo(() => {
- if (activeTab.includes('Actions')) return 0;
- if (activeTab.includes('Consultations')) return 1;
- if (activeTab.includes('Créées')) {
- if (canSeeMedicalData) return 2;
- return 1;
- }
+ if (activeTab.includes('Faites')) return 0;
+ if (activeTab.includes('Annulées')) return 1;
+ return 2; // activeTab.includes('Créées')
}, [activeTab, canSeeMedicalData]);
+
const [fullScreen, setFullScreen] = useState(false);
- const [filterStatus, setFilterStatus] = useLocalStorage('reports-actions-filter-status', []);
- const data = useMemo(() => {
- if (activeTab.includes('Action')) return actionsDueOrCompletedAt;
- if (activeTab.includes('Consultations')) return consultationsDueOrCompletedAt;
- return [...actionsCreatedAt, ...consultationsCreatedAt];
- }, [activeTab, actionsCreatedAt, consultationsCreatedAt, consultationsDueOrCompletedAt, actionsDueOrCompletedAt]);
+ const actions = useMemo(() => {
+ if (activeTab.includes('Faites')) return actionsCompletedAt;
+ if (activeTab.includes(`Annulées`)) return actionsCanceledAt;
+ return actionsCreatedAt;
+ }, [activeTab, actionsCompletedAt, actionsCanceledAt, actionsCreatedAt]);
- const filteredActionsDueOrCompletedAt = actionsDueOrCompletedAt.filter((item) => !filterStatus.length || filterStatus.includes(item.status));
- const filteredConsultationsDueOrCompletedAt = consultationsDueOrCompletedAt.filter(
- (item) => !filterStatus.length || filterStatus.includes(item.status)
- );
- const filteredData = useMemo(() => {
- if (activeTab.includes('Action')) return filteredActionsDueOrCompletedAt;
- if (activeTab.includes('Consultations')) return filteredConsultationsDueOrCompletedAt;
- return [...actionsCreatedAt, ...consultationsCreatedAt];
- }, [activeTab, actionsCreatedAt, consultationsCreatedAt, filteredConsultationsDueOrCompletedAt, filteredActionsDueOrCompletedAt]);
+ const consultations = useMemo(() => {
+ if (activeTab.includes('Faites')) return consultationsCompletedAt;
+ if (activeTab.includes(`Annulées`)) return consultationsCanceledAt;
+ return consultationsCreatedAt;
+ }, [activeTab, consultationsCompletedAt, consultationsCanceledAt, consultationsCreatedAt]);
- const tabs = canSeeMedicalData
- ? [
- `Actions (${filteredActionsDueOrCompletedAt.length})`,
- `Consultations (${filteredConsultationsDueOrCompletedAt.length})`,
- `Créées (${consultationsCreatedAt.length + actionsCreatedAt.length})`,
- ]
- : [`Actions (${filteredActionsDueOrCompletedAt.length})`, `Créées (${actionsCreatedAt.length})`];
+ const data = useMemo(() => {
+ if (showActions && showConsultations) return [...actions, ...consultations];
+ if (showActions) return actions;
+ if (showConsultations) return consultations;
+ return [];
+ }, [activeTab, showActions, showConsultations, actions, consultations]);
+
+ const tabs = [
+ `Faites (${canSeeMedicalData ? actionsCompletedAt.length + consultationsCompletedAt.length : actionsCompletedAt.length})`,
+ `Annulées (${canSeeMedicalData ? actionsCanceledAt.length + consultationsCanceledAt.length : actionsCanceledAt.length})`,
+ `Créées (${canSeeMedicalData ? actionsCreatedAt.length + consultationsCreatedAt.length : actionsCreatedAt.length})`,
+ ];
return (
<>
@@ -82,17 +85,9 @@ export const ActionsOrConsultationsReport = ({
tabs={tabs}
renderTab={(caption) =>
{caption}
}
onClick={(_, index) => {
- if (index === 0) setActiveTab('Actions');
- if (index === 1) {
- if (canSeeMedicalData) {
- setActiveTab('Consultations');
- } else {
- setActiveTab('Créées');
- }
- }
- if (index === 2) {
- setActiveTab('Créées');
- }
+ if (index === 0) setActiveTab('Faites');
+ if (index === 1) setActiveTab('Annulées');
+ if (index === 2) setActiveTab('Créées');
}}
activeTabIndex={activeTabIndex}
/>
@@ -125,91 +120,37 @@ export const ActionsOrConsultationsReport = ({
-
-
-
-
-
- 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(', ')}
-
- )}
-
-
-
-
-
-
- Actions créées {formatEcheanceLabelPeriod(period)} ({actionsCreatedAt.length})
-
+
- {canSeeMedicalData && (
- <>
-
-
-
- Consultations À FAIRE/FAITE/ANNULÉE {formatEcheanceLabelPeriod(period)} ({filteredConsultationsDueOrCompletedAt.length})
-
- {filterStatus.length > 0 && (
-
- Filtrées par status:{' '}
- {mappedIdsToLabels
- .filter((s) => filterStatus.includes(s._id))
- .map((status) => status.name)
- .join(', ')}
-
- )}
-
-
-
-
-
-
- Consultations créées {formatEcheanceLabelPeriod(period)} ({consultationsCreatedAt.length})
-
-
-
-
- >
- )}
setFullScreen(false)}>
- setFullScreen(false)}>
+ setFullScreen(false)}>
-
+