migration vers typescript + refonte total de l'app

This commit is contained in:
Sonny
2022-04-28 04:30:38 +02:00
parent 1e79072626
commit 1ab51979fe
32 changed files with 2737 additions and 7815 deletions

52
components/selector.tsx Normal file
View File

@@ -0,0 +1,52 @@
import { MutableRefObject, useState } from "react";
interface SelectorProps {
name: string;
label?: string;
labelComponent?: JSX.Element;
innerRef?: MutableRefObject<any>;
fieldClass?: string;
value?: string | number;
onChangeCallback: ({ target }, value) => void;
children?: any;
}
export default function Selector({
name,
label,
labelComponent,
innerRef = null,
fieldClass = '',
value,
onChangeCallback,
children
}: SelectorProps): JSX.Element {
const [inputValue, setInputValue] = useState<string | number>(value);
function onChange({ target }) {
setInputValue(target.value);
onChangeCallback({ target }, target.value);
}
return (<div className={`input-field ${fieldClass}`}>
{label && (
<label htmlFor={name} title={`${name} field`}>
{label}
</label>
)}
{!!labelComponent && (
<label htmlFor={name} title={`${name} field`}>
{labelComponent}
</label>
)}
<select
id={name}
name={name}
onChange={onChange}
value={inputValue}
ref={innerRef}
>
{children}
</select>
</div>);
}