Fix fulfilling deleted variants (#2090)

* Add optional chaining

* Fix type

* Fix a similar bug in the stock exceeded dialog

* Add keys to fulfillment lines

* Add undefined to return type
This commit is contained in:
Michał Droń 2022-07-07 17:28:12 +02:00 committed by GitHub
parent a54fc0396b
commit 3ac4ac4c1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -230,6 +230,7 @@ const OrderFulfillPage: React.FC<OrderFulfillPageProps> = props => {
getToFulfillOrderLines(order?.lines), getToFulfillOrderLines(order?.lines),
(line: OrderFulfillLineFragment, lineIndex) => ( (line: OrderFulfillLineFragment, lineIndex) => (
<OrderFulfillLine <OrderFulfillLine
key={line.id}
line={line} line={line}
lineIndex={lineIndex} lineIndex={lineIndex}
warehouseId={warehouse?.id} warehouseId={warehouse?.id}

View file

@ -38,7 +38,7 @@ const OrderFulfillStockExceededDialogLine: React.FC<OrderFulfillStockExceededDia
thumbnail={line?.thumbnail?.url} thumbnail={line?.thumbnail?.url}
> >
{line?.productName} {line?.productName}
{"attributes" in line.variant && ( {line.variant && "attributes" in line.variant && (
<Typography color="textSecondary" variant="caption"> <Typography color="textSecondary" variant="caption">
{getAttributesCaption(line.variant?.attributes)} {getAttributesCaption(line.variant?.attributes)}
</Typography> </Typography>

View file

@ -372,10 +372,10 @@ export const transformFuflillmentLinesToStockInputFormsetData = (
})); }));
export const getAttributesCaption = ( export const getAttributesCaption = (
attributes: OrderFulfillLineFragment["variant"]["attributes"], attributes: OrderFulfillLineFragment["variant"]["attributes"] | undefined,
): string => ): string | undefined =>
attributes attributes
.map(attribute => ?.map(attribute =>
attribute.values.map(attributeValue => attributeValue.name).join(", "), attribute.values.map(attributeValue => attributeValue.name).join(", "),
) )
.join(" / "); .join(" / ");