-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix SDL pricing message update on placement token change (#63) * Change placement modal action button text (#63) From Close to Done which semantically suggests that modal changes are applied * Move token select from placement modal to SDL builder (#63) * Update a denom in a generated yml sdl (#63)
- Loading branch information
1 parent
22448f4
commit fad3169
Showing
8 changed files
with
87 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ReactElement } from "react"; | ||
import { FormControl, InputLabel, MenuItem, Select } from "@mui/material"; | ||
import { makeStyles } from "tss-react/mui"; | ||
import { Control, Controller, Path } from "react-hook-form"; | ||
import { FieldValues } from "react-hook-form/dist/types/fields"; | ||
import { FieldPathValue } from "react-hook-form/dist/types"; | ||
|
||
import { Service } from "@src/types"; | ||
import { useSdlDenoms } from "@src/hooks/useDenom"; | ||
|
||
interface ServicesFieldValues extends FieldValues { | ||
services: Service[]; | ||
} | ||
|
||
interface Props<TFieldValues extends ServicesFieldValues, TName extends Path<TFieldValues> = Path<TFieldValues>> { | ||
name: TName; | ||
defaultValue?: FieldPathValue<TFieldValues, TName>; | ||
control: Control<TFieldValues>; | ||
} | ||
|
||
const useStyles = makeStyles()(theme => ({ | ||
formControl: { | ||
marginBottom: theme.spacing(1.5) | ||
} | ||
})); | ||
|
||
export const TokenFormControl = <F extends ServicesFieldValues>({ control, name, defaultValue }: Props<F>): ReactElement<Props<F>> => { | ||
const { classes } = useStyles(); | ||
const supportedSdlDenoms = useSdlDenoms(); | ||
|
||
return ( | ||
<FormControl className={classes.formControl} fullWidth sx={{ display: "flex", alignItems: "center", flexDirection: "row" }}> | ||
<InputLabel id="grant-token">Token</InputLabel> | ||
<Controller | ||
control={control} | ||
name={name} | ||
defaultValue={defaultValue} | ||
rules={{ | ||
required: true | ||
}} | ||
render={({ fieldState, field }) => { | ||
return ( | ||
<Select {...field} labelId="sdl-token" label="Token" size="small" error={!!fieldState.error} fullWidth MenuProps={{ disableScrollLock: true }}> | ||
{supportedSdlDenoms.map(token => ( | ||
<MenuItem key={token.id} value={token.value}> | ||
{token.tokenLabel} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
); | ||
}} | ||
/> | ||
</FormControl> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters