"feat: enhance invoice management with schema updates, seed data, and new APIs"
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
// src/app/api/product/saveProduct/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// save product to db by id
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* PUT - change order status
|
||||
*************************************** */
|
||||
export async function PUT(req: NextRequest) {
|
||||
// logger('[Invoice] list', products.length);
|
||||
const { searchParams } = req.nextUrl;
|
||||
const invoiceId = searchParams.get('invoiceId');
|
||||
|
||||
// RULES: invoiceId must exist
|
||||
if (!invoiceId) {
|
||||
return response({ message: 'Invoice ID is required!' }, STATUS.BAD_REQUEST);
|
||||
}
|
||||
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
const order = await prisma.invoiceItem.updateMany({
|
||||
where: { id: invoiceId },
|
||||
data: { status: data.status },
|
||||
});
|
||||
|
||||
return response({ order }, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.log({ data });
|
||||
return handleError('Invoice - Get list', error);
|
||||
}
|
||||
}
|
||||
|
||||
export type IProductItem = {
|
||||
id: string;
|
||||
sku: string;
|
||||
name: string;
|
||||
code: string;
|
||||
price: number;
|
||||
taxes: number;
|
||||
tags: string[];
|
||||
sizes: string[];
|
||||
publish: string;
|
||||
gender: string[];
|
||||
coverUrl: string;
|
||||
images: string[];
|
||||
colors: string[];
|
||||
quantity: number;
|
||||
category: string;
|
||||
available: number;
|
||||
totalSold: number;
|
||||
description: string;
|
||||
totalRatings: number;
|
||||
totalReviews: number;
|
||||
// createdAt: IDateValue;
|
||||
inventoryType: string;
|
||||
subDescription: string;
|
||||
priceSale: number | null;
|
||||
// reviews: IProductReview[];
|
||||
newLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
saleLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
ratings: {
|
||||
name: string;
|
||||
starCount: number;
|
||||
reviewCount: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type IDateValue = string | number | null;
|
||||
|
||||
export type IProductReview = {
|
||||
id: string;
|
||||
name: string;
|
||||
rating: number;
|
||||
comment: string;
|
||||
helpful: number;
|
||||
avatarUrl: string;
|
||||
postedAt: IDateValue;
|
||||
isPurchased: boolean;
|
||||
attachments?: string[];
|
||||
};
|
@@ -0,0 +1,9 @@
|
||||
###
|
||||
|
||||
PUT http://localhost:7272/api/invoice/changeStatus?orderId=1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"data":{"status": "helloworld"}
|
||||
}
|
||||
|
Reference in New Issue
Block a user