Skip to content
Snippets Groups Projects
Commit fef48001 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

Merge branch...

Merge branch '18-ouverture-automatique-du-backoffice-sur-le-mois-d-edition-de-la-lettre-mensuelle-tant-que-lettre' into 'dev'

fix: open correct month for newsletter editing

See merge request !103
parents 78e0e525 8977f6f1
No related branches found
No related tags found
2 merge requests!105Fix: open correct month for newsletter editing,!103fix: open correct month for newsletter editing
Pipeline #62128 passed
......@@ -30,14 +30,18 @@ export type ContentItems =
| ''
const Newsletter: React.FC = () => {
// Functional rule :
// Display next month after the 3rd of the current month
/**
* Display previous month until the newsletter is sent on the 3rd day of the month
*/
const getCurrentNewsletterDate = (): Date => {
const newsletterDate = new Date()
if (newsletterDate.getDate() >= 3) {
newsletterDate.setMonth(newsletterDate.getMonth() + 1)
}
return newsletterDate
const today = new Date()
const currentDay = today.getDate()
const currentMonth = today.getMonth()
const currentYear = today.getFullYear()
return currentDay < 3
? new Date(currentYear, currentMonth, 1)
: new Date(currentYear, currentMonth + 1, 1)
}
const [date, setDate] = useState<Date>(getCurrentNewsletterDate())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment