diff --git a/packages/cozy-sharing/locales/en.json b/packages/cozy-sharing/locales/en.json index e6b5d45b7f..15a8b0cdde 100644 --- a/packages/cozy-sharing/locales/en.json +++ b/packages/cozy-sharing/locales/en.json @@ -26,6 +26,8 @@ "recipients": { "you": "You", "anyoneWithTheLink": "Anyone with the link", + "linkWithPassword": "Anyone with a password", + "expires": "Until %{date}", "accessCount": "%{count} people have access" }, "create-cozy": "Create |||| Create my cozy", diff --git a/packages/cozy-sharing/locales/fr.json b/packages/cozy-sharing/locales/fr.json index 01fb1aa630..3541f84ec3 100644 --- a/packages/cozy-sharing/locales/fr.json +++ b/packages/cozy-sharing/locales/fr.json @@ -26,6 +26,8 @@ "recipients": { "you": "Vous", "anyoneWithTheLink": "N'importe qui avec le lien", + "linkWithPassword": "N'importe qui avec un mot de passe", + "expires": "Jusqu'au %{date}", "accessCount": "%{count} personnes y ont accès" }, "create-cozy": "Créer |||| Créer mon Cozy", diff --git a/packages/cozy-sharing/src/components/Recipient/LinkRecipient.jsx b/packages/cozy-sharing/src/components/Recipient/LinkRecipient.jsx index 384e351318..aba4f72c75 100644 --- a/packages/cozy-sharing/src/components/Recipient/LinkRecipient.jsx +++ b/packages/cozy-sharing/src/components/Recipient/LinkRecipient.jsx @@ -14,14 +14,38 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' import LinkRecipientPermissions from './LinkRecipientPermissions' import RecipientConfirm from './RecipientConfirm' +import { + checkIsPermissionHasPassword, + getPermissionExpiresDate +} from '../../helpers/permissions' import { FADE_IN_DURATION } from '../../helpers/recipients' +import { useSharingContext } from '../../hooks/useSharingContext' import styles from '../../styles/recipient.styl' const LinkRecipient = props => { - const { t } = useI18n() + const { t, f, lang } = useI18n() const { isMobile } = useBreakpoints() + const { getDocumentPermissions } = useSharingContext() - const { recipientConfirmationData, verifyRecipient, link, fadeIn } = props + const { recipientConfirmationData, verifyRecipient, link, fadeIn, document } = + props + + const permissions = getDocumentPermissions(document._id) + const hasPassword = checkIsPermissionHasPassword(permissions) + const expiresDate = getPermissionExpiresDate(permissions) + const dateFormatted = expiresDate + ? f(expiresDate, lang === 'fr' ? 'dd/LL/yyyy' : 'LL/dd/yyyy') + : null + + const textPrimary = hasPassword + ? t('Share.recipients.linkWithPassword') + : t('Share.recipients.anyoneWithTheLink') + + const textSecondary = expiresDate + ? t('Share.recipients.expires', { + date: dateFormatted + }) + : link const RightPart = recipientConfirmationData ? ( { - {t('Share.recipients.anyoneWithTheLink')} + {textPrimary} } - secondary={link} + secondary={textSecondary} /> {RightPart}