fix(admin-ui): Fix effect check in inventory table and overflow UI (#3577)

* Fix effect check in inventory table and overflow UI

* Create ten-berries-rest.md

* Fix edit stock&inventory modal to use the right form

* Fix faulty merge conflict resolution

* Fix inventory item creation

* Add redirect to locations tab if no locations, toast

* Revert redirect and toast, add message in table

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Rares StefanandOliver Windall Juhl authored and GitHub committed 2023-03-27 20:48:47 +02:00
1 parent feaf8d2e19
commit 95c9fbfdd5
5 files changed
+20 -6

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): Fix effect check in inventory table and overflow UI
@@ -52,7 +52,7 @@ const BodyCard: React.FC<BodyCardProps> = ({
)} )}
</div> </div>
<div <div
className={clsx("flex grow flex-col overflow-y-auto", { className={clsx("flex grow flex-col", {
"border-grey-20 border-b border-solid": setBorders, "border-grey-20 border-b border-solid": setBorders,
})} })}
onScroll={scrollListener} onScroll={scrollListener}
@@ -1,6 +1,6 @@
import EditFlowVariantForm, { import EditFlowVariantForm, {
EditFlowVariantFormType, EditFlowVariantFormType,
} from "../../forms/product/variant-form/edit-flow-variant-form" } from "../../forms/product/variant-inventory-form/edit-flow-variant-form"
import LayeredModal, { import LayeredModal, {
LayeredModalContext, LayeredModalContext,
} from "../../molecules/modal/layered-modal" } from "../../molecules/modal/layered-modal"
@@ -48,10 +48,10 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
const { onUpdateVariant, updatingVariant } = useEditProductActions(product.id) const { onUpdateVariant, updatingVariant } = useEditProductActions(product.id)
const onSubmit = async (data: EditFlowVariantFormType) => { const onSubmit = async (data: EditFlowVariantFormType) => {
const locationLevels = data.stock.stock_location || [] const locationLevels = data.stock.location_levels || []
const manageInventory = data.stock.manage_inventory const manageInventory = data.stock.manage_inventory
delete data.stock.manage_inventory delete data.stock.manage_inventory
delete data.stock.stock_location delete data.stock.location_levels
let inventoryItemId: string | undefined = itemId let inventoryItemId: string | undefined = itemId
@@ -176,6 +176,7 @@ const StockForm = ({
updatingVariant: boolean updatingVariant: boolean
}) => { }) => {
const form = useForm<EditFlowVariantFormType>({ const form = useForm<EditFlowVariantFormType>({
// @ts-ignore
defaultValues: getEditVariantDefaultValues(variantInventory), defaultValues: getEditVariantDefaultValues(variantInventory),
}) })
@@ -47,7 +47,7 @@ const LocationDropdown = ({
const { stock_locations: locations, isLoading } = useAdminStockLocations() const { stock_locations: locations, isLoading } = useAdminStockLocations()
useEffect(() => { useEffect(() => {
if (!selectedLocation && !isLoading && locations) { if (!selectedLocation && !isLoading && locations?.length) {
onChange(locations[0].id) onChange(locations[0].id)
} }
}, [isLoading, locations, onChange, selectedLocation]) }, [isLoading, locations, onChange, selectedLocation])
@@ -85,6 +85,9 @@ const InventoryTable: React.FC<InventoryTableProps> = () => {
const location = useLocation() const location = useLocation()
const { stock_locations, isLoading: locationsLoading } =
useAdminStockLocations()
const defaultQuery = useMemo(() => { const defaultQuery = useMemo(() => {
if (store) { if (store) {
return { return {
@@ -284,6 +287,11 @@ const InventoryTable: React.FC<InventoryTableProps> = () => {
})} })}
</Table.Body> </Table.Body>
</Table> </Table>
{!rows.length && !locationsLoading && !stock_locations?.length && (
<div className="text-grey-50 w-full py-8 text-center">
You don't have any stock locations. Add one to see inventory.
</div>
)}
</TableContainer> </TableContainer>
) )
} }
@@ -43,7 +43,7 @@ const Locations = () => {
) : ( ) : (
<div> <div>
{stock_locations?.map((stockLocation) => ( {stock_locations?.map((stockLocation) => (
<LocationCard location={stockLocation} /> <LocationCard key={stockLocation.id} location={stockLocation} />
))} ))}
</div> </div>
)} )}