Fix/missing environment variable type#7 #15
@@ -19,54 +19,30 @@ const get_all_order_from_db = async (req: Request) => {
|
||||
const status = (req.query.status as string) || undefined;
|
||||
const { page, limit, skip, sortBy, sortOrder } = paginationHelper(req.query);
|
||||
|
||||
const andCondition = [] as any[];
|
||||
const andCondition = {} as any;
|
||||
if (search) {
|
||||
andCondition.push({
|
||||
OR: [
|
||||
{
|
||||
productName: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
andCondition.productName = {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
if (customerName) {
|
||||
andCondition.push({
|
||||
OR: [
|
||||
{
|
||||
customerName: {
|
||||
contains: customerName,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
andCondition.customerName = {
|
||||
contains: customerName,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
if (productName) {
|
||||
andCondition.push({
|
||||
OR: [
|
||||
{
|
||||
productName: {
|
||||
contains: productName,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
andCondition.productName = {
|
||||
contains: productName,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
if (status) {
|
||||
andCondition.push({
|
||||
OR: [
|
||||
{
|
||||
status: {
|
||||
contains: status,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
andCondition.status = {
|
||||
contains: status,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
|
||||
// for date filter
|
||||
@@ -82,17 +58,13 @@ const get_all_order_from_db = async (req: Request) => {
|
||||
dateFilter.lte = end;
|
||||
}
|
||||
if (Object.keys(dateFilter).length > 0) {
|
||||
andCondition.push({
|
||||
createdAt: dateFilter,
|
||||
});
|
||||
andCondition.createdAt = dateFilter;
|
||||
}
|
||||
|
||||
const getAllOrders = await prisma.order.findMany({
|
||||
take: limit,
|
||||
skip,
|
||||
where: {
|
||||
AND: andCondition,
|
||||
},
|
||||
where: andCondition,
|
||||
select: {
|
||||
id: true,
|
||||
customerName: true,
|
||||
@@ -130,7 +102,7 @@ const get_single_order_from_db = async (req: Request) => {
|
||||
|
||||
const create_order_into_db = async (req: Request) => {
|
||||
const payload = req?.body;
|
||||
|
||||
|
||||
payload.status = "INITIATED";
|
||||
payload.paymentType = "COD";
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ export const orderSwaggerDocs = {
|
||||
patch: {
|
||||
tags: ["order"],
|
||||
summary: "Update order -(Admin route)",
|
||||
description: "",
|
||||
description: "The status can be updated to any of the following values : INITIATED,CONFIRMED,ONGOING,DELIVERED,CANCELLED",
|
||||
parameters: [
|
||||
{
|
||||
name: "id",
|
||||
|
||||
@@ -13,7 +13,7 @@ const create_order = z.object({
|
||||
customerNote: z.string().optional()
|
||||
});
|
||||
const update_order = z.object({
|
||||
status: z.string().optional()
|
||||
status: z.enum(["INITIATED","CONFIRMED","ONGOING","DELIVERED","CANCELLED"]).optional()
|
||||
});
|
||||
|
||||
export const order_validations = {
|
||||
|
||||
Reference in New Issue
Block a user