|
@@ -1,7 +1,26 @@
|
|
|
import React, { FC } from "react";
|
|
import React, { FC } from "react";
|
|
|
|
|
|
|
|
-const Select: FC = () => {
|
|
|
|
|
- return <select id="" name=""></select>;
|
|
|
|
|
|
|
+interface selectProps {
|
|
|
|
|
+ list: string[] | number[];
|
|
|
|
|
+ onChange: Function;
|
|
|
|
|
+ placeholder: string;
|
|
|
|
|
+ name: string;
|
|
|
|
|
+ [index: string]: any;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// En las props hago un "rest", que me da el resto del objeto que estoy desestructurando
|
|
|
|
|
+const Select: FC<selectProps> = ({ list, className, ...props }) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <select {...(props as any)} className={`form-select ${className}`}>
|
|
|
|
|
+ {props.placeholder ? <option value="">{props.placeholder}</option> : null}
|
|
|
|
|
+
|
|
|
|
|
+ {list.map((item) => (
|
|
|
|
|
+ <option value={item} key={item}>
|
|
|
|
|
+ {item}
|
|
|
|
|
+ </option>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </select>
|
|
|
|
|
+ );
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default Select;
|
|
export default Select;
|