Skip to content

Commit 943ef1c

Browse files
committed
Make InStockProduct toast closable
1 parent f248e87 commit 943ef1c

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

front/src/hooks/hooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { selectedBaseIdAtom } from "stores/globalPreferenceStore";
1010

1111
export interface INotificationProps extends UseToastOptions {
1212
title?: string;
13-
message?: string;
13+
message?: string | Element;
1414
type?: "info" | "warning" | "success" | "error" | undefined;
1515
position?: ToastPosition;
1616
}

front/src/views/Products/ProductsView.tsx

+15-39
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { useNavigate } from "react-router-dom";
33
import { useMutation, useQuery } from "@apollo/client";
44
import { CellProps, Column } from "react-table";
55
import {
6-
Alert,
7-
AlertDescription,
8-
AlertIcon,
9-
AlertTitle,
10-
Box,
116
Button,
127
Heading,
138
Skeleton,
@@ -97,37 +92,6 @@ export const DISABLE_STANDARD_PRODUCT_MUTATION = graphql(
9792
[PRODUCT_BASIC_FIELDS_FRAGMENT],
9893
);
9994

100-
function InStockProductAlert({
101-
instockItemsCount,
102-
productName,
103-
}: {
104-
instockItemsCount?: number;
105-
productName?: string;
106-
// locations?: string, // TODO: should be derived from product locations somehow
107-
}) {
108-
return (
109-
<Alert status="error" data-testid="ErrorAlertProduct">
110-
<>
111-
<AlertIcon />
112-
<Box display="flex" flexDirection="column">
113-
<AlertTitle>Disabling Product with Active Stock</AlertTitle>
114-
<AlertDescription>
115-
You are attempting to disable the product {productName} with {instockItemsCount}{" "}
116-
<Text fontWeight="600" color="#659A7E" display="inline">
117-
InStock, MarkedForShipment, InTransit, or Receiving
118-
</Text>{" "}
119-
items in one or more locations. To continue, you must first reclassify all{" "}
120-
<Text fontWeight="600" color="#659A7E" display="inline">
121-
InStock
122-
</Text>{" "}
123-
boxes as a different product, or complete your shipments.
124-
</AlertDescription>
125-
</Box>
126-
</>
127-
</Alert>
128-
);
129-
}
130-
13195
function Products() {
13296
const { isLoading: isGlobalStateLoading } = useLoadAndSetGlobalPreferences();
13397
const baseId = useAtomValue(selectedBaseIdAtom);
@@ -163,10 +127,22 @@ function Products() {
163127
(instantiationId?: string, instockItemsCount?: number, productName?: string) => {
164128
if (instockItemsCount !== undefined && instockItemsCount > 0) {
165129
createToast({
166-
duration: 6000,
167-
render: () => (
168-
<InStockProductAlert instockItemsCount={instockItemsCount} productName={productName} />
130+
title: "Disabling Product with Active Stock",
131+
message: (
132+
<>
133+
You are attempting to disable the product {productName} with {instockItemsCount}{" "}
134+
<Text fontWeight="600" color="#659A7E" display="inline">
135+
InStock, MarkedForShipment, InTransit, or Receiving
136+
</Text>{" "}
137+
items in one or more locations. To continue, you must first reclassify all{" "}
138+
<Text fontWeight="600" color="#659A7E" display="inline">
139+
InStock
140+
</Text>{" "}
141+
boxes as a different product, or complete your shipments.
142+
</>
169143
),
144+
type: "error",
145+
duration: 10000
170146
});
171147
} else if (instantiationId) {
172148
disableStandardProductMutation({

0 commit comments

Comments
 (0)