Fix warehouse selection
This commit is contained in:
parent
bc15224fcd
commit
27a740ed6b
3 changed files with 19 additions and 6 deletions
|
@ -116,8 +116,8 @@ const OrderFulfillment: React.FC<OrderFulfillmentProps> = props => {
|
||||||
)
|
)
|
||||||
: intl.formatMessage(
|
: intl.formatMessage(
|
||||||
{
|
{
|
||||||
defaultMessage: "Fulfilled ({quantity})",
|
defaultMessage: "Cancelled ({quantity})",
|
||||||
description: "section header"
|
description: "cancelled fulfillment, section header"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
quantity
|
quantity
|
||||||
|
|
|
@ -21,7 +21,7 @@ import SingleAutocompleteSelectField from "@saleor/components/SingleAutocomplete
|
||||||
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
||||||
|
|
||||||
export interface OrderFulfillmentCancelDialogFormData {
|
export interface OrderFulfillmentCancelDialogFormData {
|
||||||
warehouse: string;
|
warehouseId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
|
@ -77,7 +77,7 @@ const OrderFulfillmentCancelDialog: React.FC<OrderFulfillmentCancelDialogProps>
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="sm"
|
maxWidth="sm"
|
||||||
>
|
>
|
||||||
<Form initial={{ warehouse: null }} onSubmit={onConfirm}>
|
<Form initial={{ warehouseId: null }} onSubmit={onConfirm}>
|
||||||
{({ change, data: formData, submit }) => {
|
{({ change, data: formData, submit }) => {
|
||||||
const handleChange = createSingleAutocompleteSelectHandler(
|
const handleChange = createSingleAutocompleteSelectHandler(
|
||||||
change,
|
change,
|
||||||
|
@ -104,8 +104,8 @@ const OrderFulfillmentCancelDialog: React.FC<OrderFulfillmentCancelDialogProps>
|
||||||
defaultMessage: "Select Warehouse",
|
defaultMessage: "Select Warehouse",
|
||||||
description: "select warehouse to restock items"
|
description: "select warehouse to restock items"
|
||||||
})}
|
})}
|
||||||
name="warehouse"
|
name="warehouseId"
|
||||||
value={formData.warehouse}
|
value={formData.warehouseId}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -125,6 +125,7 @@ const OrderFulfillmentCancelDialog: React.FC<OrderFulfillmentCancelDialogProps>
|
||||||
<FormattedMessage {...buttonMessages.back} />
|
<FormattedMessage {...buttonMessages.back} />
|
||||||
</Button>
|
</Button>
|
||||||
<ConfirmButton
|
<ConfirmButton
|
||||||
|
disabled={formData.warehouseId === null}
|
||||||
transitionState={confirmButtonState}
|
transitionState={confirmButtonState}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={submit}
|
onClick={submit}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import useUser from "@saleor/hooks/useUser";
|
||||||
import useCustomerSearch from "@saleor/searches/useCustomerSearch";
|
import useCustomerSearch from "@saleor/searches/useCustomerSearch";
|
||||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||||
import NotFoundPage from "@saleor/components/NotFoundPage";
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
||||||
|
import { useWarehouseList } from "@saleor/warehouses/queries";
|
||||||
import { customerUrl } from "../../../customers/urls";
|
import { customerUrl } from "../../../customers/urls";
|
||||||
import {
|
import {
|
||||||
maybe,
|
maybe,
|
||||||
|
@ -95,6 +96,12 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
||||||
} = useOrderVariantSearch({
|
} = useOrderVariantSearch({
|
||||||
variables: DEFAULT_INITIAL_SEARCH_DATA
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
||||||
});
|
});
|
||||||
|
const warehouses = useWarehouseList({
|
||||||
|
displayLoader: true,
|
||||||
|
variables: {
|
||||||
|
first: 30
|
||||||
|
}
|
||||||
|
});
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const [openModal, closeModal] = createDialogActionHandlers<
|
const [openModal, closeModal] = createDialogActionHandlers<
|
||||||
|
@ -339,6 +346,11 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
||||||
?.orderFulfillmentCancel.errors || []
|
?.orderFulfillmentCancel.errors || []
|
||||||
}
|
}
|
||||||
open={params.action === "cancel-fulfillment"}
|
open={params.action === "cancel-fulfillment"}
|
||||||
|
warehouses={
|
||||||
|
warehouses.data?.warehouses.edges.map(
|
||||||
|
edge => edge.node
|
||||||
|
) || []
|
||||||
|
}
|
||||||
onConfirm={variables =>
|
onConfirm={variables =>
|
||||||
orderFulfillmentCancel.mutate({
|
orderFulfillmentCancel.mutate({
|
||||||
id: params.id,
|
id: params.id,
|
||||||
|
|
Loading…
Reference in a new issue