Skip to content

Commit

Permalink
feat: all surveys in mySurveys
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDmz committed Apr 13, 2024
1 parent 29e087b commit 6a08d06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pearl",
"version": "2.0.5",
"version": "2.0.6",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/trackingMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const trackingMessage = {
en: 'To access the details, click on a campaign',
},
trackingSelect: { fr: 'Sélectionnez...', en: 'Select...' },
trackingToggleAria: {
fr: 'Choisissez de voir une/toutes les enquêtes',
en: 'Choose one/all survey to view',
},
trackingSelectCampaign: {
fr: 'Sélectionnez une enquête dans la liste déroulante ci-dessus.',
en: 'Select a campaign from the drop-down list above.',
Expand Down
25 changes: 4 additions & 21 deletions src/pages/SuiviPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ export function SuiviPage() {
setSearchText(event.target.value);
};

const resetCampaignSelection = () => {
setCampaign('');
setTab('stats');
};
return (
<Box m={2}>
<Card elevation={2}>
Expand All @@ -96,7 +92,7 @@ export function SuiviPage() {
options={campaigns}
/>
{campaign && (
<IconButton aria-label="reset" onClick={resetCampaignSelection}>
<IconButton aria-label="reset" onClick={() => setCampaign('')}>
<RestartAltIcon />
</IconButton>
)}
Expand All @@ -121,7 +117,7 @@ export function SuiviPage() {
<Tabs
value={tab}
onChange={(_, tab) => setTab(tab)}
aria-label="Choose one/all survey to view"
aria-label={D.trackingToggleAria}
textColor="secondary"
>
<Tab label={D.allSurveys} value="stats" />
Expand Down Expand Up @@ -247,20 +243,6 @@ function SuiviTable({ surveyUnits, campaign, searchText }) {
setSortConfig({ key, direction });
};
const maxHeight = 'calc(100vh - 230px)';
if (!campaign) {
return (
<Row
borderRadius={4}
justifyContent="center"
bgcolor="surfacePrimary.main"
sx={{ height: maxHeight }}
>
<Typography variant="m" color="textHint">
{D.trackingSelectCampaign}
</Typography>
</Row>
);
}
const compareValues = (a, b, isAscending) => {
if (a < b) return isAscending ? -1 : 1;
if (a > b) return isAscending ? 1 : -1;
Expand Down Expand Up @@ -291,8 +273,9 @@ function SuiviTable({ surveyUnits, campaign, searchText }) {
const filteredSurveyUnits = surveyUnits
.filter(su => {
const person = getprivilegedPerson(su);
const filteredByCampaign = campaign === '' || su.campaign === campaign;
return (
su.campaign === campaign &&
filteredByCampaign &&
(searchText === '' ||
person.lastName.toUpperCase().includes(searchText.toUpperCase()) ||
person.firstName.toUpperCase().includes(searchText.toUpperCase()))
Expand Down

0 comments on commit 6a08d06

Please sign in to comment.