Skip to content

Commit 30c833b

Browse files
authored
Edit file upload appearance (#531)
1 parent 73c2c63 commit 30c833b

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

frontend/src/components/Files/Files.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import AddIcon from '@material-ui/icons/Add';
77
import CloseIcon from '@material-ui/icons/Close';
88

99
import { useTranslations } from '../../hooks/useTranslations';
10+
import { formatDate } from '../../utils/date';
1011

1112
const Files = ({
1213
title,
@@ -17,7 +18,7 @@ const Files = ({
1718
handleUpload,
1819
isDisabled = false,
1920
}) => {
20-
const translations = useTranslations()[0];
21+
const [translations, selectedLang] = useTranslations();
2122

2223
const getDeleteFileButton = (file) => {
2324
if (isDisabled) return null;
@@ -47,12 +48,16 @@ const Files = ({
4748
>
4849
<div className="file-info-wrapper">
4950
<ArrowDownwardIcon />
50-
<div>
51+
<div
52+
className={
53+
isDisabled ? `file-info-view` : `file-info-edit`
54+
}
55+
>
5156
<Typography align="left">
5257
{`${file.filename}`}
5358
</Typography>
5459
<p id="file-upload-timestamp">
55-
{file.uploadDate.toString()}
60+
{formatDate(file.uploadDate, selectedLang)}
5661
</p>
5762
</div>
5863
</div>

frontend/src/components/Files/Files.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,34 @@
2828
.file-row-wrapper {
2929
display: inherit;
3030
justify-content: space-between;
31+
align-items: center;
3132
width: 100%;
3233
}
3334

3435
.file-button {
3536
justify-content: flex-start;
3637
width: 100%;
38+
overflow: hidden;
3739
}
3840

3941
.file-info-wrapper {
4042
display: flex;
4143
flex-direction: row;
44+
display: inherit;
45+
46+
.file-info-edit {
47+
width: 315px;
48+
}
49+
50+
.file-info-view {
51+
width: 350px;
52+
padding-right: 0.4em;
53+
}
54+
4255
#file-upload-timestamp {
4356
line-height: 0;
57+
margin-top: 0.3em;
58+
text-align-last: end;
4459
color: grey;
4560
}
4661
}

frontend/src/utils/date.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { LANGUAGES } from './constants';
99
export const formatDate = (date, language) => {
1010
if (date == null) return 'Undefined';
1111

12+
let parsedDate = date;
13+
if (!(typeof date === 'object' || date instanceof Object))
14+
parsedDate = new Date(date);
15+
1216
let locale = 'ar-SA';
1317
if (language === LANGUAGES.EN) locale = 'en-US';
1418

@@ -20,5 +24,5 @@ export const formatDate = (date, language) => {
2024
minute: '2-digit',
2125
};
2226

23-
return date.toLocaleDateString(locale, options);
27+
return parsedDate.toLocaleDateString(locale, options);
2428
};

0 commit comments

Comments
 (0)