Skip to content

Commit

Permalink
Develop (#94)
Browse files Browse the repository at this point in the history
* Fix/buggy address and open terminated su questionnaire (#83)

* fix: provide questionnaireId in queen URL
fix : handle buggy address

* fix: handle missing departement for export

* fix: unnecessary script option

* fix: update test

* Issue contact (#86)

* terminatedTable

* add contactOutcome & update snapshop

* bump version

* rollback version

* fix pr review

* delete import

* fix size column

* test: update snapshots

* bump version

---------

Co-authored-by: Simon Demazière <[email protected]>

* chore: sonar configuration (#88)

* ci: coverage for sonar and exclusions

* ci: fix sonar conf

* ci: fix sonar conf for coverage

* add collection dates table in CampaignPortal (#91)

* add collection dates table in CampaignPortal

* rework test

* bump version

---------

Co-authored-by: Nicolas Turban <[email protected]>

* fix checkAll on ReviewTable (#90)

* fix checkAll on ReviewTable

* fix checkAll on CloseSUTable

* bump version

* fix package

* fix snapshots

* fix modalPreferences

* test: correct failing test

* review changes

* use NCO and some function

* fix tests

* bump version

---------

Co-authored-by: Grafikart <[email protected]>
Co-authored-by: Simon Demazière <[email protected]>

* components refactoring (#93)

* components refactoring

* remove useless rerender in CampaignPortal

* rework interviewer condition

* review (rename state and rework functions)

* bump version

* Feat/add collection dates table (#92)

* 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

* add reminders and outcome data in ListSU (#95)

* add reminders and outcome data in ListSU

* remove useless traduction

* rework functions to get reminders

* refacto SUTable component

* rework SUTableHeader component

* bump version

* add contactOutcome column

* Update package.json

* fix contactOutcome type (#97)

* fix contactOutcome type

* Update package.json

* add contact outcome type sorter

* reorder types

* Update package.json

* fix sort when contactOutcome is undefined

* Update package.json

* fix utils (#100)

* fix utils

* change condition

* Update package.json

---------

Co-authored-by: MickaelMenet <[email protected]>
Co-authored-by: RenauxLeaInsee <[email protected]>
Co-authored-by: Nicolas Turban <[email protected]>
Co-authored-by: Grafikart <[email protected]>
Co-authored-by: Lea Renaux <[email protected]>
  • Loading branch information
6 people authored Feb 5, 2024
1 parent 2517c9d commit a20b623
Show file tree
Hide file tree
Showing 57 changed files with 7,282 additions and 5,501 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.22",
"version": "0.5.32",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
Expand Down
3 changes: 2 additions & 1 deletion src/components/App/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ const updatePreferences = jest.fn((newPrefs, cb) => {

DataFormatter.mockImplementation(() => ({
getPreferences: (c) => (c(preferences)),
getAllCampaigns: (c) => (c(mainScreenData)),
getQuestionnaireId: (id, c) => (c({ questionnaireId: 'QXT55' })),
getDataForMainScreen: (a, c) => {
getFormattedCampaignsForMainScreen: (a, c) => {
if (c) { c(mainScreenData); }
return Promise.resolve(mainScreenData);
},
Expand Down
9 changes: 9 additions & 0 deletions src/components/CampaignPortal/CampaignPortal.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
width: 30%;
}

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

.DatesLeftHeader{
width: 30%;
}

/* Column sizes */

#CampaignPortal .ColInterviewerName{
Expand Down
27 changes: 17 additions & 10 deletions src/components/CampaignPortal/CampaignPortal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Utils from '../../utils/Utils';
import TimeLine from './TimeLine';
import { DatesTable } from './Dates'
import Contacts from './Contacts';
import SurveyUnits from './SurveyUnits';
import SurveySelector from '../SurveySelector/SurveySelector';
import D from '../../i18n';
import './CampaignPortal.css';

function CampaignPortal({
location, dataRetreiver,
location, dataRetreiver, campaigns
}) {
const initialData = {};
initialData.interviewers = [];
Expand All @@ -38,17 +39,14 @@ function CampaignPortal({

useEffect(() => {
if (!survey && location.survey) {
dataRetreiver.getDataForMainScreen(null, (campaignsData) => {
dataRetreiver.getFormattedCampaignsForMainScreen(null, (campaignsData) => {
const newSurvey = campaignsData.find((s) => s.id === location.survey.id);
newSurvey.allSurveys = campaignsData;
setSurvey(newSurvey);
setSurveyInfo(campaignsData.find((s) => s.id === location.survey.id));
setSurvey({...newSurvey, allSurveys : campaignsData});
setSurveyInfo(newSurvey);
setRedirect(null);
});
}, campaigns);
}
}, [redirect, dataRetreiver, location, survey]);

useEffect(() => {
if (survey) {
setIsLoading(true);
dataRetreiver.getDataForCampaignPortal(!survey || survey.id, (res) => {
Expand All @@ -57,7 +55,7 @@ function CampaignPortal({
setIsLoading(false);
});
}
}, [redirect, dataRetreiver, location, survey]);
}, [survey, campaigns, dataRetreiver, location.survey]);

function handleSort(property, asc) {
const [sortedData, newSort] = Utils.handleSort(property, data, sort, 'campaignPortal', asc);
Expand Down Expand Up @@ -105,7 +103,16 @@ function CampaignPortal({
</Row>
<Row>
<Col>
<Contacts />
<Contacts
email={surveyInfo.email}
referents={surveyInfo.referents}
/>
<DatesTable
identificationPhaseStartDate={surveyInfo.identificationPhaseStartDate}
collectionStartDate={surveyInfo.collectionStartDate}
collectionEndDate={surveyInfo.collectionEndDate}
endDate={surveyInfo.endDate}
/>
</Col>
<Col>
<SurveyUnits
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
34 changes: 34 additions & 0 deletions src/components/CampaignPortal/Dates.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import Card from 'react-bootstrap/Card';
import D from '../../i18n';
import Utils from '../../utils/Utils';
import Table from 'react-bootstrap/Table';

export const DatesTable = ({identificationPhaseStartDate, collectionStartDate, collectionEndDate, endDate }) => {
return (
<Card className="ViewCard">
<Card.Title className="Title">{D.dates}</Card.Title>
<Table className="CustomTable" bordered striped responsive size="sm">
<tbody>
<tr>
<th className="DatesLeftHeader">{D.identificationPhaseStartDate}</th>
<td className="LightGreyLine VerticallyCentered">{identificationPhaseStartDate && Utils.convertToDateString(identificationPhaseStartDate)}</td>
</tr>
<tr>
<th className="DatesLeftHeader">{D.collectionStartDate}</th>
<td className="LightGreyLine VerticallyCentered">{collectionStartDate && Utils.convertToDateString(collectionStartDate)}</td>
</tr>
<tr>
<th className="DatesLeftHeader">{D.collectionEndDate}</th>
<td className="LightGreyLine VerticallyCentered">{collectionEndDate && Utils.convertToDateString(collectionEndDate)}</td>
</tr>
<tr>
<th className="DatesLeftHeader">{D.endDate}</th>
<td className="LightGreyLine VerticallyCentered">{endDate && Utils.convertToDateString(endDate)}</td>
</tr>
</tbody>
</Table>
</Card>

)
}
42 changes: 42 additions & 0 deletions src/components/CampaignPortal/Dates.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { DatesTable } from "./Dates";
import { render, screen } from '@testing-library/react';
import Utils from '../../utils/Utils';

describe("dates component", () => {
it("should display all labels", () => {
render(
<DatesTable
identificationPhaseStartDate={1578907245000}
collectionStartDate={1609492845000}
collectionEndDate={1698706800000}
endDate={1706655600000}
/>

);

expect(screen.getByText("Dates")).toBeInTheDocument();
expect(screen.getByText("Start of identification phase")).toBeInTheDocument();
expect(screen.getByText("Collection start date")).toBeInTheDocument();
expect(screen.getByText("Collection end date")).toBeInTheDocument();
expect(screen.getByText("Processing end date")).toBeInTheDocument();

})

it("should display all formated dates", () => {
render(
<DatesTable
identificationPhaseStartDate={1578907245000}
collectionStartDate={1609492845000}
collectionEndDate={1698706800000}
endDate={1706655600000}
/>

);

expect(screen.getByText(Utils.convertToDateString(1578907245000))).toBeInTheDocument();
expect(screen.getByText(Utils.convertToDateString(1609492845000))).toBeInTheDocument();
expect(screen.getByText(Utils.convertToDateString(1698706800000))).toBeInTheDocument();
expect(screen.getByText(Utils.convertToDateString(1706655600000))).toBeInTheDocument();
})
})
Loading

0 comments on commit a20b623

Please sign in to comment.