Use MUI select component

This commit is contained in:
IshaVenikar 2024-10-23 11:46:45 +05:30
parent 967eded8b1
commit 56c7ab166c
2 changed files with 41 additions and 35 deletions

View File

@ -5,13 +5,14 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import { useMediaQuery } from 'usehooks-ts'; import { useMediaQuery } from 'usehooks-ts';
import { AddEnvironmentVariableInput, AuctionParams, Deployer } from 'gql-client'; import { AddEnvironmentVariableInput, AuctionParams, Deployer } from 'gql-client';
import { Select, MenuItem, FormControl, FormHelperText } from '@mui/material';
import { import {
ArrowRightCircleFilledIcon, ArrowRightCircleFilledIcon,
LoadingIcon, LoadingIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { Heading } from '../../shared/Heading'; import { Heading } from '../../shared/Heading';
import { Button } from '../../shared/Button'; import { Button } from '../../shared/Button';
import { Select, SelectOption } from 'components/shared/Select';
import { Input } from 'components/shared/Input'; import { Input } from 'components/shared/Input';
import { useToast } from 'components/shared/Toast'; import { useToast } from 'components/shared/Toast';
import { useGQLClient } from '../../../context/GQLClientContext'; import { useGQLClient } from '../../../context/GQLClientContext';
@ -206,24 +207,14 @@ const Configure = () => {
control={methods.control} control={methods.control}
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<Select <Select
label="Configuration Options" value={value}
value={ onChange={(event) => onChange(event.target.value)}
{ size='small'
value: value || 'LRN', displayEmpty
label: >
value === 'Auction' <MenuItem value="LRN">Deployer LRN</MenuItem>
? 'Create Auction' <MenuItem value="Auction">Create Auction</MenuItem>
: 'Deployer LRN', </Select>
} as SelectOption
}
onChange={(value) =>
onChange((value as SelectOption).value)
}
options={[
{ value: 'LRN', label: 'Deployer LRN' },
{ value: 'Auction', label: 'Create Auction' },
]}
/>
)} )}
/> />
</div> </div>
@ -240,21 +231,26 @@ const Configure = () => {
name="lrn" name="lrn"
control={methods.control} control={methods.control}
rules={{ required: true }} rules={{ required: true }}
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange }, fieldState }) => (
<FormControl fullWidth error={Boolean(fieldState.error)}>
<span className="text-sm text-elements-high-em mb-4">
Select deployer LRN
</span>
<Select <Select
label="Select deployer LRN" value={value}
value={{ onChange={(event) => onChange(event.target.value)}
value: value || '', displayEmpty
label: value || '' size='small'
} as SelectOption}
onChange={(selectedOption) => >
onChange((selectedOption as SelectOption).value) {deployers.map((deployer) => (
} <MenuItem key={deployer.deployerId} value={deployer.deployerLrn}>
options={deployers.map(deployer => ({ {deployer.deployerLrn}
value: deployer.deployerLrn, </MenuItem>
label: deployer.deployerLrn ))}
}))} </Select>
/> {fieldState.error && <FormHelperText>{fieldState.error.message}</FormHelperText>}
</FormControl>
)} )}
/> />
</div> </div>

View File

@ -17,6 +17,16 @@ import { Button, Heading, Tag } from 'components/shared';
const WAIT_DURATION = 5000; const WAIT_DURATION = 5000;
const DIALOG_STYLE = {
backgroundColor: 'rgba(0,0,0, .9)',
padding: '2em',
borderRadius: '0.5em',
marginLeft: '0.5em',
marginRight: '0.5em',
color: 'gray',
fontSize: 'small',
};
export const AuctionCard = ({ project }: { project: Project }) => { export const AuctionCard = ({ project }: { project: Project }) => {
const [auctionStatus, setAuctionStatus] = useState<string>(''); const [auctionStatus, setAuctionStatus] = useState<string>('');
const [deployers, setDeployers] = useState<Deployer[]>([]); const [deployers, setDeployers] = useState<Deployer[]>([]);
@ -140,7 +150,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
maxWidth="md" maxWidth="md"
> >
<DialogTitle>Auction Details</DialogTitle> <DialogTitle>Auction Details</DialogTitle>
<DialogContent> <DialogContent style={DIALOG_STYLE}>
{auctionDetails && ( {auctionDetails && (
<pre>{JSON.stringify(auctionDetails, null, 2)}</pre> <pre>{JSON.stringify(auctionDetails, null, 2)}</pre>
)} )}