Fix(admin-ui): multi warehouse minor fixes (#3540)

**What**
1. Enable the "create location" button in "create stock location" when a field has changed
2. Remove the "successful delete" toast when cancelling stock location creation
3. Properly update available and reserved when editing stock levels for variant
4. invalidate inventoryItemList queryKeys when changing location levels

**Why**
- we had the same bug with form validation when creating location levels as we had when editing them (1)
- when updating location levels, listing inventory items wouldn't show the newly added location levels (4)
- fixing ui bugs (2, 4)
This commit is contained in:
Philip Korsholm
2023-03-24 14:11:40 +00:00
committed by GitHub
parent 332a9b686b
commit 284578a67a
5 changed files with 68 additions and 37 deletions
@@ -47,7 +47,7 @@ const NewLocation = ({ onClose }: { onClose: () => void }) => {
})
const {
handleSubmit,
formState: { isDirty, isValid },
formState: { isDirty },
} = form
const {
@@ -63,7 +63,10 @@ const NewLocation = ({ onClose }: { onClose: () => void }) => {
const { mutateAsync: associateSalesChannel } =
useAdminAddLocationToSalesChannel()
const createSalesChannelAssociationPromise = (salesChannelId, locationId) =>
const createSalesChannelAssociationPromise = (
salesChannelId: string,
locationId: string
) =>
associateSalesChannel({
sales_channel_id: salesChannelId,
location_id: locationId,
@@ -126,7 +129,7 @@ const NewLocation = ({ onClose }: { onClose: () => void }) => {
heading="Are you sure you want to cancel with unsaved changes"
confirmText="Yes, cancel"
cancelText="No, continue creating"
successText={undefined}
successText={false}
handleClose={closeClosePrompt}
onDelete={async () => onClose()}
/>
@@ -136,7 +139,7 @@ const NewLocation = ({ onClose }: { onClose: () => void }) => {
size="small"
variant="primary"
type="button"
disabled={!isDirty || !isValid}
disabled={!isDirty}
onClick={onSubmit()}
>
Add location