Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Component fixes

dominik-zeglena16e373f7684
diff --git a/saleor/static/dashboard-next/components/ControlledCheckbox.tsx b/saleor/static/dashboard-next/components/ControlledCheckbox.tsx
index a56d55d1f6..57ee6fd6fb 100644
--- a/saleor/static/dashboard-next/components/ControlledCheckbox.tsx
+++ b/saleor/static/dashboard-next/components/ControlledCheckbox.tsx
@@ -19,9 +19,8 @@ export const ControlledCheckbox: React.StatelessComponent<
control={
<Checkbox
checked={checked}
- color="primary"
name={name}
- onChange={() => onChange({ target: { name, value: !checked } })}
+ onClick={() => onChange({ target: { name, value: !checked } })}
/>
}
label={label}
diff --git a/saleor/static/dashboard-next/components/PriceField/PriceField.tsx b/saleor/static/dashboard-next/components/PriceField/PriceField.tsx
index 7a554e27d0..b07a2cd7ac 100644
--- a/saleor/static/dashboard-next/components/PriceField/PriceField.tsx
+++ b/saleor/static/dashboard-next/components/PriceField/PriceField.tsx
@@ -1,15 +1,11 @@
-import FormControl from "@material-ui/core/FormControl";
-import FormHelperText from "@material-ui/core/FormHelperText";
-import Input from "@material-ui/core/Input";
import InputAdornment from "@material-ui/core/InputAdornment";
-import InputLabel from "@material-ui/core/InputLabel";
import {
createStyles,
Theme,
withStyles,
WithStyles
} from "@material-ui/core/styles";
-import * as classNames from "classnames";
+import TextField from "@material-ui/core/TextField";
import * as React from "react";
const styles = (theme: Theme) =>
@@ -34,81 +30,6 @@ const styles = (theme: Theme) =>
}
});
-interface PriceRangeFieldProps extends WithStyles<typeof styles> {
- currencySymbol: string;
- disabled?: boolean;
- error?: boolean;
- hint?: string;
- label?: string;
- name: string;
- value: {
- max: string | number;
- min: string | number;
- };
- onChange(event: any);
-}
-
-export const PriceRangeField = withStyles(styles, { name: "PriceRangeField" })(
- ({
- disabled,
- error,
- label,
- hint,
- currencySymbol,
- name,
- classes,
- onChange,
- value
- }: PriceRangeFieldProps) => (
- <div className={classes.widgetContainer}>
- <div className={classes.inputContainer}>
- <FormControl error={error}>
- {label && <InputLabel htmlFor={`${name}_min`}>{label}</InputLabel>}
- <Input
- value={value ? value.min : ""}
- endAdornment={
- currencySymbol ? (
- <InputAdornment position="end">{currencySymbol}</InputAdornment>
- ) : (
- <span />
- )
- }
- className={classNames({ [classes.pullDown]: !label })}
- fullWidth
- name={`${name}_min`}
- onChange={onChange}
- type="number"
- disabled={disabled}
- />
- {hint && <FormHelperText>{hint}</FormHelperText>}
- </FormControl>
- <span className={classes.separator}>-</span>
- <FormControl error={error}>
- <Input
- value={value ? value.max : ""}
- endAdornment={
- currencySymbol ? (
- <InputAdornment position="end">{currencySymbol}</InputAdornment>
- ) : (
- <span />
- )
- }
- className={classes.pullDown}
- fullWidth
- name={`${name}_max`}
- onChange={onChange}
- type="number"
- disabled={disabled}
- />
- </FormControl>
- </div>
- </div>
- )
-);
-PriceRangeField.defaultProps = {
- name: "price"
-};
-
interface PriceFieldProps extends WithStyles<typeof styles> {
currencySymbol?: string;
disabled?: boolean;
@@ -132,26 +53,25 @@ export const PriceField = withStyles(styles, { name: "PriceField" })(
onChange,
value
}: PriceFieldProps) => (
- <FormControl error={error} fullWidth>
- {label && <InputLabel htmlFor={name}>{label}</InputLabel>}
- <Input
- value={value || ""}
- endAdornment={
- currencySymbol ? (
- <InputAdornment position="end" className={classes.currencySymbol}>
- {currencySymbol}
- </InputAdornment>
- ) : (
- <span />
- )
- }
- name={name}
- onChange={onChange}
- type="number"
- disabled={disabled}
- />
- {hint && <FormHelperText>{hint}</FormHelperText>}
- </FormControl>
+ <TextField
+ error={error}
+ helperText={hint}
+ label={label}
+ value={value}
+ InputProps={{
+ endAdornment: currencySymbol ? (
+ <InputAdornment position="end" className={classes.currencySymbol}>
+ {currencySymbol}
+ </InputAdornment>
+ ) : (
+ <span />
+ ),
+ type: "number"
+ }}
+ name={name}
+ disabled={disabled}
+ onChange={onChange}
+ />
)
);
PriceField.defaultProps = {
diff --git a/saleor/static/dashboard-next/storybook/stories/components/PriceField.tsx b/saleor/static/dashboard-next/storybook/stories/components/PriceField.tsx
index 24bec55beb..12b39fceee 100644
--- a/saleor/static/dashboard-next/storybook/stories/components/PriceField.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/components/PriceField.tsx
@@ -1,88 +1,17 @@
import { storiesOf } from "@storybook/react";
import * as React from "react";
-import PriceField, { PriceRangeField } from "../../../components/PriceField";
+import PriceField from "../../../components/PriceField";
-const value = {
- max: "30",
- min: "10"
-};
-
-storiesOf("Generics / PriceRangeField", module)
- .add("with value", () => (
- <PriceRangeField
- currencySymbol="USD"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("with label", () => (
- <PriceRangeField
- currencySymbol="USD"
- label="Lorem ipsum"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("with hint", () => (
- <PriceRangeField
- currencySymbol="USD"
- hint="Lorem ipsum"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("disabled", () => (
- <PriceRangeField
- currencySymbol="USD"
- disabled
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("with label and hint", () => (
- <PriceRangeField
- currencySymbol="USD"
- hint="Ipsum"
- label="Lorem"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("with value, label, currency symbol and hint", () => (
- <PriceRangeField
- currencySymbol="USD"
- hint="Ipsum"
- label="Lorem"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ))
- .add("with value, label, currency symbol and error", () => (
- <PriceRangeField
- currencySymbol="USD"
- error={true}
- hint="Ipsum"
- label="Lorem"
- name="priceField"
- onChange={undefined}
- value={value}
- />
- ));
-
-storiesOf("Generics / PriceField", module)
+storiesOf("Generics / Price input", module)
.add("with no value", () => <PriceField onChange={undefined} />)
.add("with value", () => <PriceField value={"30"} onChange={undefined} />)
.add("with label", () => (
<PriceField label="Lorem ipsum" onChange={undefined} />
))
- .add("with hint", () => <PriceField hint="Lorem ipsum" onChange={undefined} />)
+ .add("with hint", () => (
+ <PriceField hint="Lorem ipsum" onChange={undefined} />
+ ))
.add("with currency symbol", () => (
<PriceField currencySymbol="$" onChange={undefined} />
))