Finished Hub ESLINT rule enforcement

This commit is contained in:
PxlLoewe
2025-07-09 23:26:09 -07:00
parent 98ed0cb5ca
commit eec72a51b8
26 changed files with 199 additions and 195 deletions

View File

@@ -15,7 +15,7 @@ export const Button = ({
return (
<button
{...(props as any)}
{...props}
className={cn("btn", props.className)}
disabled={isLoadingState || props.disabled}
onClick={async (e) => {
@@ -27,7 +27,7 @@ export const Button = ({
}}
>
{isLoadingState && <span className="loading loading-spinner loading-sm"></span>}
{props.children as any}
{props.children}
</button>
);
};

View File

@@ -1,32 +1,24 @@
import DatePicker, { DatePickerProps, registerLocale } from "react-datepicker";
import { Control, Controller, FieldValues, Path } from "react-hook-form";
import { de } from "date-fns/locale";
registerLocale("de", de);
import { formatDate } from "date-fns";
interface DateInputProps<T extends FieldValues>
extends Omit<DatePickerProps, "onChange" | "selected"> {
control: Control<T>;
name: Path<T>;
}
export const DateInput = <T extends FieldValues>({
control,
name,
export const DateInput = ({
value,
onChange,
...props
}: DateInputProps<T>) => {
}: Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> & {
value?: Date | null;
onChange?: (date: Date) => void;
}) => {
return (
<Controller
control={control}
name={name}
render={({ field }) => (
<DatePicker
className="input input-bordered mt-2"
locale={"de"}
onChange={(date) => field.onChange(date)}
selected={field.value}
{...props}
/>
)}
<input
type="datetime-local"
className="input"
value={formatDate(value || new Date(), "yyyy-MM-dd hh:mm")}
onChange={(e) => {
const date = e.target.value ? new Date(e.target.value) : null;
if (!date) return;
onChange?.(date);
}}
{...props}
/>
);
};