Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add stock information card
dominik-zeglen3196403076bd
diff --git a/saleor/static/dashboard-next/home/components/HomeNotificationTable/HomeNotificationTable.tsx b/saleor/static/dashboard-next/home/components/HomeNotificationTable/HomeNotificationTable.tsxindex 7734fe6038..1024bccd9c 100644--- a/saleor/static/dashboard-next/home/components/HomeNotificationTable/HomeNotificationTable.tsx+++ b/saleor/static/dashboard-next/home/components/HomeNotificationTable/HomeNotificationTable.tsx@@ -10,22 +10,15 @@ import * as React from "react";import Skeleton from "../../../components/Skeleton";import i18n from "../../../i18n";--// There is no API for this component right now,-// but maybe it will come in handy in the future+import { maybe } from "../../../misc";interface HomeNotificationTableProps {- disabled: boolean;- notifications: {- orders: number;- payments: number;- problems: number;- productsOut: number;- };- toOrders: () => void;- toPayments: () => void;- toProblems: () => void;- toProductsOut: () => void;+ ordersToCapture: number;+ ordersToFulfill: number;+ productsOutOfStock: number;+ onOrdersToFulfillClick: () => void;+ onOrdersToCaptureClick: () => void;+ onProductsOutOfStockClick: () => void;}const decorate = withStyles(theme => ({@@ -39,108 +32,86 @@ const decorate = withStyles(theme => ({const HomeNotificationTable = decorate<HomeNotificationTableProps>(({classes,- notifications,- toOrders,- toPayments,- toProblems,- toProductsOut+ onOrdersToCaptureClick,+ onOrdersToFulfillClick,+ onProductsOutOfStockClick,+ ordersToCapture,+ ordersToFulfill,+ productsOutOfStock}) => {return (<Card><Table><TableBody className={classes.tableRow}>- <TableRow- hover={true}- onClick={!!notifications ? toOrders : undefined}- >- <TableCell>- {notifications === undefined ? (- <Skeleton />- ) : notifications && notifications.orders === 0 ? (- <Typography>{i18n.t("No orders to fulfill")}</Typography>- ) : (- <Typography- dangerouslySetInnerHTML={{- __html: i18n.t(- "<b>{{orders}} Orders</b> are ready to fulfill",- { orders: notifications.orders }- )- }}- />- )}- </TableCell>- <TableCell className={classes.arrowIcon}>- <KeyboardArrowRight />- </TableCell>- </TableRow>- <TableRow- hover={true}- onClick={!!notifications ? toPayments : undefined}- >+ <TableRow hover={true} onClick={onOrdersToFulfillClick}><TableCell>- {notifications === undefined ? (+ {maybe(+ () =>+ ordersToFulfill === 0 ? (+ <Typography>+ {i18n.t("No orders ready to fulfill")}+ </Typography>+ ) : (+ <Typography+ dangerouslySetInnerHTML={{+ __html: i18n.t(+ "<b>{{ amount }} Orders</b> are ready to fulfill",+ { amount: ordersToFulfill }+ )+ }}+ />+ ),<Skeleton />- ) : notifications.payments === 0 ? (- <Typography>- {i18n.t("No payments waiting for capture")}- </Typography>- ) : (- <Typography- dangerouslySetInnerHTML={{- __html: i18n.t(- "<b>{{payments}} Payments </b>to capture",- { payments: notifications.payments }- )- }}- />)}</TableCell><TableCell className={classes.arrowIcon}><KeyboardArrowRight /></TableCell></TableRow>- <TableRow- hover={true}- onClick={!!notifications ? toProblems : undefined}- >+ <TableRow hover={true} onClick={onOrdersToCaptureClick}><TableCell>- {notifications === undefined ? (+ {maybe(+ () =>+ ordersToCapture === 0 ? (+ <Typography>+ {i18n.t("No payments waiting for capture")}+ </Typography>+ ) : (+ <Typography+ dangerouslySetInnerHTML={{+ __html: i18n.t(+ "<b>{{ amount }} Payments</b> to capture",+ { amount: ordersToCapture }+ )+ }}+ />+ ),<Skeleton />- ) : notifications.problems === 0 ? (- <Typography>{i18n.t("No problem with orders")}</Typography>- ) : (- <Typography- dangerouslySetInnerHTML={{- __html: i18n.t(- "<b>{{problems}} Problems</b> with orders",- { problems: notifications.problems }- )- }}- />)}</TableCell><TableCell className={classes.arrowIcon}><KeyboardArrowRight /></TableCell></TableRow>- <TableRow- hover={true}- onClick={!!notifications ? toProductsOut : undefined}- >+ <TableRow hover={true} onClick={onProductsOutOfStockClick}><TableCell>- {notifications === undefined ? (+ {maybe(+ () =>+ productsOutOfStock === 0 ? (+ <Typography>+ {i18n.t("No products out of stock")}+ </Typography>+ ) : (+ <Typography+ dangerouslySetInnerHTML={{+ __html: i18n.t(+ "<b>{{ amount }} Products</b> out of stock",+ { amount: productsOutOfStock }+ )+ }}+ />+ ),<Skeleton />- ) : notifications.productsOut === 0 ? (- <Typography>{i18n.t("No out of stock products")}</Typography>- ) : (- <Typography- dangerouslySetInnerHTML={{- __html: i18n.t(- "<b>{{productsOut}} Products </b>out of stock",- { productsOut: notifications.productsOut }- )- }}- />)}</TableCell><TableCell className={classes.arrowIcon}>diff --git a/saleor/static/dashboard-next/home/components/HomePage/HomePage.tsx b/saleor/static/dashboard-next/home/components/HomePage/HomePage.tsxindex ec0b7e00d9..4365dd4902 100644--- a/saleor/static/dashboard-next/home/components/HomePage/HomePage.tsx+++ b/saleor/static/dashboard-next/home/components/HomePage/HomePage.tsx@@ -16,15 +16,22 @@ import {import HomeActivityCard from "../HomeActivityCard";import HomeAnalyticsCard from "../HomeAnalyticsCard";import HomeHeader from "../HomeHeader";+import HomeNotificationTable from "../HomeNotificationTable/HomeNotificationTable";import HomeProductListCard from "../HomeProductListCard";export interface HomePageProps {activities: Home_activities_edges_node[];orders: number;+ ordersToCapture: number;+ ordersToFulfill: number;+ productsOutOfStock: number;sales: Home_salesToday_gross;- userName: string;topProducts: Home_productTopToday_edges_node[];+ userName: string;+ onOrdersToCaptureClick: () => void;+ onOrdersToFulfillClick: () => void;onProductClick: (productId: string, variantId: string) => void;+ onProductsOutOfStockClick: () => void;}const decorate = withStyles(theme => ({@@ -60,7 +67,13 @@ const HomePage = decorate<HomePageProps>(sales,topProducts,onProductClick,- activities+ activities,+ onOrdersToCaptureClick,+ onOrdersToFulfillClick,+ onProductsOutOfStockClick,+ ordersToCapture,+ ordersToFulfill,+ productsOutOfStock}) => (<Container width="md"><HomeHeader userName={userName} />@@ -90,6 +103,15 @@ const HomePage = decorate<HomePageProps>()}</HomeAnalyticsCard></div>+ <HomeNotificationTable+ onOrdersToCaptureClick={onOrdersToCaptureClick}+ onOrdersToFulfillClick={onOrdersToFulfillClick}+ onProductsOutOfStockClick={onProductsOutOfStockClick}+ ordersToCapture={ordersToCapture}+ ordersToFulfill={ordersToFulfill}+ productsOutOfStock={productsOutOfStock}+ />+ <CardSpacer /><HomeProductListCardonRowClick={onProductClick}topProducts={topProducts}diff --git a/saleor/static/dashboard-next/home/queries.ts b/saleor/static/dashboard-next/home/queries.tsindex 951bf35e4a..d8ab29ec6a 100644--- a/saleor/static/dashboard-next/home/queries.ts+++ b/saleor/static/dashboard-next/home/queries.ts@@ -15,28 +15,13 @@ const home = gql`totalCount}ordersToFulfill: orders(status: READY_TO_FULFILL, created: TODAY) {- edges {- node {- id- number- }- }+ totalCount}ordersToCapture: orders(status: READY_TO_CAPTURE, created: TODAY) {- edges {- node {- id- number- }- }+ totalCount}productsOutOfStock: products(stockAvailability: OUT_OF_STOCK) {- edges {- node {- id- name- }- }+ totalCount}productTopToday: reportProductSales(period: TODAY) {edges {diff --git a/saleor/static/dashboard-next/home/types/Home.ts b/saleor/static/dashboard-next/home/types/Home.tsindex 5187a67e32..be5d3c6b18 100644--- a/saleor/static/dashboard-next/home/types/Home.ts+++ b/saleor/static/dashboard-next/home/types/Home.ts@@ -23,52 +23,19 @@ export interface Home_ordersToday {totalCount: number | null;}-export interface Home_ordersToFulfill_edges_node {- __typename: "Order";- id: string;- number: string | null;-}--export interface Home_ordersToFulfill_edges {- __typename: "OrderCountableEdge";- node: Home_ordersToFulfill_edges_node;-}-export interface Home_ordersToFulfill {__typename: "OrderCountableConnection";- edges: Home_ordersToFulfill_edges[];-}--export interface Home_ordersToCapture_edges_node {- __typename: "Order";- id: string;- number: string | null;-}--export interface Home_ordersToCapture_edges {- __typename: "OrderCountableEdge";- node: Home_ordersToCapture_edges_node;+ totalCount: number | null;}export interface Home_ordersToCapture {__typename: "OrderCountableConnection";- edges: Home_ordersToCapture_edges[];-}--export interface Home_productsOutOfStock_edges_node {- __typename: "Product";- id: string;- name: string;-}--export interface Home_productsOutOfStock_edges {- __typename: "ProductCountableEdge";- node: Home_productsOutOfStock_edges_node;+ totalCount: number | null;}export interface Home_productsOutOfStock {__typename: "ProductCountableConnection";- edges: Home_productsOutOfStock_edges[];+ totalCount: number | null;}export interface Home_productTopToday_edges_node_revenue_gross {diff --git a/saleor/static/dashboard-next/home/views/index.tsx b/saleor/static/dashboard-next/home/views/index.tsxindex 4068a32e83..148ea88b78 100644--- a/saleor/static/dashboard-next/home/views/index.tsx+++ b/saleor/static/dashboard-next/home/views/index.tsx@@ -3,7 +3,8 @@ import * as React from "react";import { UserContext } from "../../auth";import Navigator from "../../components/Navigator";import { maybe } from "../../misc";-import { productVariantEditUrl } from "../../products";+import { orderListUrl } from "../../orders";+import { productListUrl, productVariantEditUrl } from "../../products";import HomePage from "../components/HomePage";import { HomePageQuery } from "../queries";@@ -31,6 +32,14 @@ const HomeSection = () => ())}+ onOrdersToCaptureClick={() => navigate(orderListUrl)}+ onOrdersToFulfillClick={() => navigate(orderListUrl)}+ onProductsOutOfStockClick={() => navigate(productListUrl)}+ ordersToCapture={maybe(() => data.ordersToCapture.totalCount)}+ ordersToFulfill={maybe(() => data.ordersToFulfill.totalCount)}+ productsOutOfStock={maybe(+ () => data.productsOutOfStock.totalCount+ )}userName={user.email}/>)}