diff --git a/03_source/cms_backend/.gitignore b/03_source/cms_backend/.gitignore index 5f0eeb6..89aaa3a 100644 --- a/03_source/cms_backend/.gitignore +++ b/03_source/cms_backend/.gitignore @@ -1,3 +1,7 @@ +**/*del +**/*bak +**/*copy* + # Logs logs *.log diff --git a/03_source/cms_backend/scripts/10_build.sh b/03_source/cms_backend/scripts/10_build.sh index 8154f68..5ab75b9 100755 --- a/03_source/cms_backend/scripts/10_build.sh +++ b/03_source/cms_backend/scripts/10_build.sh @@ -15,3 +15,4 @@ yarn tsc yarn build +echo "done" diff --git a/03_source/cms_backend/src/app/api/product/createProduct/route.ts b/03_source/cms_backend/src/app/api/product/createProduct/route.ts deleted file mode 100644 index 1475a12..0000000 --- a/03_source/cms_backend/src/app/api/product/createProduct/route.ts +++ /dev/null @@ -1,43 +0,0 @@ -// src/app/api/product/createProduct/route.ts -// REQ0183 frontend product new -// -// PURPOSE: -// create product to db -// -// RULES: -// T.B.A. -// - -import type { NextRequest } from 'next/server'; - -import { STATUS, response, handleError } from 'src/utils/response'; - -import { isDev } from 'src/constants'; - -import prisma from '../../../lib/prisma'; - -// ---------------------------------------------------------------------- - -/** ************************************** - * POST - Products - *************************************** */ -export async function POST(req: NextRequest) { - const { data } = await req.json(); - - try { - if (isDev) { - console.log({ data }); - } - - await prisma.productItem.create({ data }); - - if (isDev) { - console.log('create done'); - } - - return response({ hello: 'world' }, STATUS.OK); - } catch (error) { - console.log({ hello: 'world', data }); - return handleError('Product - Create', error); - } -} diff --git a/03_source/cms_backend/src/app/api/product/createProduct/test.http b/03_source/cms_backend/src/app/api/product/createProduct/test.http deleted file mode 100644 index 46163ae..0000000 --- a/03_source/cms_backend/src/app/api/product/createProduct/test.http +++ /dev/null @@ -1,51 +0,0 @@ -### - -POST http://localhost:7272/api/product/createProduct -Content-Type: application/json - -{ - "data": { - "available": 99, - "category": "T-shirts", - "code": "PD-12345", - "colors": [ - "Red" - ], - "coverUrl": "", - "description": "this is description, 会員管理機能は、単なるデータ管理ツール以上の価値を持ちます。 企業は顧客の情報や動向を深く理解し、長期的な顧客関係の構築やロイヤルティの確立、そして迅速な市場変動への対応に直結します。 会員管理機能は、現代のビジネスにおいて企業の競争力を高める基盤として欠かせないものとなっています。", - "gender": [ - "Men" - ], - "images": [ - "data:image/png;base64,C", - "data:image/png;base64,C" - ], - "inventoryType": "test", - "name": "hello product", - "newLabel": { - "enabled": false, - "content": "" - }, - "price": 99.99, - "priceSale": null, - "publish": "yes", - "quantity": 99, - "saleLabel": { - "enabled": false, - "content": "" - }, - "sizes": [ - "7" - ], - "sku": "SK-122345", - "subDescription": "this is test sub-description", - "tags": [ - "Travel", - "Finance" - ], - "taxes": 0, - "totalRatings": 1, - "totalReviews": 1, - "totalSold": 1 - } -} diff --git a/03_source/cms_backend/src/app/api/product/delete/test.http b/03_source/cms_backend/src/app/api/product/delete/test.http new file mode 100644 index 0000000..3bd1398 --- /dev/null +++ b/03_source/cms_backend/src/app/api/product/delete/test.http @@ -0,0 +1,8 @@ +### + +PATCH http://localhost:7272/api/product/delete +Content-Type: application/json + +{ + "productId" :"e99f09a7-dd88-49d5-b1c8-1daf80c2d7b06" +} diff --git a/03_source/cms_backend/src/app/api/product/deleteProduct/route.ts b/03_source/cms_backend/src/app/api/product/deleteProduct/route.ts deleted file mode 100644 index f1dcf17..0000000 --- a/03_source/cms_backend/src/app/api/product/deleteProduct/route.ts +++ /dev/null @@ -1,44 +0,0 @@ -// src/app/api/product/deleteProduct/route.ts -// -// PURPOSE: -// delete product from db by id -// -// RULES: -// T.B.A. - -import type { NextRequest } from 'next/server'; - -import { logger } from 'src/utils/logger'; -import { STATUS, response, handleError } from 'src/utils/response'; - -import prisma from '../../../lib/prisma'; - -// ---------------------------------------------------------------------- - -/** ************************************** - * handle Delete Products - *************************************** */ -export async function DELETE(req: NextRequest) { - try { - const { searchParams } = req.nextUrl; - - // RULES: productId must exist - const productId = searchParams.get('productId'); - if (!productId) { - return response({ message: 'Product ID is required!' }, STATUS.BAD_REQUEST); - } - - // NOTE: productId confirmed exist, run below - const product = await prisma.productItem.delete({ where: { id: productId } }); - - if (!product) { - return response({ message: 'Product not found!' }, STATUS.NOT_FOUND); - } - - logger('[Product] details', product.id); - - return response({ product }, STATUS.OK); - } catch (error) { - return handleError('Product - Get details', error); - } -} diff --git a/03_source/cms_backend/src/app/api/product/deleteProduct/test.http b/03_source/cms_backend/src/app/api/product/deleteProduct/test.http deleted file mode 100644 index 4d6bfb6..0000000 --- a/03_source/cms_backend/src/app/api/product/deleteProduct/test.http +++ /dev/null @@ -1,3 +0,0 @@ -### - -DELETE http://localhost:7272/api/product/deleteProduct?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b06 diff --git a/03_source/cms_backend/src/app/api/product/saveProduct/route.ts b/03_source/cms_backend/src/app/api/product/saveProduct/route.ts deleted file mode 100644 index d2a8c05..0000000 --- a/03_source/cms_backend/src/app/api/product/saveProduct/route.ts +++ /dev/null @@ -1,129 +0,0 @@ -// 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'; - -// ---------------------------------------------------------------------- - -/** ************************************** - * GET - Products - *************************************** */ -export async function PUT(req: NextRequest) { - // logger('[Product] list', products.length); - const { data } = await req.json(); - - try { - const products = await prisma.productItem.updateMany({ - data: { - name: data.name, - sku: data.sku, - code: data.code, - price: data.price, - taxes: data.taxes, - tags: data.tags, - sizes: data.sizes, - publish: data.publish, - gender: data.gender, - coverUrl: data.coverUrl, - images: data.images, - colors: data.colors, - quantity: data.quantity, - category: data.category, - available: data.available, - totalSold: data.totalSold, - description: data.description, - totalRatings: data.totalRatings, - totalReviews: data.totalReviews, - inventoryType: data.inventoryType, - subDescription: data.subDescription, - priceSale: data.priceSale, - // - newLabel: { - content: data.newLabel?.content || '', - enabled: data.newLabel?.enabled ?? false, - }, - saleLabel: { - content: data.saleLabel?.content || '', - enabled: data.saleLabel?.enabled ?? false, - }, - ratings: { - set: data.ratings.map((rating: { name: string; starCount: number; reviewCount: number }) => ({ - name: rating.name, - starCount: rating.starCount, - reviewCount: rating.reviewCount, - })), - }, - }, - where: { id: data.id }, - }); - - return response({ data }, STATUS.OK); - } catch (error) { - console.log({ data }); - return handleError('Product - 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[]; -}; diff --git a/03_source/cms_backend/src/app/api/product/saveProduct/test.http b/03_source/cms_backend/src/app/api/product/saveProduct/test.http deleted file mode 100644 index 2b44878..0000000 --- a/03_source/cms_backend/src/app/api/product/saveProduct/test.http +++ /dev/null @@ -1,51 +0,0 @@ -### - -PUT http://localhost:7272/api/product/createProduct -Content-Type: application/json - -{ - "data": { - "available": 99, - "category": "T-shirts", - "code": "PD-12345", - "colors": [ - "Red" - ], - "coverUrl": "", - "description": "this is description, 会員管理機能は、単なるデータ管理ツール以上の価値を持ちます。 企業は顧客の情報や動向を深く理解し、長期的な顧客関係の構築やロイヤルティの確立、そして迅速な市場変動への対応に直結します。 会員管理機能は、現代のビジネスにおいて企業の競争力を高める基盤として欠かせないものとなっています。", - "gender": [ - "Men" - ], - "images": [ - "data:image/png;base64,C", - "data:image/png;base64,C" - ], - "inventoryType": "test", - "name": "hello product", - "newLabel": { - "enabled": false, - "content": "" - }, - "price": 99.99, - "priceSale": null, - "publish": "yes", - "quantity": 99, - "saleLabel": { - "enabled": false, - "content": "" - }, - "sizes": [ - "7" - ], - "sku": "SK-122345", - "subDescription": "this is test sub-description", - "tags": [ - "Travel", - "Finance" - ], - "taxes": 0, - "totalRatings": 1, - "totalReviews": 1, - "totalSold": 1 - } -} diff --git a/03_source/cms_backend/src/app/api/product/update/test.http b/03_source/cms_backend/src/app/api/product/update/test.http index 2b44878..8738d5a 100644 --- a/03_source/cms_backend/src/app/api/product/update/test.http +++ b/03_source/cms_backend/src/app/api/product/update/test.http @@ -1,10 +1,10 @@ ### -PUT http://localhost:7272/api/product/createProduct +PUT http://localhost:7272/api/product/update Content-Type: application/json { - "data": { + "productData": { "available": 99, "category": "T-shirts", "code": "PD-12345", @@ -30,6 +30,7 @@ Content-Type: application/json "priceSale": null, "publish": "yes", "quantity": 99, + "ratings":[], "saleLabel": { "enabled": false, "content": "" diff --git a/03_source/frontend/.gitignore b/03_source/frontend/.gitignore index d544fff..89aaa3a 100644 --- a/03_source/frontend/.gitignore +++ b/03_source/frontend/.gitignore @@ -2,7 +2,6 @@ **/*bak **/*copy* - # Logs logs *.log diff --git a/03_source/frontend/scripts/10_build.sh b/03_source/frontend/scripts/10_build.sh index 4257cc6..f94f39a 100755 --- a/03_source/frontend/scripts/10_build.sh +++ b/03_source/frontend/scripts/10_build.sh @@ -11,3 +11,5 @@ yarn fm:fix yarn tsc yarn build + +echo "done" diff --git a/03_source/mobile/scripts/00_dev.sh b/03_source/mobile/scripts/00_dev.sh index 0f3efe3..68f34ef 100755 --- a/03_source/mobile/scripts/00_dev.sh +++ b/03_source/mobile/scripts/00_dev.sh @@ -5,7 +5,6 @@ npm i -D clear while true; do - npm run dev echo "restarting..." diff --git a/03_source/mobile/scripts/10_build.sh b/03_source/mobile/scripts/10_build.sh index b8f6c42..7ce2971 100755 --- a/03_source/mobile/scripts/10_build.sh +++ b/03_source/mobile/scripts/10_build.sh @@ -12,5 +12,4 @@ npm run format npm run build - echo "done"