Skip to content

Commit

Permalink
feat(admin-ui): Correctly display cancelled Fulfillments
Browse files Browse the repository at this point in the history
Relates to #565
  • Loading branch information
michaelbromley committed Nov 25, 2020
1 parent 3245e00 commit 7efe800
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/admin-ui/src/lib/core/src/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5152,6 +5152,10 @@ export type OrderFragment = (
export type FulfillmentFragment = (
{ __typename?: 'Fulfillment' }
& Pick<Fulfillment, 'id' | 'state' | 'nextStates' | 'createdAt' | 'updatedAt' | 'method' | 'trackingCode'>
& { orderItems: Array<(
{ __typename?: 'OrderItem' }
& Pick<OrderItem, 'id'>
)> }
);

export type OrderLineFragment = (
Expand Down Expand Up @@ -7691,6 +7695,7 @@ export namespace Order {

export namespace Fulfillment {
export type Fragment = FulfillmentFragment;
export type OrderItems = NonNullable<(NonNullable<FulfillmentFragment['orderItems']>)[number]>;
}

export namespace OrderLine {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const FULFILLMENT_FRAGMENT = gql`
createdAt
updatedAt
method
orderItems {
id
}
trackingCode
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class FulfillmentDetailComponent {

get items(): Array<{ name: string; quantity: number }> {
const itemMap = new Map<string, number>();
const fulfillmentItemIds = this.fulfillment?.orderItems.map(i => i.id);
for (const line of this.order.lines) {
for (const item of line.items) {
if (item.fulfillment && item.fulfillment.id === this.fulfillmentId) {
if (fulfillmentItemIds?.includes(item.id)) {
const count = itemMap.get(line.productVariant.name);
if (count != null) {
itemMap.set(line.productVariant.name, count + 1);
Expand Down

0 comments on commit 7efe800

Please sign in to comment.