Skip to content

Commit 390010e

Browse files
committed
Refactoring and add translation
1 parent 1a9d2a4 commit 390010e

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

i18n/en/code.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,5 +1118,8 @@
11181118
},
11191119
"The server is currently unable to handle the request due to a temporary overload or maintenance of the server. Please try again later.": {
11201120
"message": "The server is currently unable to handle the request due to a temporary overload or maintenance of the server. Please try again later."
1121+
},
1122+
"Copied": {
1123+
"message": "Copied"
11211124
}
11221125
}

i18n/fr/code.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,5 +1118,8 @@
11181118
},
11191119
"The server is currently unable to handle the request due to a temporary overload or maintenance of the server. Please try again later.": {
11201120
"message": "Le serveur est actuellement incapable de traiter la requête en raison d'une surcharge temporaire ou d'une maintenance du serveur. Veuillez réessayer plus tard."
1121+
},
1122+
"Copied": {
1123+
"message": "Copié"
11211124
}
11221125
}

src/features/dashboard/components/common-table/cell-copy-text.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import { LabelPairedCopyLgRegularIcon } from '@deriv/quill-icons';
33
import { Text } from '@deriv-com/quill-ui';
4+
import Translate from '@docusaurus/Translate';
45
import styles from './cell-copy-text.module.scss';
56

67
const CopyTextCell: React.FC<{
78
cell: {
89
value: React.ReactNode;
910
};
10-
}> = ({ cell }) => {
11-
const [tooltipVisible, setTooltipVisible] = useState(false);
11+
}> = ({ cell: { value } }) => {
12+
const [tooltipVisible, setTooltipVisible] = React.useState(false);
1213

13-
const handleCopy = () => {
14-
navigator.clipboard.writeText(cell.value.toString());
14+
const handleCopy = React.useCallback(() => {
15+
navigator.clipboard.writeText(value.toString());
1516
setTooltipVisible(true);
1617
setTimeout(() => setTooltipVisible(false), 1000);
17-
};
18+
}, [value]);
1819

1920
return (
2021
<React.Fragment>
21-
{cell.value ? (
22+
{value && (
2223
<div className={styles.copyText} onClick={handleCopy}>
23-
<Text>{cell.value}</Text>
24+
<Text>{value}</Text>
2425
<span className={styles.copyTextIcon}>
2526
<LabelPairedCopyLgRegularIcon />
26-
{tooltipVisible && <div className={`${styles.tooltip} ${tooltipVisible ? styles.visible : ''}`}>Copied</div>}
27+
{tooltipVisible && (
28+
<div className={`${styles.tooltip} ${tooltipVisible ? styles.visible : ''}`}>
29+
<Translate>Copied</Translate>
30+
</div>
31+
)}
2732
</span>
2833
</div>
29-
) : ''}
34+
)}
3035
</React.Fragment>
3136
);
3237
};

0 commit comments

Comments
 (0)