UNPKG

@myorders/storefront-engine

Version:

Headless Commerce & Marketplace Extension for Myorders

36 lines (31 loc) 1.23 kB
import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; import { action, set } from '@ember/object'; import isNestedRouteTransition from '@myorders/ember-core/utils/is-nested-route-transition'; export default class CustomersIndexRoute extends Route { @service store; @service storefront; queryParams = { page: { refreshModel: true }, limit: { refreshModel: true }, sort: { refreshModel: true }, query: { refreshModel: true }, status: { refreshModel: true }, phone: { refreshModel: true }, email: { refreshModel: true }, address: { refreshModel: true }, public_id: { refreshModel: true }, internal_id: { refreshModel: true }, created_at: { refreshModel: true }, updated_at: { refreshModel: true }, }; @action willTransition(transition) { if (isNestedRouteTransition(transition)) { set(this.queryParams, 'page.refreshModel', false); set(this.queryParams, 'sort.refreshModel', false); } } model(params) { return this.store.query('customer', { ...params, storefront: this.storefront.getActiveStore('public_id') }); } }