mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-22 10:51:46 +03:00
1d7bc8a5bc
* remove duplicate import * 🚧 add new linter configuration * 🧑💻 add and run prettier * 🐛 add babel parser for linter * 🧑💻 add lint-fix command * 🚨 use lint-fix * 🚨 remove 'FC' as a type. Use const and JSX.Element * 🚨 enforce arrow function rule from linter * 🔥 delete unused file * 🚨 adding /* eslint-disable */ in failing files * 💩 add ts-expect-error to Victory components
24 lines
587 B
TypeScript
24 lines
587 B
TypeScript
import { HTMLAttributes } from "react";
|
|
|
|
import { UserStats } from "../../../lib/types/User";
|
|
|
|
interface DateComponentProps extends HTMLAttributes<HTMLSpanElement> {
|
|
date: UserStats["date"];
|
|
}
|
|
|
|
export const DateComponent = ({
|
|
date,
|
|
...props
|
|
}: DateComponentProps): JSX.Element => {
|
|
// Extract year, month, and day from the date string
|
|
const year = date.slice(0, 4);
|
|
const month = date.slice(4, 6);
|
|
const day = date.slice(6, 8);
|
|
|
|
const formattedDate = new Date(
|
|
`${year}-${month}-${day}`
|
|
).toLocaleDateString();
|
|
|
|
return <span {...props}>{formattedDate}</span>;
|
|
};
|