Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve draft order lines empty state
dominik-zeglen2ed944d2d443
diff --git a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsxindex c12fcf206f..5a48ac212c 100644--- a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx+++ b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx@@ -31,7 +31,7 @@ const decorate = withStyles(theme => ({},toolbar: {marginRight: -theme.spacing.unit * 2,- marginTop: -theme.spacing.unit * 0.75 + "px"+ marginTop: -10}}));const CardTitle = decorate<CardTitleProps>(diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex 8dda640185..ba9cce7480 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -94,13 +94,13 @@ export function renderCollection<T>(index: number | undefined,collection: T[]) => any,- renderEmpty: (collection: T[]) => any+ renderEmpty?: (collection: T[]) => any) {if (collection === undefined) {return renderItem(undefined, undefined, collection);}if (collection.length === 0) {- return renderEmpty(collection);+ return !!renderEmpty ? renderEmpty(collection) : null;}return collection.map(renderItem);}diff --git a/saleor/static/dashboard-next/orders/components/OrderDraftDetails/OrderDraftDetails.tsx b/saleor/static/dashboard-next/orders/components/OrderDraftDetails/OrderDraftDetails.tsxindex 819f9e207f..be5ad4825f 100644--- a/saleor/static/dashboard-next/orders/components/OrderDraftDetails/OrderDraftDetails.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderDraftDetails/OrderDraftDetails.tsx@@ -45,12 +45,14 @@ const OrderDraftDetails: React.StatelessComponent<OrderDraftDetailsProps> = ({lines={maybe(() => order.lines.edges.map(edge => edge.node))}onOrderLineChange={onOrderLineChange}/>- <CardContent>- <OrderDraftDetailsSummary- order={order}- onShippingMethodEdit={onShippingMethodEdit}- />- </CardContent>+ {maybe(() => order.lines.edges.length) !== 0 && (+ <CardContent>+ <OrderDraftDetailsSummary+ order={order}+ onShippingMethodEdit={onShippingMethodEdit}+ />+ </CardContent>+ )}</Card>);OrderDraftDetails.displayName = "OrderDraftDetails";diff --git a/saleor/static/dashboard-next/orders/components/OrderDraftDetailsProducts/OrderDraftDetailsProducts.tsx b/saleor/static/dashboard-next/orders/components/OrderDraftDetailsProducts/OrderDraftDetailsProducts.tsxindex a6448e146f..5819162d26 100644--- a/saleor/static/dashboard-next/orders/components/OrderDraftDetailsProducts/OrderDraftDetailsProducts.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderDraftDetailsProducts/OrderDraftDetailsProducts.tsx@@ -28,11 +28,12 @@ interface OrderDraftDetailsProductsProps {onOrderLineChange: (id: string, data: FormData) => void;}-const decorate = withStyles({+const decorate = withStyles(theme => ({iconCell: {"&:last-child": {paddingRight: 0- }+ },+ width: 48 + theme.spacing.unit / 2},quantityField: {"& input": {@@ -43,31 +44,38 @@ const decorate = withStyles({textRight: {textAlign: "right" as "right"}-});+}));const OrderDraftDetailsProducts = decorate<OrderDraftDetailsProductsProps>(({ classes, lines, onOrderLineChange }) => (<Table>- <TableHead>- <TableRow>- <TableCell colSpan={2}>- {i18n.t("Product", { context: "table header" })}- </TableCell>- <TableCell className={classes.textRight}>- {i18n.t("Quantity", { context: "table header" })}- </TableCell>- <TableCell className={classes.textRight}>- {i18n.t("Price", { context: "table header" })}- </TableCell>- <TableCell className={classes.textRight}>- {i18n.t("Total", { context: "table header" })}- </TableCell>- <TableCell />- </TableRow>- </TableHead>+ {maybe(() => !!lines.length) && (+ <TableHead>+ <TableRow>+ <TableCell colSpan={2}>+ {i18n.t("Product", { context: "table header" })}+ </TableCell>+ <TableCell className={classes.textRight}>+ {i18n.t("Quantity", { context: "table header" })}+ </TableCell>+ <TableCell className={classes.textRight}>+ {i18n.t("Price", { context: "table header" })}+ </TableCell>+ <TableCell className={classes.textRight}>+ {i18n.t("Total", { context: "table header" })}+ </TableCell>+ <TableCell />+ </TableRow>+ </TableHead>+ )}<TableBody>- {renderCollection(- lines,- line => (+ {maybe(() => lines.length) === 0 ? (+ <TableRow>+ <TableCell colSpan={5}>+ {i18n.t("No Products added to Order")}+ </TableCell>+ </TableRow>+ ) : (+ renderCollection(lines, line => (<TableRow key={line ? line.id : "skeleton"}><TableCellAvatar thumbnail={maybe(() => line.thumbnailUrl)} /><TableCell>@@ -90,6 +98,7 @@ const OrderDraftDetailsProducts = decorate<OrderDraftDetailsProductsProps>(<Debouncechange={change}submit={hasChanged ? submit : undefined}+ time={200}>{debounce => (<TextField@@ -134,12 +143,7 @@ const OrderDraftDetailsProducts = decorate<OrderDraftDetailsProductsProps>(</IconButton></TableCell></TableRow>- ),- () => (- <TableRow>- <TableCell colSpan={5}>{i18n.t("No products found")}</TableCell>- </TableRow>- )+ )))}</TableBody></Table>