Skip to content

Commit

Permalink
fix(admin-ui): Correctly sort customer orders in detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jul 4, 2023
1 parent b989607 commit 86a17af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ export function detailComponentWithResolver<
query: T;
entityKey: R;
getBreadcrumbs?: (entity: ResultOf<T>[R]) => BreadcrumbValue;
variables?: T extends TypedDocumentNode<any, infer V> ? Omit<V, 'id'> : never;
}) {
const resolveFn: ResolveFn<{ entity: Observable<ResultOf<T>[Field] | null>; result?: ResultOf<T> }> = (
route,
state,
) => {
const resolveFn: ResolveFn<{
entity: Observable<ResultOf<T>[Field] | null>;
result?: ResultOf<T>;
}> = route => {
const router = inject(Router);
const dataService = inject(DataService);
const id = route.paramMap.get('id');
Expand All @@ -268,7 +269,7 @@ export function detailComponentWithResolver<
return of({ entity: of(null) });
} else {
const result$ = dataService
.query(config.query, { id })
.query(config.query, { id, ...(config.variables ?? {}) })
.refetchOnChannelChange()
.stream$.pipe(takeUntil(navigateAway$), shareReplay(1));
const entity$ = result$.pipe(map(result => result[config.entityKey]));
Expand Down
8 changes: 8 additions & 0 deletions packages/admin-ui/src/lib/customer/src/customer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
GetCustomerGroupDetailDocument,
PageService,
SharedModule,
SortOrder,
} from '@vendure/admin-ui/core';

import { AddCustomerToGroupDialogComponent } from './components/add-customer-to-group-dialog/add-customer-to-group-dialog.component';
Expand Down Expand Up @@ -80,6 +81,13 @@ export class CustomerModule {
component: CustomerDetailComponent,
query: CustomerDetailQueryDocument,
entityKey: 'customer',
variables: {
orderListOptions: {
sort: {
orderPlacedAt: SortOrder.DESC,
},
},
},
getBreadcrumbs: entity => [
{
label: entity
Expand Down

0 comments on commit 86a17af

Please sign in to comment.