2022-02-27 20:05:21 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
import TextField from '@mui/material/TextField';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const SelectTextFields = (props) => {
|
|
|
|
|
2022-03-07 02:19:35 +00:00
|
|
|
const [currency, setCurrency] = useState(props.emptyField ? '0' : '1');
|
|
|
|
|
2022-03-06 19:37:09 +00:00
|
|
|
if(props.emptyField){
|
|
|
|
props.currencies.push({ 'value': 0, 'label': ''})
|
|
|
|
}
|
2022-02-27 20:05:21 +00:00
|
|
|
|
|
|
|
|
2022-03-07 02:19:35 +00:00
|
|
|
useEffect(()=>{
|
2022-03-11 03:01:58 +00:00
|
|
|
|
2022-03-07 02:19:35 +00:00
|
|
|
props.func(currency);
|
|
|
|
|
|
|
|
},[currency, props])
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
const handleChange = (event) => {
|
2022-03-07 02:19:35 +00:00
|
|
|
|
|
|
|
setCurrency(event.target.value);
|
|
|
|
|
|
|
|
};
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
return (
|
|
|
|
|
|
|
|
<Box
|
|
|
|
component="form"
|
|
|
|
sx={{
|
|
|
|
"&:hover": {
|
|
|
|
"&& fieldset": {
|
|
|
|
border: "1px solid black"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
'& .MuiTextField-root': { m: 1, },}
|
|
|
|
}
|
|
|
|
noValidate
|
|
|
|
autoComplete="off"
|
2022-01-24 11:44:42 +00:00
|
|
|
>
|
2022-02-27 20:05:21 +00:00
|
|
|
<TextField
|
|
|
|
id="outlined-select-currency-native"
|
|
|
|
margin="dense"
|
|
|
|
size="small"
|
|
|
|
select
|
|
|
|
label={props.header}
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
SelectProps={{
|
|
|
|
native: true,
|
|
|
|
}}
|
|
|
|
// helperText="Please select your currency"
|
|
|
|
>
|
|
|
|
|
|
|
|
{props.currencies.map((option, index) => (
|
|
|
|
<option key={index} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
|
|
|
|
</TextField>
|
|
|
|
|
|
|
|
|
|
|
|
</Box>
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
export default SelectTextFields
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
component="form"
|
|
|
|
sx={{
|
|
|
|
'& .MuiTextField-root': { m: 1, width: '25ch' },
|
|
|
|
}}
|
|
|
|
noValidate
|
|
|
|
autoComplete="off"
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<TextField
|
|
|
|
id="outlined-select-currency"
|
|
|
|
select
|
|
|
|
label="Select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<MenuItem key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
<TextField
|
|
|
|
id="outlined-select-currency-native"
|
|
|
|
select
|
|
|
|
label="Native select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
SelectProps={{
|
|
|
|
native: true,
|
|
|
|
}}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<option key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<TextField
|
|
|
|
id="filled-select-currency"
|
|
|
|
select
|
|
|
|
label="Select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
variant="filled"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<MenuItem key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
<TextField
|
|
|
|
id="filled-select-currency-native"
|
|
|
|
select
|
|
|
|
label="Native select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
SelectProps={{
|
|
|
|
native: true,
|
|
|
|
}}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
variant="filled"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<option key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<TextField
|
|
|
|
id="standard-select-currency"
|
|
|
|
select
|
|
|
|
label="Select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
variant="standard"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<MenuItem key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
<TextField
|
|
|
|
id="standard-select-currency-native"
|
|
|
|
select
|
|
|
|
label="Native select"
|
|
|
|
value={currency}
|
|
|
|
onChange={handleChange}
|
|
|
|
SelectProps={{
|
|
|
|
native: true,
|
|
|
|
}}
|
|
|
|
helperText="Please select your currency"
|
|
|
|
variant="standard"
|
|
|
|
>
|
|
|
|
{currencies.map((option) => (
|
|
|
|
<option key={option.value} value={option.value}>
|
|
|
|
{option.label}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</TextField>
|
|
|
|
</div>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
*/
|