build ok,
This commit is contained in:
@@ -11,7 +11,7 @@ import type { NextRequest } from 'next/server';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
// import { AccessLogService } from '../../../../modules/AccessLog/AccessLog.service';
|
||||
import { getAccessLogById } from 'src/app/services/AccessLog.service';
|
||||
import { getAccessLogById } from 'src/app/services/access-log.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listAccessLogs } from 'src/app/services/AccessLog.service';
|
||||
import { listAccessLogs } from 'src/app/services/access-log.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listAppLogs, deleteAppLog, createNewAppLog } from 'src/app/services/AppLog.service';
|
||||
import { listAppLogs, deleteAppLog, createNewAppLog } from 'src/app/services/app-log.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { JWT_SECRET } from 'src/_mock/_auth';
|
||||
import { getUserById } from 'src/app/services/user.service';
|
||||
import { createAccessLog } from 'src/app/services/AccessLog.service';
|
||||
import { createAccessLog } from 'src/app/services/access-log.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../sign-in/flattenNextjsRequest';
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { sign } from 'src/utils/jwt';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { JWT_SECRET, JWT_EXPIRES_IN } from 'src/_mock/_auth';
|
||||
import { createAccessLog } from 'src/app/services/AccessLog.service';
|
||||
import { createAccessLog } from 'src/app/services/access-log.service';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { flattenNextjsRequest } from './flattenNextjsRequest';
|
||||
|
@@ -12,7 +12,7 @@ import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { getEvent } from 'src/app/services/eventItem.service';
|
||||
import { createAppLog } from 'src/app/services/AppLog.service';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
@@ -11,7 +11,7 @@ import type { NextRequest } from 'next/server';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { createAppLog } from 'src/app/services/AppLog.service';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
||||
const products = _products();
|
||||
|
||||
// Accept search by name or sku
|
||||
const results = products.filter(
|
||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
||||
);
|
||||
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||
|
||||
logger('[Product] search-results', results.length);
|
||||
|
||||
|
@@ -25,13 +25,8 @@ const ENDPOINTS = {
|
||||
};
|
||||
|
||||
function loggerData(action?: string, value?: unknown) {
|
||||
const columnsWithTasks = boardData.columns.map(
|
||||
(col) => `${col.name} (${boardData.tasks[col.id].length} tasks)`
|
||||
);
|
||||
logger(
|
||||
'[Kanban] get-board',
|
||||
`columns (${boardData.columns.length}): ${JSON.stringify(columnsWithTasks, null, 2)}`
|
||||
);
|
||||
const columnsWithTasks = boardData.columns.map((col) => `${col.name} (${boardData.tasks[col.id].length} tasks)`);
|
||||
logger('[Kanban] get-board', `columns (${boardData.columns.length}): ${JSON.stringify(columnsWithTasks, null, 2)}`);
|
||||
if (value || action) {
|
||||
logger(`[Kanban] ${action}`, value);
|
||||
}
|
||||
@@ -126,9 +121,7 @@ async function updateColumn(req: NextRequest) {
|
||||
|
||||
// Find and update the specified column.
|
||||
updateBoardData({
|
||||
columns: boardData.columns.map((col) =>
|
||||
col.id === columnId ? { ...col, name: columnName } : col
|
||||
),
|
||||
columns: boardData.columns.map((col) => (col.id === columnId ? { ...col, name: columnName } : col)),
|
||||
});
|
||||
|
||||
loggerData('updated-column', columnName);
|
||||
@@ -222,9 +215,7 @@ async function updateTask(req: NextRequest) {
|
||||
updateBoardData({
|
||||
tasks: {
|
||||
...boardData.tasks,
|
||||
[columnId]: boardData.tasks[columnId].map((task) =>
|
||||
task.id === taskData.id ? { ...task, ...taskData } : task
|
||||
),
|
||||
[columnId]: boardData.tasks[columnId].map((task) => (task.id === taskData.id ? { ...task, ...taskData } : task)),
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -31,10 +31,7 @@ export async function GET(req: NextRequest) {
|
||||
}
|
||||
|
||||
// Get filtered mails
|
||||
const filteredMails =
|
||||
label.type === 'custom'
|
||||
? mails.filter((mail) => mail.labelIds.includes(labelId!))
|
||||
: filterMailsByLabelId(mails, labelId);
|
||||
const filteredMails = label.type === 'custom' ? mails.filter((mail) => mail.labelIds.includes(labelId!)) : filterMailsByLabelId(mails, labelId);
|
||||
|
||||
logger(`[Mail] label-[${labelId}]`, filteredMails.length);
|
||||
|
||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
||||
const products = _products();
|
||||
|
||||
// Accept search by name or sku
|
||||
const results = products.filter(
|
||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
||||
);
|
||||
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||
|
||||
logger('[Product] search-results', results.length);
|
||||
|
||||
|
@@ -47,9 +47,7 @@ export async function GET(req: NextRequest) {
|
||||
products: paginatedProducts,
|
||||
totalPages,
|
||||
totalItems,
|
||||
categoryOptions: Array.from(
|
||||
new Set(_products.map(({ category: c_category }) => c_category))
|
||||
), // Remove duplicate categories
|
||||
categoryOptions: Array.from(new Set(_products.map(({ category: c_category }) => c_category))), // Remove duplicate categories
|
||||
},
|
||||
STATUS.OK
|
||||
);
|
||||
@@ -70,9 +68,7 @@ function paginateProducts(products: Products, page: number, perPage: number) {
|
||||
function filterProducts(products: Products, searchQuery: string, category: string) {
|
||||
return products.filter(({ id, name, category: prodCategory }) => {
|
||||
// Accept search by id or name
|
||||
const matchesSearch = searchQuery
|
||||
? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery)
|
||||
: true;
|
||||
const matchesSearch = searchQuery ? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery) : true;
|
||||
const matchesCategory = category ? prodCategory === category : true;
|
||||
|
||||
return matchesSearch && matchesCategory;
|
||||
|
@@ -24,10 +24,7 @@ export async function GET(req: NextRequest) {
|
||||
const posts = _posts();
|
||||
|
||||
// Accept search by title or description
|
||||
const results = posts.filter(
|
||||
({ title, description }) =>
|
||||
title.toLowerCase().includes(query) || description?.toLowerCase().includes(query)
|
||||
);
|
||||
const results = posts.filter(({ title, description }) => title.toLowerCase().includes(query) || description?.toLowerCase().includes(query));
|
||||
|
||||
logger('[Post] search-results', results.length);
|
||||
|
||||
|
@@ -15,6 +15,8 @@ import { STATUS, response, handleError } from 'src/utils/response';
|
||||
import { isDev } from 'src/constants';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { createProduct } from 'src/app/services/product.service';
|
||||
// import { createProduct } from 'src/app/services/product.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -29,13 +31,14 @@ export async function POST(req: NextRequest) {
|
||||
console.log({ productData });
|
||||
}
|
||||
|
||||
await prisma.productItem.create({ data: productData });
|
||||
const created = await createProduct(productData);
|
||||
// const created = await prisma.productItem.create({ data: productData });
|
||||
|
||||
if (isDev) {
|
||||
console.log('create done');
|
||||
}
|
||||
|
||||
return response({ hello: 'world' }, STATUS.OK);
|
||||
return response(created, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.log({ hello: 'world', productData });
|
||||
return handleError('Product - Create', error);
|
||||
|
@@ -1,10 +1,10 @@
|
||||
###
|
||||
|
||||
POST http://localhost:7272/api/product/createProduct
|
||||
POST http://localhost:7272/api/product/create
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"productData": {
|
||||
"available": 99,
|
||||
"category": "T-shirts",
|
||||
"code": "PD-12345",
|
||||
|
@@ -15,7 +15,7 @@ import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { getProduct } from 'src/app/services/product.service';
|
||||
import { createAppLog } from 'src/app/services/AppLog.service';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||
|
||||
|
@@ -11,7 +11,7 @@ import type { NextRequest } from 'next/server';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { createAppLog } from 'src/app/services/AppLog.service';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
import { listProducts } from 'src/app/services/product.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||
|
@@ -4,7 +4,7 @@ import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { changeToAdmin } from 'src/app/services/userItem.service';
|
||||
import { changeToAdmin } from 'src/app/services/user-item.service';
|
||||
|
||||
/**
|
||||
***************************************
|
||||
|
@@ -4,7 +4,7 @@ import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { changeToUser } from 'src/app/services/userItem.service';
|
||||
import { changeToUser } from 'src/app/services/user-item.service';
|
||||
|
||||
/**
|
||||
***************************************
|
||||
|
@@ -2,7 +2,7 @@ import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { isAdmin } from 'src/app/services/userItem.service';
|
||||
import { isAdmin } from 'src/app/services/user-item.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { isAdmin } from 'src/app/services/userItem.service';
|
||||
import { isAdmin } from 'src/app/services/user-item.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listUsers } from 'src/app/services/userItem.service';
|
||||
import { listUsers } from 'src/app/services/user-item.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listUsers, deleteUser, updateUser, createNewUser } from 'src/app/services/userItem.service';
|
||||
import { listUsers, deleteUser, updateUser, createNewUser } from 'src/app/services/user-item.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
||||
const products = _products();
|
||||
|
||||
// Accept search by name or sku
|
||||
const results = products.filter(
|
||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
||||
);
|
||||
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||
|
||||
logger('[Product] search-results', results.length);
|
||||
|
||||
|
Reference in New Issue
Block a user