Skip to content

Commit

Permalink
feat(admin-ui): Display shipping calculator metadata
Browse files Browse the repository at this point in the history
Relates to #136
  • Loading branch information
michaelbromley committed Aug 9, 2019
1 parent bdbdf9a commit 4e5bce5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
23 changes: 13 additions & 10 deletions admin-ui/src/app/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,7 @@ export type ShippingMethodQuote = {
price: Scalars['Int'],
priceWithTax: Scalars['Int'],
description: Scalars['String'],
metadata?: Maybe<Scalars['JSON']>,
};

export type ShippingMethodSortParameter = {
Expand All @@ -3075,12 +3076,6 @@ export type ShippingMethodSortParameter = {
description?: Maybe<SortOrder>,
};

export type ShippingPrice = {
__typename?: 'ShippingPrice',
price: Scalars['Int'],
priceWithTax: Scalars['Int'],
};

/** The price value where the result has a single price */
export type SinglePrice = {
__typename?: 'SinglePrice',
Expand Down Expand Up @@ -3221,10 +3216,18 @@ export type TestShippingMethodOrderLineInput = {
quantity: Scalars['Int'],
};

export type TestShippingMethodQuote = {
__typename?: 'TestShippingMethodQuote',
price: Scalars['Int'],
priceWithTax: Scalars['Int'],
description: Scalars['String'],
metadata?: Maybe<Scalars['JSON']>,
};

export type TestShippingMethodResult = {
__typename?: 'TestShippingMethodResult',
eligible: Scalars['Boolean'],
price?: Maybe<ShippingPrice>,
quote?: Maybe<TestShippingMethodQuote>,
};

export type UiState = {
Expand Down Expand Up @@ -4289,14 +4292,14 @@ export type TestShippingMethodQueryVariables = {
};


export type TestShippingMethodQuery = ({ __typename?: 'Query' } & { testShippingMethod: ({ __typename?: 'TestShippingMethodResult' } & Pick<TestShippingMethodResult, 'eligible'> & { price: Maybe<({ __typename?: 'ShippingPrice' } & Pick<ShippingPrice, 'price' | 'priceWithTax'>)> }) });
export type TestShippingMethodQuery = ({ __typename?: 'Query' } & { testShippingMethod: ({ __typename?: 'TestShippingMethodResult' } & Pick<TestShippingMethodResult, 'eligible'> & { quote: Maybe<({ __typename?: 'TestShippingMethodQuote' } & Pick<TestShippingMethodQuote, 'price' | 'priceWithTax' | 'metadata'>)> }) });

export type TestEligibleShippingMethodsQueryVariables = {
input: TestEligibleShippingMethodsInput
};


export type TestEligibleShippingMethodsQuery = ({ __typename?: 'Query' } & { testEligibleShippingMethods: Array<({ __typename?: 'ShippingMethodQuote' } & Pick<ShippingMethodQuote, 'id' | 'description' | 'price' | 'priceWithTax'>)> });
export type TestEligibleShippingMethodsQuery = ({ __typename?: 'Query' } & { testEligibleShippingMethods: Array<({ __typename?: 'ShippingMethodQuote' } & Pick<ShippingMethodQuote, 'id' | 'description' | 'price' | 'priceWithTax' | 'metadata'>)> });
type DiscriminateUnion<T, U> = T extends U ? T : never;

type RequireField<T, TNames extends string> = T & { [P in TNames]: (T & { [name: string]: never })[P] };
Expand Down Expand Up @@ -5261,7 +5264,7 @@ export namespace TestShippingMethod {
export type Variables = TestShippingMethodQueryVariables;
export type Query = TestShippingMethodQuery;
export type TestShippingMethod = TestShippingMethodQuery['testShippingMethod'];
export type Price = (NonNullable<TestShippingMethodQuery['testShippingMethod']['price']>);
export type Quote = (NonNullable<TestShippingMethodQuery['testShippingMethod']['quote']>);
}

export namespace TestEligibleShippingMethods {
Expand Down
4 changes: 3 additions & 1 deletion admin-ui/src/app/data/definitions/shipping-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ export const TEST_SHIPPING_METHOD = gql`
query TestShippingMethod($input: TestShippingMethodInput!) {
testShippingMethod(input: $input) {
eligible
price {
quote {
price
priceWithTax
metadata
}
}
}
Expand All @@ -98,6 +99,7 @@ export const TEST_ELIGIBLE_SHIPPING_METHODS = gql`
description
price
priceWithTax
metadata
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{{ quote.priceWithTax / 100 | currency: currencyCode }}
</vdr-labeled-data>
</div>
<vdr-object-tree *ngIf="quote.metadata" [value]="quote.metadata"></vdr-object-tree>
</div>
</div>
<div class="card-block" *ngIf="testResult?.length === 0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@
<div class="price-row">
<vdr-labeled-data
[label]="'common.price' | translate"
*ngIf="testResult?.price?.price != null"
*ngIf="testResult?.quote?.price != null"
>
{{ testResult.price.price / 100 | currency: currencyCode }}
{{ testResult.quote.price / 100 | currency: currencyCode }}
</vdr-labeled-data>
<vdr-labeled-data
[label]="'common.price-with-tax' | translate"
*ngIf="testResult?.price?.priceWithTax != null"
*ngIf="testResult?.quote?.priceWithTax != null"
>
{{ testResult.price.priceWithTax / 100 | currency: currencyCode }}
{{ testResult.quote.priceWithTax / 100 | currency: currencyCode }}
</vdr-labeled-data>
</div>
<vdr-object-tree
*ngIf="testResult?.quote?.metadata"
[value]="testResult?.quote?.metadata"
></vdr-object-tree>
</div>
</div>
<div class="card-footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td class="align-middle quantity">
<input
[(ngModel)]="line.quantity"
(change)="orderLinesChange.emit(lines)"
(change)="updateQuantity()"
type="number"
max="9999"
min="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ export class TestOrderBuilderComponent implements OnInit {
}
}

removeLine(line: TestOrderLine) {
this.lines = this.lines.filter(l => l.id !== line.id);
this.persistToLocalStorage();
this.orderLinesChange.emit(this.lines);
}

private addToLines(result: SearchForTestOrder.Items) {
if (!this.lines.find(l => l.id === result.productVariantId)) {
this.lines.push({
Expand All @@ -87,6 +81,17 @@ export class TestOrderBuilderComponent implements OnInit {
}
}

private updateQuantity() {
this.persistToLocalStorage();
this.orderLinesChange.emit(this.lines);
}

removeLine(line: TestOrderLine) {
this.lines = this.lines.filter(l => l.id !== line.id);
this.persistToLocalStorage();
this.orderLinesChange.emit(this.lines);
}

private initSearchResults() {
const searchItems$ = this.searchInput$.pipe(
debounceTime(200),
Expand Down

0 comments on commit 4e5bce5

Please sign in to comment.