-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/sections/account/ApiTokenSection/ApiTokenSection.module.scss
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/sections/account/api-token-section/ApiTokenSection.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module'; | ||
|
||
.exp-date { | ||
display: flex; | ||
gap: 1.5rem; | ||
align-items: center; | ||
padding-left: 0.5rem; | ||
font-weight: bold; | ||
|
||
time { | ||
font-weight: normal; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
gap: 3rem; | ||
} | ||
} | ||
|
||
.api-token { | ||
padding: 0.5rem 1rem; | ||
background-color: #f7f7f9; | ||
border: solid 1px $dv-border-color; | ||
border-radius: 4px; | ||
} | ||
|
||
.btns-wrapper { | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
padding-top: 1rem; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/sections/account/api-token-section/ApiTokenSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Trans, useTranslation } from 'react-i18next' | ||
import accountStyles from '../Account.module.scss' | ||
import styles from './ApiTokenSection.module.scss' | ||
import { Button } from '@iqss/dataverse-design-system' | ||
|
||
export const ApiTokenSection = () => { | ||
const { t } = useTranslation('account', { keyPrefix: 'apiToken' }) | ||
|
||
const apiToken = '999fff-666rrr-12kfd54-123123' | ||
const expirationDate = '2025-09-04' | ||
|
||
const copyToClipboard = () => { | ||
navigator.clipboard.writeText(apiToken).catch((error) => { | ||
console.error('Failed to copy text:', error) | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<p className={accountStyles['helper-text']}> | ||
<Trans | ||
t={t} | ||
i18nKey="helperText" | ||
components={{ | ||
anchor: ( | ||
<a | ||
href="http://guides.dataverse.org/en/latest/api" | ||
target="_blank" | ||
rel="noreferrer" | ||
/> | ||
) | ||
}} | ||
/> | ||
</p> | ||
<p className={styles['exp-date']}> | ||
{t('expirationDate')} <time dateTime={expirationDate}>{expirationDate}</time> | ||
</p> | ||
<div className={styles['api-token']}> | ||
<code>{apiToken}</code> | ||
</div> | ||
<div className={styles['btns-wrapper']} role="group"> | ||
<Button variant="secondary" onClick={copyToClipboard}> | ||
{t('copyToClipboard')} | ||
</Button> | ||
<Button variant="secondary">{t('recreateToken')}</Button> | ||
<Button variant="secondary">{t('revokeToken')}</Button> | ||
</div> | ||
</> | ||
) | ||
} |