@symanticreative/vendure-admin-client
Version:
A TypeScript GraphQL client for Vendure Admin API to create custom dashboards
81 lines • 2.93 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Injectable } from '../core/di/injectable.decorator';
import { BasePaginatedService } from './base.service';
/**
* Service for order operations
*/
let OrderService = class OrderService extends BasePaginatedService {
constructor(orderRepository) {
super(orderRepository);
this.orderRepository = orderRepository;
}
/**
* Update order status
* @param input - Order status update input
* @returns Promise resolving to updated order
*/
async updateOrderStatus(input) {
// Add any business logic, validation, or transformations here
return this.orderRepository.updateOrderStatus(input);
}
/**
* Get orders by customer
* @param customerId - Customer ID
* @param options - Pagination options
* @returns Promise resolving to paginated orders
*/
async getOrdersByCustomer(customerId, options = {}) {
const orderOptions = {
...options,
filter: {
...(options.filter || {}),
customer: { id: { eq: customerId } }
}
};
return this.getPaginated(orderOptions);
}
/**
* Get orders by status
* @param status - Order status
* @param options - Pagination options
* @returns Promise resolving to paginated orders
*/
async getOrdersByStatus(status, options = {}) {
const orderOptions = {
...options,
filter: {
...(options.filter || {}),
state: { eq: status }
}
};
return this.getPaginated(orderOptions);
}
/**
* Search orders by term
* @param term - Search term
* @param options - Pagination options
* @returns Promise resolving to paginated orders
*/
async searchOrders(term, options = {}) {
// Search in order code or customer name/email
const searchOptions = {
...options,
filter: {
...(options.filter || {}),
code: { contains: term }
// Note: In a real implementation, we would also search by customer
}
};
return this.getPaginated(searchOptions);
}
};
OrderService = __decorate([
Injectable()
], OrderService);
export { OrderService };
//# sourceMappingURL=order.service.js.map