Skip to content

Commit

Permalink
fix: acces to new report
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Dec 18, 2023
1 parent d171aea commit 1d4ffda
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 30 deletions.
6 changes: 5 additions & 1 deletion dashboard/src/scenes/report/components/ActionsReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ export const ActionsOrConsultations = ({ actions, consultations }) => {
const filteredData = activeTab.includes('Actions') ? filteredActions : filteredConsultations;
const history = useHistory();
const user = useRecoilValue(userState);
const tabs = ['admin', 'normal'].includes(user.role)

const canSeeMedicalData = ['admin', 'normal'].includes(user.role) && !!user.healthcareProfessional;

const tabs = canSeeMedicalData
? [`Actions (${filteredActions.length})`, `Consultations (${filteredConsultations.length})`]
: [`Actions (${filteredActions.length})`];

return (
<>
<section title={activeTab} className="tw-relative tw-flex tw-h-full tw-flex-col tw-overflow-hidden">
Expand Down
11 changes: 8 additions & 3 deletions dashboard/src/scenes/report/components/CommentsReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FullScreenIcon } from '../../../assets/icons/FullScreenIcon';
import TabsNav from '../../../components/tailwind/TabsNav';
import Table from '../../../components/table';
import ExclamationMarkButton from '../../../components/tailwind/ExclamationMarkButton';
import { organisationState } from '../../../recoil/auth';
import { organisationState, userState } from '../../../recoil/auth';
import { useRecoilValue } from 'recoil';
import UserName from '../../../components/UserName';
import TagTeam from '../../../components/TagTeam';
Expand All @@ -17,8 +17,13 @@ import DateBloc from '../../../components/DateBloc';
export const CommentsSocialAndMedical = ({ comments, commentsMedical }) => {
const [activeTab, setActiveTab] = useLocalStorage('reports-comments-toggle', 'Commentaires');
const [fullScreen, setFullScreen] = useState(false);
const data = activeTab.includes('Commentaires médicaux') ? commentsMedical : comments;
const tabs = [`Commentaires (${comments.length})`, `Commentaires médicaux (${commentsMedical.length})`];
const user = useRecoilValue(userState);
const canSeeMedicalData = ['admin', 'normal'].includes(user.role) && !!user.healthcareProfessional;

const data = canSeeMedicalData && activeTab.includes('Commentaires médicaux') ? commentsMedical : comments;
const tabs = canSeeMedicalData
? [`Commentaires (${comments.length})`, `Commentaires médicaux (${commentsMedical.length})`]
: [`Commentaires (${comments.length})`];

return (
<>
Expand Down
52 changes: 26 additions & 26 deletions dashboard/src/scenes/report/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const View = () => {
document.title = 'Mano - Admin';
};
});

const canSeeComments = ['admin', 'normal'].includes(user.role);
return (
<>
<HeaderStyled className=" !tw-py-4 tw-px-0">
Expand Down Expand Up @@ -348,42 +348,42 @@ const View = () => {
<div className="tw-mb-4 tw-h-[50vh] tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-shadow">
<ActionsOrConsultations actions={actions} consultations={consultations} />
</div>
{['admin', 'normal'].includes(user.role) && (
{canSeeComments && (
<div className="tw-h-[50vh] tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-shadow">
<CommentsSocialAndMedical comments={comments} commentsMedical={commentsMedical} />
</div>
)}
</div>
<div className="tw-mx-4 tw-mb-12 tw-basis-3/12 ">
<div className="tw-mb-4 tw-flex tw-flex-wrap tw-gap-y-4">
<div className="tw-flex tw-basis-full">
<div className="tw-basis-1/2">
<div className="tw-mr-2 tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow-2xl">
<PassagesReport passages={passages} period={period} selectedTeams={selectedTeams} />
</div>
</div>
<div className="tw-basis-1/2">
<div className="tw-ml-2 tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<RencontresReport rencontres={rencontres} period={period} selectedTeams={selectedTeams} />
</div>
<div
style={{
gridTemplateColumns: 'repeat(auto-fit, minmax(40%, 1fr))',
}}
className="tw-mb-4 tw-grid tw-gap-4">
{organisation.passagesEnabled && (
<div className="tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow-2xl">
<PassagesReport passages={passages} period={period} selectedTeams={selectedTeams} />
</div>
</div>
<div className="tw-flex tw-basis-full">
<div className="tw-basis-1/2">
<div className="tw-mr-2 tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<ObservationsReport observations={observations} period={period} selectedTeams={selectedTeams} />
</div>
)}
{organisation.rencontresEnabled && (
<div className="tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<RencontresReport rencontres={rencontres} period={period} selectedTeams={selectedTeams} />
</div>
<div className="tw-basis-1/2">
<div className="tw-ml-2 tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<PersonsReport personsCreated={personsCreated} period={period} selectedTeams={selectedTeams} />
</div>
)}
{organisation.territoriesEnabled && (
<div className="tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<ObservationsReport observations={observations} period={period} selectedTeams={selectedTeams} />
</div>
)}
<div className="tw-overflow-hidden tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-main tw-shadow">
<PersonsReport personsCreated={personsCreated} period={period} selectedTeams={selectedTeams} />
</div>
</div>
<div className="tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-gray-100 tw-shadow">
<ServicesReport selectedTeamsObject={selectedTeamsObject} period={period} />
</div>
{organisation.receptionEnabled && (
<div className="tw-rounded-lg tw-border tw-border-zinc-200 tw-bg-gray-100 tw-shadow">
<ServicesReport selectedTeamsObject={selectedTeamsObject} period={period} />
</div>
)}
</div>

<div className="tw-maxh tw-mr-2 tw-mb-12 tw-basis-3/12 tw-overflow-auto tw-rounded-lg tw-border tw-border-zinc-200 tw-shadow ">
Expand Down

0 comments on commit 1d4ffda

Please sign in to comment.