chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s

This commit is contained in:
parsa committed 2026-08-07 07:39:26 +03:30
1 parent 4659a7b1de
commit 9f11d8fb2d
98 files changed
+1272 -1009

No files matched your search

+28 -25
View File
@@ -1,23 +1,31 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
export class CategoryQuery {
page?: number | string;
limit?: number | string;
search?: string;
}
@Injectable()
export class CategoriesService {
constructor(private prisma: PrismaService) {}
async getCategories(query: any) {
const { page = 1, limit = 10, search = '' } = query;
const skip = (Number(page) - 1) * Number(limit);
async getCategories(query: CategoryQuery = {}) {
const page = Number(query.page) || 1;
const limit = Number(query.limit) || 10;
const skip = (page - 1) * limit;
const where = search
? { name: { contains: search, mode: 'insensitive' as any } }
const where: Prisma.CategoryWhereInput = query.search
? { name: { contains: query.search, mode: 'insensitive' } }
: {};
const [data, total] = await Promise.all([
this.prisma.category.findMany({
where,
skip,
take: Number(limit),
take: limit,
orderBy: { createdAt: 'desc' },
}),
this.prisma.category.count({ where }),
@@ -27,9 +35,9 @@ export class CategoriesService {
data,
meta: {
total,
page: Number(page),
limit: Number(limit),
lastPage: Math.ceil(total / Number(limit)),
page,
limit,
lastPage: Math.ceil(total / limit),
},
};
}
@@ -38,28 +46,23 @@ export class CategoriesService {
return this.prisma.category.findMany({ orderBy: { name: 'asc' } });
}
async createCategory(data: any) {
const cleanData = { ...data };
Object.keys(cleanData).forEach((k) => {
if (cleanData[k] === '') cleanData[k] = null;
});
// Ensure required fields
if (!cleanData.slug)
cleanData.slug = cleanData.name.replace(/\s+/g, '-').toLowerCase();
async createCategory(data: Prisma.CategoryCreateInput) {
const nameStr = data.name || '';
const slugStr = data.slug || nameStr.replace(/\s+/g, '-').toLowerCase();
return this.prisma.category.create({ data: cleanData });
return this.prisma.category.create({
data: {
...data,
slug: slugStr,
},
});
}
async updateCategory(id: string, data: any) {
async updateCategory(id: string, data: Prisma.CategoryUpdateInput) {
const category = await this.prisma.category.findUnique({ where: { id } });
if (!category) throw new NotFoundException('Category not found');
const cleanData = { ...data };
Object.keys(cleanData).forEach((k) => {
if (cleanData[k] === '') cleanData[k] = null;
});
return this.prisma.category.update({ where: { id }, data: cleanData });
return this.prisma.category.update({ where: { id }, data });
}
async deleteCategory(id: string) {