<div
*ngFor="let inquiry of inquiries | paginate:
{ itemsPerPage: pageInfo.itemsPerPage, currentPage: pageInfo.currentPage, totalItems: pageInfo.totalItems};index as i"
[routerLink]="['./', inquiry.id]"
>
<div>
{{setIndex(pageInfo, i)}}
</div>
setIndex(pageInfo: PageInfo, index: number) {
return (
pageInfo?.totalItems -
(index + 1 + pageInfo.itemsPerPage * (pageInfo.currentPage - 1)) +
1
);
}
async search(body: SearchOptionDTO<Policy>) {
const { align, orderBy, pageNo, pageSize, query } = body;
const _policies: any[] = await this.prismaService.policy.findMany({
where: {
title: { contains: query, mode: 'insensitive' },
},
skip: (pageNo - 1) * pageSize,
take: pageSize,
orderBy: { [orderBy]: align },
});
const count = await this.prismaService.policy.count({
where: {
title: { contains: query, mode: 'insensitive' },
},
});
const policies = _policies.map((p, index) => {
p.rowNumber = _policies.length - pageSize * (pageNo - 1) - index;
return p;
});
return { policies, count };
}