Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helpers to generate paper expiration date message #1468

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

zatteo
Copy link
Contributor

@zatteo zatteo commented Apr 24, 2024

Following the work done here #1452 to mutualize logic for paper formatting, we mutualize logic for paper expiration date message like 'Expired' or 'Expires in 10 days'.

We will use these helpers in :

Copy link
Contributor

@JF-Cozy JF-Cozy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'aurai appelé ça makeXxx plutôt que computeXxx qu'on utilise plutôt pour calculer des valeurs ou manipuler des tableaux. Ca sous-entend un peu de calcul qu'il faut potentiellement memo, ce qui n'est pas tellement le cas ici.

@@ -435,3 +437,46 @@ export const formatContactValue = contacts => {
? contacts.map(contact => `${getDisplayName(contact)}`).join(', ')
: ''
}

/**
* @param {Object} options - Options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What could we do without you, jsdoc

const t = getLocalizer(lang)

const distance = formatDistanceToNowStrict(new Date(expirationDate), {
locale: lang === 'fr' ? fr : undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the locale is undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a comment to explain it. It fallbacks to english by default.

@zatteo zatteo force-pushed the feat/migrate-expiration-data branch from f465dc8 to 2692c73 Compare April 24, 2024 12:46
@zatteo zatteo merged commit b3a5a30 into master Apr 24, 2024
4 checks passed
@zatteo zatteo deleted the feat/migrate-expiration-data branch April 24, 2024 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants