diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index b222976d9ff..9b4ef9e5053 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -1097,9 +1097,6 @@ "context": "references attribute type", "string": "References" }, - "5dyOs0": { - "string": "No payments waiting for capture" - }, "5elC9k": { "context": "taxes section name", "string": "Taxes" @@ -2170,9 +2167,6 @@ "context": "Order summary refunds header", "string": "Refunds" }, - "E9Jssl": { - "string": "No orders ready to fulfill" - }, "EA7rjI": { "context": "disabled status label", "string": "Disabled" @@ -3566,9 +3560,6 @@ "context": "weight", "string": "{value} {unit}" }, - "Nuq83+": { - "string": "Create new channel" - }, "Nv/toB": { "context": "button", "string": "Assign and save" @@ -4752,6 +4743,9 @@ "context": "order refund amount", "string": "Shipment Cost" }, + "WHgdsk": { + "string": "Out of stock" + }, "WIxSDm": { "context": "card header", "string": "{country} class rates" @@ -4875,9 +4869,6 @@ "context": "title", "string": "Reserved stock" }, - "X7jl6w": { - "string": "Orders" - }, "X8qjg3": { "context": "inactive", "string": "Inactive" @@ -5467,9 +5458,6 @@ "context": "success gift card enable message", "string": "Successfully enabled gift card" }, - "bFhzRX": { - "string": "No products are out of stock" - }, "bHdFph": { "context": "subsection header", "string": "Address" @@ -5584,9 +5572,6 @@ "byP6IC": { "string": "Selected" }, - "c0H45L": { - "string": "{amount, plural,one {One order is ready to fulfill} other {{amount} orders are ready to fulfill}}" - }, "c24hjq": { "context": "status", "string": "Active" @@ -5688,9 +5673,6 @@ "context": "WarehouseSettings no shipping zones assigned", "string": "This warehouse has no shipping zones assigned." }, - "cdxwA8": { - "string": "{amount, plural,one {One product out of stock}other {{amount} products out of stock}}" - }, "cfQf0w": { "context": "button", "string": "Create Order" @@ -6916,9 +6898,6 @@ "context": "bulk issue gift cards success alert description", "string": "Requested {cardsAmount} were successfully issued" }, - "md326v": { - "string": "{amount, plural,one {One payment to capture}other {{amount} payments to capture}}" - }, "me585h": { "context": "navigator section header", "string": "Quick Actions" diff --git a/src/graphql/hooks.generated.ts b/src/graphql/hooks.generated.ts index 4b8bf650241..781e726db68 100644 --- a/src/graphql/hooks.generated.ts +++ b/src/graphql/hooks.generated.ts @@ -8136,22 +8136,13 @@ export type CustomerGiftCardListQueryHookResult = ReturnType; export type CustomerGiftCardListQueryResult = Apollo.QueryResult; export const HomeDocument = gql` - query Home($channel: String!, $datePeriod: DateRangeInput!, $PERMISSION_MANAGE_PRODUCTS: Boolean!, $PERMISSION_MANAGE_ORDERS: Boolean!) { + query Home($channel: String!, $PERMISSION_MANAGE_PRODUCTS: Boolean!, $PERMISSION_MANAGE_ORDERS: Boolean!) { salesToday: ordersTotal(period: TODAY, channel: $channel) @include(if: $PERMISSION_MANAGE_ORDERS) { gross { amount currency } } - ordersToday: orders(filter: {created: $datePeriod}, channel: $channel) @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } - ordersToFulfill: orders(filter: {status: READY_TO_FULFILL}, channel: $channel) @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } - ordersToCapture: orders(filter: {status: READY_TO_CAPTURE}, channel: $channel) @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } productsOutOfStock: products( filter: {stockAvailability: OUT_OF_STOCK} channel: $channel @@ -8222,7 +8213,6 @@ export const HomeDocument = gql` * const { data, loading, error } = useHomeQuery({ * variables: { * channel: // value for 'channel' - * datePeriod: // value for 'datePeriod' * PERMISSION_MANAGE_PRODUCTS: // value for 'PERMISSION_MANAGE_PRODUCTS' * PERMISSION_MANAGE_ORDERS: // value for 'PERMISSION_MANAGE_ORDERS' * }, diff --git a/src/graphql/types.generated.ts b/src/graphql/types.generated.ts index 58097675b67..169e347bb42 100644 --- a/src/graphql/types.generated.ts +++ b/src/graphql/types.generated.ts @@ -9351,13 +9351,12 @@ export type CustomerGiftCardListQuery = { __typename: 'Query', giftCards: { __ty export type HomeQueryVariables = Exact<{ channel: Scalars['String']; - datePeriod: DateRangeInput; PERMISSION_MANAGE_PRODUCTS: Scalars['Boolean']; PERMISSION_MANAGE_ORDERS: Scalars['Boolean']; }>; -export type HomeQuery = { __typename: 'Query', salesToday: { __typename: 'TaxedMoney', gross: { __typename: 'Money', amount: number, currency: string } } | null, ordersToday: { __typename: 'OrderCountableConnection', totalCount: number | null } | null, ordersToFulfill: { __typename: 'OrderCountableConnection', totalCount: number | null } | null, ordersToCapture: { __typename: 'OrderCountableConnection', totalCount: number | null } | null, productsOutOfStock: { __typename: 'ProductCountableConnection', totalCount: number | null } | null, productTopToday: { __typename: 'ProductVariantCountableConnection', edges: Array<{ __typename: 'ProductVariantCountableEdge', node: { __typename: 'ProductVariant', id: string, quantityOrdered: number | null, revenue: { __typename: 'TaxedMoney', gross: { __typename: 'Money', amount: number, currency: string } } | null, attributes: Array<{ __typename: 'SelectedAttribute', values: Array<{ __typename: 'AttributeValue', id: string, name: string | null }> }>, product: { __typename: 'Product', id: string, name: string, thumbnail: { __typename: 'Image', url: string } | null } } }> } | null, activities: { __typename: 'OrderEventCountableConnection', edges: Array<{ __typename: 'OrderEventCountableEdge', node: { __typename: 'OrderEvent', amount: number | null, composedId: string | null, date: any | null, email: string | null, emailType: OrderEventsEmailsEnum | null, id: string, message: string | null, orderNumber: string | null, oversoldItems: Array | null, quantity: number | null, type: OrderEventsEnum | null, user: { __typename: 'User', id: string, email: string } | null } }> } | null }; +export type HomeQuery = { __typename: 'Query', salesToday: { __typename: 'TaxedMoney', gross: { __typename: 'Money', amount: number, currency: string } } | null, productsOutOfStock: { __typename: 'ProductCountableConnection', totalCount: number | null } | null, productTopToday: { __typename: 'ProductVariantCountableConnection', edges: Array<{ __typename: 'ProductVariantCountableEdge', node: { __typename: 'ProductVariant', id: string, quantityOrdered: number | null, revenue: { __typename: 'TaxedMoney', gross: { __typename: 'Money', amount: number, currency: string } } | null, attributes: Array<{ __typename: 'SelectedAttribute', values: Array<{ __typename: 'AttributeValue', id: string, name: string | null }> }>, product: { __typename: 'Product', id: string, name: string, thumbnail: { __typename: 'Image', url: string } | null } } }> } | null, activities: { __typename: 'OrderEventCountableConnection', edges: Array<{ __typename: 'OrderEventCountableEdge', node: { __typename: 'OrderEvent', amount: number | null, composedId: string | null, date: any | null, email: string | null, emailType: OrderEventsEmailsEnum | null, id: string, message: string | null, orderNumber: string | null, oversoldItems: Array | null, quantity: number | null, type: OrderEventsEnum | null, user: { __typename: 'User', id: string, email: string } | null } }> } | null }; export type MenuCreateMutationVariables = Exact<{ input: MenuCreateInput; diff --git a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx b/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx deleted file mode 100644 index 14ab07c6148..00000000000 --- a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import RequirePermissions from "@dashboard/components/RequirePermissions"; -import ResponsiveTable from "@dashboard/components/ResponsiveTable"; -import Skeleton from "@dashboard/components/Skeleton"; -import TableRowLink from "@dashboard/components/TableRowLink"; -import { PermissionEnum } from "@dashboard/graphql"; -import { - Card, - CardContent, - TableBody, - TableCell, - Typography, -} from "@material-ui/core"; -import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; -import { makeStyles } from "@saleor/macaw-ui"; -import { vars } from "@saleor/macaw-ui/next"; -import React from "react"; -import { useIntl } from "react-intl"; - -import { homeNotificationTableMessages as messages } from "./messages"; - -const useStyles = makeStyles( - () => ({ - arrowIcon: { - textAlign: "right", - width: "100%", - display: "flex", - alignItems: "center", - justifyContent: "flex-end", - }, - tableCard: { - overflow: "hidden", - borderRadius: 0, - }, - tableRow: { - cursor: "pointer", - /* Table to be replaced with Box */ - "& .MuiTableCell-root": { - paddingLeft: `${vars.spacing[5]} !important`, - paddingRight: `${vars.spacing[5]} !important`, - }, - }, - cardContent: { - padding: 0, - }, - }), - { name: "HomeNotificationTable" }, -); - -interface HomeNotificationTableProps { - ordersToCapture: number; - ordersToFulfill: number; - productsOutOfStock: number; - createNewChannelHref: string; - ordersToFulfillHref: string; - ordersToCaptureHref: string; - productsOutOfStockHref: string; - noChannel: boolean; -} - -const HomeNotificationTable: React.FC = props => { - const { - createNewChannelHref, - ordersToFulfillHref, - ordersToCaptureHref, - productsOutOfStockHref, - ordersToCapture, - ordersToFulfill, - productsOutOfStock, - noChannel, - } = props; - - const classes = useStyles(props); - - const intl = useIntl(); - - return ( - - - - - {noChannel && ( - - - - - {intl.formatMessage(messages.createNewChannel)} - - - - - - - - )} - - - - {ordersToFulfill === undefined ? ( - - ) : ordersToFulfill === 0 ? ( - - {intl.formatMessage(messages.noOrders)} - - ) : ( - - {intl.formatMessage(messages.orderReady, { - amount: {ordersToFulfill}, - })} - - )} - - - - - - - - {ordersToCapture === undefined ? ( - - ) : ordersToCapture === 0 ? ( - - {intl.formatMessage(messages.noPaymentWaiting)} - - ) : ( - - {intl.formatMessage(messages.paymentCapture, { - amount: {ordersToCapture}, - })} - - )} - - - - - - - - - - {productsOutOfStock === undefined ? ( - - ) : productsOutOfStock === 0 ? ( - - {intl.formatMessage(messages.noProductsOut)} - - ) : ( - - {intl.formatMessage(messages.productOut, { - amount: {productsOutOfStock}, - })} - - )} - - - - - - - - - - - ); -}; -HomeNotificationTable.displayName = "HomeNotificationTable"; -export default HomeNotificationTable; diff --git a/src/home/components/HomeNotificationTable/index.ts b/src/home/components/HomeNotificationTable/index.ts deleted file mode 100644 index 5f13ce2da77..00000000000 --- a/src/home/components/HomeNotificationTable/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from "./HomeNotificationTable"; -export * from "./HomeNotificationTable"; diff --git a/src/home/components/HomeNotificationTable/messages.ts b/src/home/components/HomeNotificationTable/messages.ts deleted file mode 100644 index b5f3002b8ac..00000000000 --- a/src/home/components/HomeNotificationTable/messages.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { defineMessages } from "react-intl"; - -export const homeNotificationTableMessages = defineMessages({ - createNewChannel: { - id: "Nuq83+", - defaultMessage: "Create new channel", - }, - noOrders: { - id: "E9Jssl", - defaultMessage: "No orders ready to fulfill", - }, - noPaymentWaiting: { - id: "5dyOs0", - defaultMessage: "No payments waiting for capture", - }, - noProductsOut: { - id: "bFhzRX", - defaultMessage: "No products are out of stock", - }, - orderReady: { - id: "c0H45L", - defaultMessage: - "{amount, plural,one {One order is ready to fulfill} other {{amount} orders are ready to fulfill}}", - }, - paymentCapture: { - id: "md326v", - defaultMessage: - "{amount, plural,one {One payment to capture}other {{amount} payments to capture}}", - }, - productOut: { - id: "cdxwA8", - defaultMessage: - "{amount, plural,one {One product out of stock}other {{amount} products out of stock}}", - }, -}); diff --git a/src/home/components/HomePage/HomePage.stories.tsx b/src/home/components/HomePage/HomePage.stories.tsx index 37a5bf7e8b9..2618c08e2ac 100644 --- a/src/home/components/HomePage/HomePage.stories.tsx +++ b/src/home/components/HomePage/HomePage.stories.tsx @@ -15,12 +15,7 @@ const homePageProps: Omit = { activities: mapEdgesToItems(shop.activities), noChannel: false, createNewChannelHref: "", - ordersToFulfillHref: "", - ordersToCaptureHref: "", productsOutOfStockHref: "", - orders: shop.ordersToday.totalCount, - ordersToCapture: shop.ordersToCapture.totalCount, - ordersToFulfill: shop.ordersToFulfill.totalCount, productsOutOfStock: shop.productsOutOfStock.totalCount, sales: shop.salesToday.gross, topProducts: mapEdgesToItems(shop.productTopToday), diff --git a/src/home/components/HomePage/HomePage.tsx b/src/home/components/HomePage/HomePage.tsx index 582615d60da..4611e6e9acc 100644 --- a/src/home/components/HomePage/HomePage.tsx +++ b/src/home/components/HomePage/HomePage.tsx @@ -14,22 +14,16 @@ import { useIntl } from "react-intl"; import HomeActivityCard from "../HomeActivityCard"; import HomeAnalyticsCard from "../HomeAnalyticsCard"; import HomeHeader from "../HomeHeader"; -import HomeNotificationTable from "../HomeNotificationTable/HomeNotificationTable"; import HomeProductListCard from "../HomeProductListCard"; import { homePageMessages } from "./messages"; export interface HomePageProps { activities: RelayToFlat; - orders: number | null; - ordersToCapture: number | null; - ordersToFulfill: number | null; productsOutOfStock: number; sales: HomeQuery["salesToday"]["gross"]; topProducts: RelayToFlat | null; userName: string; createNewChannelHref: string; - ordersToFulfillHref: string; - ordersToCaptureHref: string; productsOutOfStockHref: string; noChannel: boolean; } @@ -37,16 +31,9 @@ export interface HomePageProps { const HomePage: React.FC = props => { const { userName, - orders, sales, topProducts, activities, - createNewChannelHref, - ordersToFulfillHref, - ordersToCaptureHref, - productsOutOfStockHref, - ordersToCapture = 0, - ordersToFulfill = 0, productsOutOfStock = 0, noChannel, } = props; @@ -59,7 +46,10 @@ const HomePage: React.FC = props => { = props => { )} {noChannel ? ( 0 - ) : orders !== undefined ? ( - orders + ) : productsOutOfStock !== undefined ? ( + productsOutOfStock ) : ( )} - {topProducts && ( HomeQuery = ( }, ], }, - ordersToCapture: { - __typename: "OrderCountableConnection", - totalCount: 0, - }, - ordersToFulfill: { - __typename: "OrderCountableConnection", - totalCount: 1, - }, - ordersToday: { - __typename: "OrderCountableConnection", - totalCount: 1, - }, productTopToday: { __typename: "ProductVariantCountableConnection", edges: [ diff --git a/src/home/queries.ts b/src/home/queries.ts index 489310656a8..eac32f4811a 100644 --- a/src/home/queries.ts +++ b/src/home/queries.ts @@ -3,7 +3,6 @@ import { gql } from "@apollo/client"; export const home = gql` query Home( $channel: String! - $datePeriod: DateRangeInput! $PERMISSION_MANAGE_PRODUCTS: Boolean! $PERMISSION_MANAGE_ORDERS: Boolean! ) { @@ -14,22 +13,6 @@ export const home = gql` currency } } - ordersToday: orders(filter: { created: $datePeriod }, channel: $channel) - @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } - ordersToFulfill: orders( - filter: { status: READY_TO_FULFILL } - channel: $channel - ) @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } - ordersToCapture: orders( - filter: { status: READY_TO_CAPTURE } - channel: $channel - ) @include(if: $PERMISSION_MANAGE_ORDERS) { - totalCount - } productsOutOfStock: products( filter: { stockAvailability: OUT_OF_STOCK } channel: $channel diff --git a/src/home/views/index.tsx b/src/home/views/index.tsx index a6ae3241844..f8bce5ae0f5 100644 --- a/src/home/views/index.tsx +++ b/src/home/views/index.tsx @@ -2,16 +2,11 @@ import { useUser } from "@dashboard/auth"; import { channelsListUrl } from "@dashboard/channels/urls"; import useAppChannel from "@dashboard/components/AppLayout/AppChannelContext"; -import { - OrderStatusFilter, - StockAvailability, - useHomeQuery, -} from "@dashboard/graphql"; +import { StockAvailability, useHomeQuery } from "@dashboard/graphql"; import { mapEdgesToItems } from "@dashboard/utils/maps"; import React from "react"; -import { getDatePeriod, getUserName } from "../../misc"; -import { orderListUrl } from "../../orders/urls"; +import { getUserName } from "../../misc"; import { productListUrl } from "../../products/urls"; import HomePage from "../components/HomePage"; @@ -24,30 +19,19 @@ const HomeSection = () => { const { data } = useHomeQuery({ displayLoader: true, skip: noChannel, - variables: { channel: channel?.slug, datePeriod: getDatePeriod(1) }, + variables: { channel: channel?.slug }, }); return (