Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add empty state to select fields
dominik-zeglen835d578fc53e
diff --git a/saleor/static/dashboard-next/components/MultiAutocompleteSelectField/MultiAutocompleteSelectField.tsx b/saleor/static/dashboard-next/components/MultiAutocompleteSelectField/MultiAutocompleteSelectField.tsxindex 6719cf51a6..489889ba8d 100644--- a/saleor/static/dashboard-next/components/MultiAutocompleteSelectField/MultiAutocompleteSelectField.tsx+++ b/saleor/static/dashboard-next/components/MultiAutocompleteSelectField/MultiAutocompleteSelectField.tsx@@ -155,7 +155,7 @@ export const MultiAutocompleteSelectField = decorate<)): !loading && (<MenuItem disabled={true} component="div">- {i18n.t("No matches found")}+ {i18n.t("No results found")}</MenuItem>)}</>diff --git a/saleor/static/dashboard-next/components/MultiSelectField/MultiSelectField.tsx b/saleor/static/dashboard-next/components/MultiSelectField/MultiSelectField.tsxindex 034cfbcd04..fe0b2fe3e9 100644--- a/saleor/static/dashboard-next/components/MultiSelectField/MultiSelectField.tsx+++ b/saleor/static/dashboard-next/components/MultiSelectField/MultiSelectField.tsx@@ -7,6 +7,8 @@ import Select, { SelectProps } from "@material-ui/core/Select";import { withStyles } from "@material-ui/core/styles";import * as React from "react";+import i18n from "../../i18n";+const decorate = withStyles(theme => ({chip: {margin: theme.spacing.unit * 0.5@@ -82,11 +84,15 @@ export const MultiSelectField = decorate<MultiSelectFieldProps>(onChange={onChange}{...selectProps}>- {choices.map(choice => (- <MenuItem value={choice.value} key={choice.value}>- {choice.label}- </MenuItem>- ))}+ {choices.length > 0 ? (+ choices.map(choice => (+ <MenuItem value={choice.value} key={choice.value}>+ {choice.label}+ </MenuItem>+ ))+ ) : (+ <MenuItem disabled={true}>{i18n.t("No results found")}</MenuItem>+ )}</Select>{hint && <FormHelperText>{hint}</FormHelperText>}</FormControl>diff --git a/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx b/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsxindex e88356a690..5450b1c65f 100644--- a/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx+++ b/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx@@ -114,7 +114,7 @@ const SingleAutocompleteSelectFieldComponent = decorate<<MenuItem disabled={true} component="div">{i18n.t("Loading...")}</MenuItem>- ) : (+ ) : choices.length > 0 || custom ? (<>{choices.map((suggestion, index) => (<MenuItem@@ -139,6 +139,10 @@ const SingleAutocompleteSelectFieldComponent = decorate<</MenuItem>)}</>+ ) : (+ <MenuItem disabled={true} component="div">+ {i18n.t("No results found")}+ </MenuItem>)}</Paper>)}diff --git a/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx b/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsxindex ba7e882683..850dcd89e5 100644--- a/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx+++ b/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx@@ -6,6 +6,8 @@ import Select, { SelectProps } from "@material-ui/core/Select";import { withStyles } from "@material-ui/core/styles";import * as React from "react";+import i18n from "../../i18n";+const decorate = withStyles({formControl: {width: "100%"@@ -65,11 +67,15 @@ export const SingleSelectField = decorate<SingleSelectFieldProps>(onChange={onChange}{...selectProps}>- {choices.map(choice => (- <MenuItem value={choice.value} key={choice.value}>- {choice.label}- </MenuItem>- ))}+ {choices.length > 0 ? (+ choices.map(choice => (+ <MenuItem value={choice.value} key={choice.value}>+ {choice.label}+ </MenuItem>+ ))+ ) : (+ <MenuItem disabled={true}>{i18n.t("No results found")}</MenuItem>+ )}</Select>{hint && <FormHelperText>{hint}</FormHelperText>}</FormControl>