feat(cardex): implement cardex module with filters, templates, and service integration
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { getFullName } from '@/utils';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map, Observable } from 'rxjs';
|
||||
import { CARDEX_API_ROUTES } from '../constants';
|
||||
import { ICardexRawResponse, ICardexRequestPayload, ICardexResponse } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CardexService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = CARDEX_API_ROUTES;
|
||||
|
||||
getCardex(params: ICardexRequestPayload): Observable<IPaginatedResponse<ICardexResponse>> {
|
||||
return this.http
|
||||
.get<IPaginatedResponse<ICardexRawResponse>>(this.apiRoutes.cardex(), {
|
||||
params: { ...params },
|
||||
})
|
||||
.pipe(
|
||||
map((res) => {
|
||||
return {
|
||||
meta: res.meta,
|
||||
data: res.data.map((item) => ({
|
||||
...item,
|
||||
supplier: item.supplier
|
||||
? {
|
||||
...item.supplier,
|
||||
name: getFullName(item.supplier),
|
||||
}
|
||||
: undefined,
|
||||
customer: item.customer
|
||||
? {
|
||||
...item.customer,
|
||||
name: getFullName(item.customer),
|
||||
}
|
||||
: undefined,
|
||||
})),
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user