Skip to content

Commit

Permalink
Feat/add collection dates table (#92)
Browse files Browse the repository at this point in the history
* fix collectionStartDate and add email

* wip referents

* fix useEffect and add referents in portal page

* bump version

* remove useless className and add default referents value
  • Loading branch information
RenauxLeaInsee authored Jan 5, 2024
1 parent e46e441 commit cd4c82c
Show file tree
Hide file tree
Showing 16 changed files with 410 additions and 388 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sonor",
"version": "0.5.25",
"version": "0.5.26",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
Expand Down
5 changes: 5 additions & 0 deletions src/components/CampaignPortal/CampaignPortal.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
width: 30%;
}

.ContactRow{
display: flex;
flex-direction: column;
}

.DatesLeftHeader{
width: 30%;
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/CampaignPortal/CampaignPortal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function CampaignPortal({
setIsLoading(false);
});
}
}, [survey]);
}, [survey, campaigns, dataRetreiver, location.survey]);

function handleSort(property, asc) {
const [sortedData, newSort] = Utils.handleSort(property, data, sort, 'campaignPortal', asc);
Expand Down Expand Up @@ -103,10 +103,13 @@ function CampaignPortal({
</Row>
<Row>
<Col>
<Contacts />
<Contacts
email={surveyInfo.email}
referents={surveyInfo.referents}
/>
<DatesTable
identificationPhaseStartDate={surveyInfo.identificationPhaseStartDate}
collectionstartDate={surveyInfo.collectionstartDate}
collectionStartDate={surveyInfo.collectionStartDate}
collectionEndDate={surveyInfo.collectionEndDate}
endDate={surveyInfo.endDate}
/>
Expand Down
76 changes: 59 additions & 17 deletions src/components/CampaignPortal/Contacts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Popover from 'react-bootstrap/Popover';
import D from '../../i18n';

function Contacts() {
function Contacts({email, referents}) {
const renderTooltip = (
<Popover id="popover-basic">
<Popover.Content>
{D.sendMail}
</Popover.Content>
</Popover>
);

const primaryReferents = referents?.filter((referent) => referent.role === "PRIMARY") ?? [];
const secondaryReferents = referents?.filter((referent) => referent.role === "SECONDARY") ?? [];

return (
<Card className="ViewCard">
<div>
Expand All @@ -24,26 +28,64 @@ function Contacts() {
<tr
className="Clickable"
data-testid="mail-button"
onClick={() => { window.location.assign('mailto:[email protected]'); }}
onClick={() => { window.location.assign(`mailto:${email}`); }}
>
<th className="ContactsLeftHeader">{D.functionalBox}</th>
<td className=" LightGreyLine MailLink">[email protected]</td>
<td className=" LightGreyLine MailLink" >{email}</td>
</tr>
</OverlayTrigger>
<tr>
<th rowSpan="2" className="VerticallyCentered ContactsLeftHeader">{D.cpos}</th>
<td className="LightGreyLine">Chloé Dupont</td>
</tr>
<tr>
<td className="LightGreyLine">01 01 01 01 01</td>
</tr>
<tr>
<th rowSpan="2" className="VerticallyCentered ContactsLeftHeader">{D.deputyCpos}</th>
<td className="LightGreyLine">Thierry Fabres</td>
</tr>
<tr>
<td className="LightGreyLine">02 01 01 01 01</td>
</tr>

{(referents === undefined || primaryReferents.length === 0) &&
<tr>
<th className="VerticallyCentered ContactsLeftHeader">{D.cpos}</th>
<td>{"-"}</td>
</tr>
}

{primaryReferents.map((primaryReferent) => {
return (
<tr key={primaryReferent.phoneNumber}>
<th className="VerticallyCentered ContactsLeftHeader">{D.cpos}</th>
<td className="ContactRow">
<span>
{primaryReferent.firstName || primaryReferent.lastName ?
`${primaryReferent.firstName ?? ""} ${primaryReferent.lastName ?? ""}`
: "-"
}
</span>
<span >
{primaryReferent.phoneNumber ?? "-"}
</span>
</td>
</tr>
)
})}

{(referents === undefined || secondaryReferents.length === 0) &&
<tr>
<th className="VerticallyCentered ContactsLeftHeader">{D.deputyCpos}</th>
<td>{"-"}</td>
</tr>
}

{secondaryReferents.map((secondaryReferent) => {
return (
<tr key={secondaryReferent.phoneNumber}>
<th className="VerticallyCentered ContactsLeftHeader">{D.deputyCpos}</th>
<td className="ContactRow">
<span>
{secondaryReferent.firstName || secondaryReferent.lastName ?
`${secondaryReferent.firstName ?? ""} ${secondaryReferent.lastName ?? ""}`
: "-"
}
</span>
<span >
{secondaryReferent.phoneNumber ?? "-"}
</span>
</td>
</tr>
)
})}
</tbody>
</Table>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/CampaignPortal/Dates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import D from '../../i18n';
import Utils from '../../utils/Utils';
import Table from 'react-bootstrap/Table';

export const DatesTable = ({identificationPhaseStartDate, collectionstartDate, collectionEndDate, endDate }) => {
export const DatesTable = ({identificationPhaseStartDate, collectionStartDate, collectionEndDate, endDate }) => {
return (
<Card className="ViewCard">
<Card.Title className="Title">{D.dates}</Card.Title>
Expand All @@ -16,7 +16,7 @@ export const DatesTable = ({identificationPhaseStartDate, collectionstartDate, c
</tr>
<tr>
<th className="DatesLeftHeader">{D.collectionStartDate}</th>
<td className="LightGreyLine VerticallyCentered">{collectionstartDate && Utils.convertToDateString(collectionstartDate)}</td>
<td className="LightGreyLine VerticallyCentered">{collectionStartDate && Utils.convertToDateString(collectionStartDate)}</td>
</tr>
<tr>
<th className="DatesLeftHeader">{D.collectionEndDate}</th>
Expand Down
4 changes: 2 additions & 2 deletions src/components/CampaignPortal/Dates.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("dates component", () => {
render(
<DatesTable
identificationPhaseStartDate={1578907245000}
collectionstartDate={1609492845000}
collectionStartDate={1609492845000}
collectionEndDate={1698706800000}
endDate={1706655600000}
/>
Expand All @@ -27,7 +27,7 @@ describe("dates component", () => {
render(
<DatesTable
identificationPhaseStartDate={1578907245000}
collectionstartDate={1609492845000}
collectionStartDate={1609492845000}
collectionEndDate={1698706800000}
endDate={1706655600000}
/>
Expand Down
Loading

0 comments on commit cd4c82c

Please sign in to comment.