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

fix: open correct month for newsletter editing

parent 78e0e525
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
......@@ -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