Skip to content

Commit

Permalink
fix(admin-ui): Fix tax rate permissions so product variants do not ne…
Browse files Browse the repository at this point in the history
…ed access to customer groups (#1274)
  • Loading branch information
vrosa authored Dec 9, 2021
1 parent 5f5f767 commit 0a49fea
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class VariantPriceDetailComponent implements OnInit, OnChanges {

ngOnInit() {
const taxRates$ = this.dataService.settings
.getTaxRates(999, 0, 'cache-first')
.getTaxRatesSimple(999, 0, 'cache-first')
.mapStream(data => data.taxRates.items);
const activeChannel$ = this.dataService.settings
.getActiveChannel('cache-first')
Expand Down
30 changes: 30 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 @@ -7463,6 +7463,27 @@ export type GetTaxRateListQuery = { taxRates: (
)> }
) };

export type GetTaxRateListSimpleQueryVariables = Exact<{
options?: Maybe<TaxRateListOptions>;
}>;


export type GetTaxRateListSimpleQuery = { taxRates: (
{ __typename?: 'TaxRateList' }
& Pick<TaxRateList, 'totalItems'>
& { items: Array<(
{ __typename?: 'TaxRate' }
& Pick<TaxRate, 'id' | 'createdAt' | 'updatedAt' | 'name' | 'enabled' | 'value'>
& { category: (
{ __typename?: 'TaxCategory' }
& Pick<TaxCategory, 'id' | 'name'>
), zone: (
{ __typename?: 'Zone' }
& Pick<Zone, 'id' | 'name'>
) }
)> }
) };

export type GetTaxRateQueryVariables = Exact<{
id: Scalars['ID'];
}>;
Expand Down Expand Up @@ -9851,6 +9872,15 @@ export namespace GetTaxRateList {
export type Items = NonNullable<(NonNullable<(NonNullable<GetTaxRateListQuery['taxRates']>)['items']>)[number]>;
}

export namespace GetTaxRateListSimple {
export type Variables = GetTaxRateListSimpleQueryVariables;
export type Query = GetTaxRateListSimpleQuery;
export type TaxRates = (NonNullable<GetTaxRateListSimpleQuery['taxRates']>);
export type Items = NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>;
export type Category = (NonNullable<NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>['category']>);
export type Zone = (NonNullable<NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>['zone']>);
}

export namespace GetTaxRate {
export type Variables = GetTaxRateQueryVariables;
export type Query = GetTaxRateQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ export const GET_TAX_RATE_LIST = gql`
${TAX_RATE_FRAGMENT}
`;

export const GET_TAX_RATE_LIST_SIMPLE = gql`
query GetTaxRateListSimple($options: TaxRateListOptions) {
taxRates(options: $options) {
items {
id
createdAt
updatedAt
name
enabled
value
category {
id
name
}
zone {
id
name
}
}
totalItems
}
}
`;

export const GET_TAX_RATE = gql`
query GetTaxRate($id: ID!) {
taxRate(id: $id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
GetTaxCategory,
GetTaxRate,
GetTaxRateList,
GetTaxRateListSimple,
GetZone,
GetZones,
JobListOptions,
Expand Down Expand Up @@ -93,6 +94,7 @@ import {
GET_TAX_CATEGORY,
GET_TAX_RATE,
GET_TAX_RATE_LIST,
GET_TAX_RATE_LIST_SIMPLE,
GET_ZONES,
REMOVE_MEMBERS_FROM_ZONE,
UPDATE_CHANNEL,
Expand Down Expand Up @@ -243,6 +245,19 @@ export class SettingsDataService {
);
}

getTaxRatesSimple(take: number = 10, skip: number = 0, fetchPolicy?: FetchPolicy) {
return this.baseDataService.query<GetTaxRateListSimple.Query, GetTaxRateListSimple.Variables>(
GET_TAX_RATE_LIST_SIMPLE,
{
options: {
take,
skip,
},
},
fetchPolicy,
);
}

getTaxRate(id: string) {
return this.baseDataService.query<GetTaxRate.Query, GetTaxRate.Variables>(GET_TAX_RATE, {
id,
Expand Down

0 comments on commit 0a49fea

Please sign in to comment.