@fleetbase/storefront-engine
Version:
Headless Commerce & Marketplace Extension for Fleetbase
38 lines (33 loc) • 1.21 kB
JavaScript
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class CustomersIndexRoute extends Route {
store;
storefront;
intl;
abilities;
hostRouter;
notifications;
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 },
};
beforeModel() {
if (this.abilities.cannot('storefront list customer')) {
this.notifications.warning(this.intl.t('common.unauthorized-access'));
return this.hostRouter.transitionTo('console.storefront');
}
}
model(params) {
return this.store.query('customer', { ...params, storefront: this.storefront.getActiveStore('public_id') });
}
}