Skip to content

Commit 9b20529

Browse files
authored
Merge pull request #68 from cph-cachet/feature/fix-issues
Fix issues
2 parents d707ae7 + 693b18c commit 9b20529

File tree

12 files changed

+137
-23
lines changed

12 files changed

+137
-23
lines changed

src/assets/languageMap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type LanguageLabelsMapping = {
3939
export const languageLabels: LanguageLabelsMapping = {
4040
BG: { primary: "Bulgarian", secondary: "bg" },
4141
HR: { primary: "Croatian", secondary: "hr" },
42-
CZ: { primary: "Czech", secondary: "cs" },
42+
CZ: { primary: "Czech", secondary: "cz" },
4343
DK: { primary: "Danish", secondary: "da" },
4444
NL: { primary: "Dutch", secondary: "nl" },
4545
GB: { primary: "English", secondary: "en" },

src/pages/Deployment/InformedConsentCard/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const InformedConsentCard = () => {
144144
<DownloadButton onClick={() => downloadPdf(consent)}>
145145
<FileDownloadOutlinedIcon />
146146
<Typography variant="h6">
147-
{t("common:export_data")}
147+
{t("common:download_pdf")}
148148
</Typography>
149149
</DownloadButton>
150150
</Right>

src/pages/Deployments/DeploymentCard/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-underscore-dangle */
22
import CopyButton from "@Components/Buttons/CopyButton";
3-
import { ParticipantGroup } from "@carp-dk/client";
3+
import { ParticipantGroup } from "@carp-dk/client/models/ParticipantGroups";
44
import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
55
import { Skeleton, Typography } from "@mui/material";
66
import { useEffect, useMemo, useState } from "react";
@@ -79,7 +79,11 @@ const DeploymentCard = ({
7979
)
8080
}
8181
>
82-
{names && names[0].length > 0 ? names : <i>Generated deployment</i>}
82+
{!deployment.participants.every((p) => p.email == null) ? (
83+
names
84+
) : (
85+
<i>Generated deployment</i>
86+
)}
8387
</Names>
8488
<StyledDivider />
8589
<HorizontalStatusContainer>

src/pages/Export/ExportsTable/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ExportsTable = memo(({ exports, exportsLoading }: Props) => {
5353
},
5454
{
5555
accessorKey: "download",
56-
header: "Export",
56+
header: "Download",
5757
Cell: DownloadButton,
5858
enableSorting: false,
5959
size: 100,

src/pages/Participant/InformedConsent/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const InformedConsent = () => {
114114
<>
115115
<StyledDivider />
116116
<DownloadButton onClick={() => downloadPdf()}>
117-
<Typography variant="h6">Export</Typography>
117+
<Typography variant="h6">Download PDF</Typography>
118118
<FileDownloadOutlinedIcon fontSize="small" />
119119
</DownloadButton>
120120
</>

src/pages/Participants/ParticipantsTable/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
useParticipantsAccounts,
55
} from "@Utils/queries/participants";
66
import { useStudyDetails } from "@Utils/queries/studies";
7-
import { formatDate } from "@Utils/utility";
7+
import { formatDateTime } from "@Utils/utility";
88
import carpStudies from "@cachet/carp-studies-core";
99
import { ParticipantAccount } from "@carp-dk/client";
1010
import AddRoundedIcon from "@mui/icons-material/AddRounded";
@@ -90,7 +90,11 @@ const ParticipantsTable = ({
9090
if (deployment) {
9191
return (
9292
<Typography variant="h5">
93-
{formatDate(deployment.invitedOn.toEpochMilliseconds())}
93+
{formatDateTime(deployment.invitedOn.toEpochMilliseconds(), {
94+
year: "numeric",
95+
month: "short",
96+
day: "numeric",
97+
})}
9498
</Typography>
9599
);
96100
}

src/pages/StudyOverview/Overview/DeploymentStatus/TooltipContent/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const TooltipContent = () => {
1414
</Typography>
1515
<Typography variant="h5">
1616
<span style={{ color: getDeploymentStatusColor("DeployingDevices") }}>
17-
Deploying Devices
17+
Deploying
1818
</span>
1919
: Participants have started registering devices, but are remaining
2020
devices.

src/pages/StudyOverview/Overview/DeploymentStatus/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const DeploymentStatus = () => {
6666
deploying: {
6767
id: 1,
6868
value: 0,
69-
label: "Deploying Devices",
69+
label: "Deploying",
7070
color: getDeploymentStatusColor("DeployingDevices"),
7171
},
7272
running: {

src/pages/StudySettings/StudyData/index.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import LinkIcon from "@mui/icons-material/Link";
1818
import { useFormik } from "formik";
1919
import { useNavigate, useParams } from "react-router";
2020
import * as yup from "yup";
21+
import { formatDateTime } from "@Utils/utility";
2122
import StudySetupSkeleton from "../StudySetupSkeleton";
2223
import {
2324
Heading,
@@ -175,7 +176,17 @@ const StudyData = () => {
175176
key={protocol.id.stringRepresentation}
176177
value={protocol.id.stringRepresentation}
177178
>
178-
{protocol.name}
179+
<Stack
180+
width="100%"
181+
direction="row"
182+
alignItems="center"
183+
justifyContent="space-between"
184+
>
185+
<Typography>{protocol.name}</Typography>
186+
<Typography variant="caption">
187+
{formatDateTime(protocol.createdOn.toEpochMilliseconds())}
188+
</Typography>
189+
</Stack>
179190
</MenuItem>
180191
))}
181192
</Select>

src/pages/Translation/AddTranslationModal/index.tsx

+104-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1+
/* eslint-disable react/jsx-props-no-spreading */
12
import { languageLabels } from "@Assets/languageMap";
23
import DragAndDrop from "@Components/DragAndDrop";
3-
import { FormLabel, Modal } from "@mui/material";
4+
import {
5+
Autocomplete,
6+
FormLabel,
7+
InputAdornment,
8+
MenuItem,
9+
Modal,
10+
Stack,
11+
TextField,
12+
} from "@mui/material";
413
import { useCreateTranslation } from "@Utils/queries/studies";
514
import { useFormik } from "formik";
615
import { useEffect, useState } from "react";
7-
import ReactFlagsSelect from "react-flags-select";
816
import { useParams } from "react-router-dom";
917
import * as yup from "yup";
18+
import * as flags from "react-flags-select";
1019
import {
1120
CancelButton,
1221
DoneButton,
@@ -121,14 +130,99 @@ const AddTranslationModal = ({ open, onClose }: Props) => {
121130
</ModalDescription>
122131
<ModalContainer>
123132
<ModalContent>
124-
<FormLabel required>Language</FormLabel>
125-
<ReactFlagsSelect
126-
countries={[...Object.keys(languageLabels)]}
127-
customLabels={languageLabels}
128-
placeholder="Select Language"
129-
selected={formik.values.language}
130-
// eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/no-unsafe-member-access
131-
onSelect={(code) => formik.setFieldValue("language", code)}
133+
<FormLabel id="languageLabel" required>
134+
Language
135+
</FormLabel>
136+
<Autocomplete
137+
options={Object.keys(languageLabels)}
138+
value={formik.values.language || null}
139+
onChange={(_, newValue) => {
140+
formik.setFieldValue("language", newValue);
141+
}}
142+
filterOptions={(options, params) => {
143+
return options.filter((option) =>
144+
languageLabels[option].primary
145+
.toLowerCase()
146+
.includes(params.inputValue.toLowerCase()),
147+
);
148+
}}
149+
onBlur={formik.handleBlur}
150+
fullWidth
151+
getOptionLabel={(option) =>
152+
`${languageLabels[option].primary} ${
153+
languageLabels[option].secondary
154+
}`
155+
}
156+
renderInput={(params) => {
157+
if (!formik.values.language) {
158+
return (
159+
<TextField
160+
{...params}
161+
placeholder="Select Language"
162+
size="small"
163+
/>
164+
);
165+
}
166+
const countryCode =
167+
formik.values.language[0].toUpperCase() +
168+
formik.values.language[1].toLowerCase();
169+
let CountryFlag;
170+
if (countryCode in flags) {
171+
CountryFlag = flags[countryCode];
172+
} else {
173+
CountryFlag = "div";
174+
}
175+
return (
176+
<TextField
177+
{...params}
178+
placeholder="Select Language"
179+
size="small"
180+
// eslint-disable-next-line react/no-unstable-nested-components
181+
InputProps={{
182+
...params.InputProps,
183+
startAdornment: (
184+
<InputAdornment
185+
position="start"
186+
sx={{ marginRight: 0 }}
187+
>
188+
<CountryFlag
189+
name={formik.values.language}
190+
selected=""
191+
onSelect={undefined}
192+
width={25}
193+
style={{ marginLeft: "10px" }}
194+
/>
195+
</InputAdornment>
196+
),
197+
}}
198+
/>
199+
);
200+
}}
201+
renderOption={(props, option) => {
202+
// eslint-disable-next-line react/prop-types
203+
const { key, ...optionProps } = props;
204+
const countryCode =
205+
option[0].toUpperCase() + option[1].toLowerCase();
206+
let CountryFlag;
207+
if (countryCode in flags) {
208+
CountryFlag = flags[countryCode];
209+
} else {
210+
CountryFlag = "div";
211+
}
212+
return (
213+
<MenuItem key={key} {...optionProps}>
214+
<Stack direction="row" alignItems="center" gap={1}>
215+
<CountryFlag
216+
name={option}
217+
selected=""
218+
onSelect={undefined}
219+
width={30}
220+
/>
221+
{languageLabels[option].primary}
222+
</Stack>
223+
</MenuItem>
224+
);
225+
}}
132226
/>
133227
<FormLabel required>Upload Translation File</FormLabel>
134228
<DragAndDrop

src/public/locales/en/common.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"last_data_zero": "Last data: Today",
1313
"last_data_one": "Last data: {{count}} day ago",
1414
"last_data_other": "Last data: {{count}} days ago",
15-
"participant_id": "Participant ID: {{participantId}}"
15+
"participant_id": "Participant ID: {{participantId}}",
16+
"download_pdf": "Download PDF"
1617
}

src/utils/utility.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const formatDateTime = (
6868
},
6969
) => {
7070
const date = new Date(dateString);
71-
return `${date.toLocaleString("en-GB", options)}`;
71+
return `${date.toLocaleString("en-US", options)}`;
7272
};
7373

7474
export const formatDate = (dateString: number | string) => {

0 commit comments

Comments
 (0)