diff --git a/src/App.tsx b/src/App.tsx index 1fa3fe2..e366641 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,6 +38,11 @@ function App() { result.push(item) return result }, []) + .sort((a, b) => { + if (b.birthday < a.birthday) return 1 + if (b.birthday > a.birthday) return -1 + return 0 + }) return birthdays } diff --git a/src/components/BirthdayList.tsx b/src/components/BirthdayList.tsx index b9ed4cc..be84b85 100644 --- a/src/components/BirthdayList.tsx +++ b/src/components/BirthdayList.tsx @@ -1,5 +1,6 @@ -import {FC} from "react"; +import {FC, ReactNode} from "react"; import {Birthday} from "../types.ts"; +import {MONTHS} from "../utilities.ts"; const BirthdayList: FC = ({birthdays, selectedPerson, selectPerson}) => { @@ -9,26 +10,32 @@ const BirthdayList: FC = ({birthdays, selectedPerson, selectP } return } diff --git a/src/utilities.ts b/src/utilities.ts index 04e3490..bc65b01 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -9,3 +9,5 @@ export const arrayRange = (end: number, start = 0) => { export const pad = (number: number, pad = 2, char = '0') => { return (new Array(pad).join(char) + number).slice(-pad) } + +export const MONTHS = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] \ No newline at end of file