mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat: add top-artists report
This commit is contained in:
parent
6a6ba493f6
commit
6fc10c40ca
18 changed files with 345 additions and 30 deletions
31
frontend/src/components/inputs/DateSelect.tsx
Normal file
31
frontend/src/components/inputs/DateSelect.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { format, parse } from "date-fns";
|
||||
import React from "react";
|
||||
|
||||
const parseDateFromDateInput = (input: string) =>
|
||||
parse(input, "yyyy-MM-dd", new Date());
|
||||
|
||||
const formatDateForDateInput = (date: Date) => format(date, "yyyy-MM-dd");
|
||||
|
||||
interface DateSelectProps {
|
||||
label: string;
|
||||
value: Date;
|
||||
onChange: (date: Date) => void;
|
||||
}
|
||||
|
||||
export const DateSelect: React.FC<DateSelectProps> = ({
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
return (
|
||||
<div>
|
||||
<label className="text-sm">{label}</label>
|
||||
<input
|
||||
className="block appearance-none min-w-full md:win-w-0 md:w-1/4 bg-white border border-gray-400 hover:border-gray-500 p-2 rounded shadow leading-tight focus:outline-none focus:shadow-outline"
|
||||
type="date"
|
||||
value={formatDateForDateInput(value)}
|
||||
onChange={(e) => onChange(parseDateFromDateInput(e.target.value))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue