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