Compare commits
22 Commits
develop/re
...
e791b01160
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e791b01160 | ||
![]() |
8383be13bc | ||
![]() |
d82afe5a5f | ||
![]() |
1216bef8f8 | ||
![]() |
02058981bf | ||
![]() |
b7cd25b614 | ||
![]() |
c319c103f6 | ||
![]() |
3213ef951b | ||
![]() |
cc35015a3e | ||
![]() |
253c2f2487 | ||
![]() |
c74a273928 | ||
![]() |
bebf9834e6 | ||
![]() |
45bac1b3c8 | ||
![]() |
862c5bd29c | ||
![]() |
1e1a2d63ae | ||
![]() |
3d2a8bb4f8 | ||
![]() |
f53cf9d932 | ||
![]() |
48e90bca1b | ||
![]() |
c3c93fbde9 | ||
![]() |
17080edb40 | ||
![]() |
17249dee44 | ||
![]() |
bd7e6dd9e0 |
@@ -2,10 +2,14 @@
|
|||||||
tags: frontend, product, new
|
tags: frontend, product, new
|
||||||
---
|
---
|
||||||
|
|
||||||
# REQ0182 frontend product new
|
# REQ0183 frontend product new
|
||||||
|
|
||||||
frontend page to create new product
|
frontend page to create new product
|
||||||
|
|
||||||
## sources
|
## sources
|
||||||
|
|
||||||
T.B.A.
|
T.B.A.
|
||||||
|
|
||||||
|
## branch
|
||||||
|
|
||||||
|
develop/requirements/REQ0183
|
||||||
|
17
01_Requirements/REQ0184/index.md
Normal file
17
01_Requirements/REQ0184/index.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
tags: frontend, product, delete
|
||||||
|
---
|
||||||
|
|
||||||
|
# REQ0184 frontend product delete
|
||||||
|
|
||||||
|
frontend page to delete product
|
||||||
|
|
||||||
|
list page
|
||||||
|
|
||||||
|
## sources
|
||||||
|
|
||||||
|
T.B.A.
|
||||||
|
|
||||||
|
## branch
|
||||||
|
|
||||||
|
develop/requirements/REQ0184
|
17
01_Requirements/REQ0185/index.md
Normal file
17
01_Requirements/REQ0185/index.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
tags: frontend, product, update
|
||||||
|
---
|
||||||
|
|
||||||
|
# REQ0185 frontend product update
|
||||||
|
|
||||||
|
frontend page to update product
|
||||||
|
|
||||||
|
edit page T.B.A.
|
||||||
|
|
||||||
|
## sources
|
||||||
|
|
||||||
|
T.B.A.
|
||||||
|
|
||||||
|
## branch
|
||||||
|
|
||||||
|
develop/requirements/REQ0185
|
@@ -160,3 +160,6 @@
|
|||||||
- [REQ0180: REQ0180 service port schedule](./REQ0180/index.md)
|
- [REQ0180: REQ0180 service port schedule](./REQ0180/index.md)
|
||||||
- [REQ0181: REQ0181 frontend side menu configuration](./REQ0181/index.md)
|
- [REQ0181: REQ0181 frontend side menu configuration](./REQ0181/index.md)
|
||||||
- [REQ0182: REQ0182 frontend product details](./REQ0182/index.md)
|
- [REQ0182: REQ0182 frontend product details](./REQ0182/index.md)
|
||||||
|
- [REQ0183: REQ0183 frontend product new](./REQ0183/index.md)
|
||||||
|
- [REQ0184: REQ0184 frontend product delete](./REQ0184/index.md)
|
||||||
|
- [REQ0185: REQ0185 frontend product update](./REQ0185/index.md)
|
||||||
|
4
03_source/cms_backend/.gitignore
vendored
4
03_source/cms_backend/.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
|
**/*del
|
||||||
|
**/*bak
|
||||||
|
**/*copy*
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
@@ -19,8 +19,10 @@
|
|||||||
"re:build": "yarn clean && yarn install && yarn build",
|
"re:build": "yarn clean && yarn install && yarn build",
|
||||||
"re:build-npm": "npm run clean && npm install && npm run build",
|
"re:build-npm": "npm run clean && npm install && npm run build",
|
||||||
"tsc:dev": "yarn dev & yarn tsc:watch",
|
"tsc:dev": "yarn dev & yarn tsc:watch",
|
||||||
"tsc:watch": "tsc --noEmit --watch",
|
|
||||||
"tsc:print": "npx tsc --showConfig",
|
"tsc:print": "npx tsc --showConfig",
|
||||||
|
"tsc:w": "npx nodemon --delay 3 --ext ts,tsx --exec \"yarn tsc\"",
|
||||||
|
"tsc:watch": "tsc --noEmit --watch",
|
||||||
|
"tsc": "tsc --noEmit",
|
||||||
"migrate": "npx prisma migrate dev --skip-seed",
|
"migrate": "npx prisma migrate dev --skip-seed",
|
||||||
"seed": "tsx ./prisma/seed.ts",
|
"seed": "tsx ./prisma/seed.ts",
|
||||||
"seed:w": "npx nodemon --ext \"ts,tsx,json\" -w prisma --exec \"yarn seed\"",
|
"seed:w": "npx nodemon --ext \"ts,tsx,json\" -w prisma --exec \"yarn seed\"",
|
||||||
|
@@ -195,32 +195,32 @@ model ProductItem {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
//
|
//
|
||||||
sku String
|
|
||||||
name String
|
|
||||||
code String
|
|
||||||
price Float
|
|
||||||
taxes Float
|
|
||||||
tags String[]
|
|
||||||
sizes String[]
|
|
||||||
publish String
|
|
||||||
gender String[]
|
|
||||||
coverUrl String
|
|
||||||
images String[]
|
|
||||||
colors String[]
|
|
||||||
quantity Int
|
|
||||||
category String
|
|
||||||
available Int
|
available Int
|
||||||
totalSold Int
|
category String
|
||||||
|
code String
|
||||||
|
colors String[]
|
||||||
|
coverUrl String
|
||||||
description String
|
description String
|
||||||
totalRatings Float
|
gender String[]
|
||||||
totalReviews Int
|
images String[]
|
||||||
inventoryType String
|
inventoryType String
|
||||||
subDescription String
|
name String
|
||||||
priceSale Float?
|
|
||||||
newLabel Json
|
newLabel Json
|
||||||
saleLabel Json
|
price Float
|
||||||
|
priceSale Float?
|
||||||
|
publish String
|
||||||
|
quantity Int
|
||||||
ratings Json[]
|
ratings Json[]
|
||||||
reviews ProductReview[]
|
reviews ProductReview[]
|
||||||
|
saleLabel Json
|
||||||
|
sizes String[]
|
||||||
|
sku String
|
||||||
|
subDescription String
|
||||||
|
tags String[]
|
||||||
|
taxes Float
|
||||||
|
totalRatings Float
|
||||||
|
totalReviews Int
|
||||||
|
totalSold Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model MailSender {
|
model MailSender {
|
||||||
|
@@ -1,7 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
yarn --dev
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
yarn --dev
|
yarn db:push
|
||||||
|
|
||||||
|
yarn seed
|
||||||
|
|
||||||
|
yarn db:studio &
|
||||||
|
|
||||||
yarn dev
|
yarn dev
|
||||||
|
|
||||||
echo "restarting..."
|
echo "restarting..."
|
||||||
|
@@ -2,11 +2,17 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
yarn db:push
|
rm -rf ./**/*Zone.Identifier
|
||||||
|
|
||||||
npx nodemon --ext ts,tsx --exec "yarn tsc"
|
# yarn db:push
|
||||||
|
# npx nodemon --ext ts,tsx --exec "yarn tsc"
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
yarn fm:fix
|
||||||
|
|
||||||
# yarn build
|
yarn tsc
|
||||||
|
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
echo "done"
|
||||||
|
@@ -16,11 +16,7 @@ export const _contacts = () =>
|
|||||||
address: _mock.fullAddress(index),
|
address: _mock.fullAddress(index),
|
||||||
avatarUrl: _mock.image.avatar(index),
|
avatarUrl: _mock.image.avatar(index),
|
||||||
phoneNumber: _mock.phoneNumber(index),
|
phoneNumber: _mock.phoneNumber(index),
|
||||||
status:
|
status: ([0, 1, 6, 12].includes(index) && 'online') || ([3, 8, 14].includes(index) && 'offline') || ([4, 10, 16].includes(index) && 'busy') || 'always',
|
||||||
([0, 1, 6, 12].includes(index) && 'online') ||
|
|
||||||
([3, 8, 14].includes(index) && 'offline') ||
|
|
||||||
([4, 10, 16].includes(index) && 'busy') ||
|
|
||||||
'always',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const _conversations = () => {
|
export const _conversations = () => {
|
||||||
|
@@ -6,8 +6,7 @@ import { _tags } from './assets';
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
const generateAttachments = () =>
|
const generateAttachments = () => Array.from({ length: 20 }, (_, index) => _mock.image.cover(index));
|
||||||
Array.from({ length: 20 }, (_, index) => _mock.image.cover(index));
|
|
||||||
|
|
||||||
const generateAssignees = () =>
|
const generateAssignees = () =>
|
||||||
Array.from({ length: 20 }, (_, index) => ({
|
Array.from({ length: 20 }, (_, index) => ({
|
||||||
@@ -68,24 +67,14 @@ const createTask = (index: number, status: string) => {
|
|||||||
assignee: assignedUser.slice(0, index),
|
assignee: assignedUser.slice(0, index),
|
||||||
description: _mock.description(index),
|
description: _mock.description(index),
|
||||||
due: [fAdd({ days: index + 1 }), fAdd({ days: index + 2 })],
|
due: [fAdd({ days: index + 1 }), fAdd({ days: index + 2 })],
|
||||||
priority:
|
priority: ([1, 3].includes(index) && PRIORITY_LEVEL.hight) || ([2, 4].includes(index) && PRIORITY_LEVEL.medium) || PRIORITY_LEVEL.low,
|
||||||
([1, 3].includes(index) && PRIORITY_LEVEL.hight) ||
|
attachments: (index === 1 && attachmentList.slice(11, 15)) || (index === 5 && attachmentList.slice(4, 9)) || [],
|
||||||
([2, 4].includes(index) && PRIORITY_LEVEL.medium) ||
|
|
||||||
PRIORITY_LEVEL.low,
|
|
||||||
attachments:
|
|
||||||
(index === 1 && attachmentList.slice(11, 15)) ||
|
|
||||||
(index === 5 && attachmentList.slice(4, 9)) ||
|
|
||||||
[],
|
|
||||||
status,
|
status,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const tasks = () => ({
|
const tasks = () => ({
|
||||||
[COLUMN_IDS.id1]: [
|
[COLUMN_IDS.id1]: [createTask(1, COLUMN_NAMES.name1), createTask(2, COLUMN_NAMES.name1), createTask(3, COLUMN_NAMES.name1)],
|
||||||
createTask(1, COLUMN_NAMES.name1),
|
|
||||||
createTask(2, COLUMN_NAMES.name1),
|
|
||||||
createTask(3, COLUMN_NAMES.name1),
|
|
||||||
],
|
|
||||||
[COLUMN_IDS.id2]: [createTask(4, COLUMN_NAMES.name2), createTask(5, COLUMN_NAMES.name2)],
|
[COLUMN_IDS.id2]: [createTask(4, COLUMN_NAMES.name2), createTask(5, COLUMN_NAMES.name2)],
|
||||||
[COLUMN_IDS.id3]: [],
|
[COLUMN_IDS.id3]: [],
|
||||||
[COLUMN_IDS.id4]: [createTask(6, COLUMN_NAMES.name4)],
|
[COLUMN_IDS.id4]: [createTask(6, COLUMN_NAMES.name4)],
|
||||||
|
@@ -28,20 +28,11 @@ export const _mails = () =>
|
|||||||
Array.from({ length: 9 }, (_, index) => {
|
Array.from({ length: 9 }, (_, index) => {
|
||||||
const files = _files();
|
const files = _files();
|
||||||
|
|
||||||
const attachments =
|
const attachments = (index === 1 && files.slice(0, 2)) || (index === 2 && files.slice(0, 4)) || (index === 5 && files.slice(4, 10)) || [];
|
||||||
(index === 1 && files.slice(0, 2)) ||
|
|
||||||
(index === 2 && files.slice(0, 4)) ||
|
|
||||||
(index === 5 && files.slice(4, 10)) ||
|
|
||||||
[];
|
|
||||||
|
|
||||||
const folder =
|
const folder = ([1, 2].includes(index) && 'spam') || ([3, 4].includes(index) && 'sent') || 'inbox';
|
||||||
([1, 2].includes(index) && 'spam') || ([3, 4].includes(index) && 'sent') || 'inbox';
|
|
||||||
|
|
||||||
const labelIds =
|
const labelIds = (index === 1 && ['promotions', 'forums']) || (index === 2 && ['forums']) || (index === 5 && ['social']) || [];
|
||||||
(index === 1 && ['promotions', 'forums']) ||
|
|
||||||
(index === 2 && ['forums']) ||
|
|
||||||
(index === 5 && ['social']) ||
|
|
||||||
[];
|
|
||||||
|
|
||||||
const from = {
|
const from = {
|
||||||
name: _mock.fullName(index),
|
name: _mock.fullName(index),
|
||||||
|
@@ -78,11 +78,8 @@ export const _mock = {
|
|||||||
avatar: (index: number) => `${CONFIG.basePath}/assets/images/avatar/avatar-${index + 1}.webp`,
|
avatar: (index: number) => `${CONFIG.basePath}/assets/images/avatar/avatar-${index + 1}.webp`,
|
||||||
travel: (index: number) => `${CONFIG.basePath}/assets/images/travel/travel-${index + 1}.webp`,
|
travel: (index: number) => `${CONFIG.basePath}/assets/images/travel/travel-${index + 1}.webp`,
|
||||||
course: (index: number) => `${CONFIG.basePath}/assets/images/course/course-${index + 1}.webp`,
|
course: (index: number) => `${CONFIG.basePath}/assets/images/course/course-${index + 1}.webp`,
|
||||||
company: (index: number) =>
|
company: (index: number) => `${CONFIG.basePath}/assets/images/company/company-${index + 1}.webp`,
|
||||||
`${CONFIG.basePath}/assets/images/company/company-${index + 1}.webp`,
|
product: (index: number) => `${CONFIG.basePath}/assets/images/m-product/product-${index + 1}.webp`,
|
||||||
product: (index: number) =>
|
portrait: (index: number) => `${CONFIG.basePath}/assets/images/portrait/portrait-${index + 1}.webp`,
|
||||||
`${CONFIG.basePath}/assets/images/m-product/product-${index + 1}.webp`,
|
|
||||||
portrait: (index: number) =>
|
|
||||||
`${CONFIG.basePath}/assets/images/portrait/portrait-${index + 1}.webp`,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -3,16 +3,7 @@ import { _tags } from './assets';
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
const COLORS = [
|
const COLORS = ['#FF4842', '#1890FF', '#FFC0CB', '#00AB55', '#FFC107', '#7F00FF', '#000000', '#FFFFFF'];
|
||||||
'#FF4842',
|
|
||||||
'#1890FF',
|
|
||||||
'#FFC0CB',
|
|
||||||
'#00AB55',
|
|
||||||
'#FFC107',
|
|
||||||
'#7F00FF',
|
|
||||||
'#000000',
|
|
||||||
'#FFFFFF',
|
|
||||||
];
|
|
||||||
|
|
||||||
const DESCRIPTION = `
|
const DESCRIPTION = `
|
||||||
<h6>Specifications</h6>
|
<h6>Specifications</h6>
|
||||||
@@ -93,8 +84,7 @@ const DESCRIPTION = `
|
|||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const generateAttachments = () =>
|
const generateAttachments = () => Array.from({ length: 20 }, (_, index) => _mock.image.product(index));
|
||||||
Array.from({ length: 20 }, (_, index) => _mock.image.product(index));
|
|
||||||
|
|
||||||
const generateReviews = () => {
|
const generateReviews = () => {
|
||||||
const attachments = generateAttachments();
|
const attachments = generateAttachments();
|
||||||
@@ -108,11 +98,7 @@ const generateReviews = () => {
|
|||||||
rating: _mock.number.rating(index),
|
rating: _mock.number.rating(index),
|
||||||
avatarUrl: _mock.image.avatar(index),
|
avatarUrl: _mock.image.avatar(index),
|
||||||
helpful: _mock.number.nativeL(index),
|
helpful: _mock.number.nativeL(index),
|
||||||
attachments:
|
attachments: (index === 1 && attachments.slice(0, 1)) || (index === 3 && attachments.slice(2, 4)) || (index === 5 && attachments.slice(5, 8)) || [],
|
||||||
(index === 1 && attachments.slice(0, 1)) ||
|
|
||||||
(index === 3 && attachments.slice(2, 4)) ||
|
|
||||||
(index === 5 && attachments.slice(5, 8)) ||
|
|
||||||
[],
|
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -192,7 +178,6 @@ export const _products = () =>
|
|||||||
newLabel: { enabled: [1, 2, 3].includes(index), content: 'NEW' },
|
newLabel: { enabled: [1, 2, 3].includes(index), content: 'NEW' },
|
||||||
saleLabel: { enabled: [4, 5].includes(index), content: 'SALE' },
|
saleLabel: { enabled: [4, 5].includes(index), content: 'SALE' },
|
||||||
sizes: ['6', '7', '8', '8.5', '9', '9.5', '10', '10.5', '11', '11.5', '12', '13'],
|
sizes: ['6', '7', '8', '8.5', '9', '9.5', '10', '10.5', '11', '11.5', '12', '13'],
|
||||||
subDescription:
|
subDescription: 'Featuring the original ripple design inspired by Japanese bullet trains, the Nike Air Max 97 lets you push your style full-speed ahead.',
|
||||||
'Featuring the original ripple design inspired by Japanese bullet trains, the Nike Air Max 97 lets you push your style full-speed ahead.',
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export const _id = Array.from(
|
export const _id = Array.from({ length: 40 }, (_, index) => `e99f09a7-dd88-49d5-b1c8-1daf80c2d7b${index + 1}`);
|
||||||
{ length: 40 },
|
|
||||||
(_, index) => `e99f09a7-dd88-49d5-b1c8-1daf80c2d7b${index + 1}`
|
|
||||||
);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -37,36 +34,24 @@ export const _booleans = [
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export const _prices = [
|
export const _prices = [
|
||||||
83.74, 97.14, 68.71, 85.21, 52.17, 25.18, 43.84, 60.98, 98.42, 53.37, 72.75, 56.61, 64.55, 77.32,
|
83.74, 97.14, 68.71, 85.21, 52.17, 25.18, 43.84, 60.98, 98.42, 53.37, 72.75, 56.61, 64.55, 77.32, 60.62, 79.81, 93.68, 47.44, 76.24, 92.87, 72.91, 20.54,
|
||||||
60.62, 79.81, 93.68, 47.44, 76.24, 92.87, 72.91, 20.54, 94.25, 37.51,
|
94.25, 37.51,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const _ratings = [
|
export const _ratings = [4.2, 3.7, 4.5, 3.5, 0.5, 3.0, 2.5, 2.8, 4.9, 3.6, 2.5, 1.7, 3.9, 2.8, 4.1, 4.5, 2.2, 3.2, 0.6, 1.3, 3.8, 3.8, 3.8, 2.0];
|
||||||
4.2, 3.7, 4.5, 3.5, 0.5, 3.0, 2.5, 2.8, 4.9, 3.6, 2.5, 1.7, 3.9, 2.8, 4.1, 4.5, 2.2, 3.2, 0.6,
|
|
||||||
1.3, 3.8, 3.8, 3.8, 2.0,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const _ages = [
|
export const _ages = [30, 26, 59, 47, 29, 46, 18, 56, 39, 19, 45, 18, 46, 56, 38, 41, 44, 48, 32, 45, 42, 60, 33, 57];
|
||||||
30, 26, 59, 47, 29, 46, 18, 56, 39, 19, 45, 18, 46, 56, 38, 41, 44, 48, 32, 45, 42, 60, 33, 57,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const _percents = [
|
export const _percents = [
|
||||||
10.1, 13.6, 28.2, 42.1, 37.2, 18.5, 40.1, 94.8, 91.4, 53.0, 25.4, 62.9, 86.6, 62.4, 35.4, 17.6,
|
10.1, 13.6, 28.2, 42.1, 37.2, 18.5, 40.1, 94.8, 91.4, 53.0, 25.4, 62.9, 86.6, 62.4, 35.4, 17.6, 52.0, 6.8, 95.3, 26.6, 69.9, 92.1, 46.2, 85.6,
|
||||||
52.0, 6.8, 95.3, 26.6, 69.9, 92.1, 46.2, 85.6,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const _nativeS = [
|
export const _nativeS = [11, 10, 7, 10, 12, 5, 10, 1, 8, 8, 10, 11, 12, 8, 4, 11, 8, 9, 4, 9, 2, 6, 3, 7];
|
||||||
11, 10, 7, 10, 12, 5, 10, 1, 8, 8, 10, 11, 12, 8, 4, 11, 8, 9, 4, 9, 2, 6, 3, 7,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const _nativeM = [
|
export const _nativeM = [497, 763, 684, 451, 433, 463, 951, 194, 425, 435, 807, 521, 538, 839, 394, 269, 453, 821, 364, 849, 804, 776, 263, 239];
|
||||||
497, 763, 684, 451, 433, 463, 951, 194, 425, 435, 807, 521, 538, 839, 394, 269, 453, 821, 364,
|
|
||||||
849, 804, 776, 263, 239,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const _nativeL = [
|
export const _nativeL = [
|
||||||
9911, 1947, 9124, 6984, 8488, 2034, 3364, 8401, 8996, 5271, 8478, 1139, 8061, 3035, 6733, 3952,
|
9911, 1947, 9124, 6984, 8488, 2034, 3364, 8401, 8996, 5271, 8478, 1139, 8061, 3035, 6733, 3952, 2405, 3127, 6843, 4672, 6995, 6053, 5192, 9686,
|
||||||
2405, 3127, 6843, 4672, 6995, 6053, 5192, 9686,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const _fullAddress = [
|
export const _fullAddress = [
|
||||||
|
@@ -11,7 +11,7 @@ import type { NextRequest } from 'next/server';
|
|||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
import { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
// import { AccessLogService } from '../../../../modules/AccessLog/AccessLog.service';
|
// 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 { 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';
|
// 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 { 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';
|
// 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 { JWT_SECRET } from 'src/_mock/_auth';
|
||||||
import { getUserById } from 'src/app/services/user.service';
|
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';
|
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 { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
import { JWT_SECRET, JWT_EXPIRES_IN } from 'src/_mock/_auth';
|
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 prisma from '../../../lib/prisma';
|
||||||
import { flattenNextjsRequest } from './flattenNextjsRequest';
|
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 { L_INFO, L_ERROR } from 'src/constants';
|
||||||
import { getEvent } from 'src/app/services/eventItem.service';
|
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 { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
import { L_INFO, L_ERROR } from 'src/constants';
|
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 prisma from '../../../lib/prisma';
|
||||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
|||||||
const products = _products();
|
const products = _products();
|
||||||
|
|
||||||
// Accept search by name or sku
|
// Accept search by name or sku
|
||||||
const results = products.filter(
|
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('[Product] search-results', results.length);
|
logger('[Product] search-results', results.length);
|
||||||
|
|
||||||
|
@@ -25,13 +25,8 @@ const ENDPOINTS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function loggerData(action?: string, value?: unknown) {
|
function loggerData(action?: string, value?: unknown) {
|
||||||
const columnsWithTasks = boardData.columns.map(
|
const columnsWithTasks = boardData.columns.map((col) => `${col.name} (${boardData.tasks[col.id].length} tasks)`);
|
||||||
(col) => `${col.name} (${boardData.tasks[col.id].length} tasks)`
|
logger('[Kanban] get-board', `columns (${boardData.columns.length}): ${JSON.stringify(columnsWithTasks, null, 2)}`);
|
||||||
);
|
|
||||||
logger(
|
|
||||||
'[Kanban] get-board',
|
|
||||||
`columns (${boardData.columns.length}): ${JSON.stringify(columnsWithTasks, null, 2)}`
|
|
||||||
);
|
|
||||||
if (value || action) {
|
if (value || action) {
|
||||||
logger(`[Kanban] ${action}`, value);
|
logger(`[Kanban] ${action}`, value);
|
||||||
}
|
}
|
||||||
@@ -126,9 +121,7 @@ async function updateColumn(req: NextRequest) {
|
|||||||
|
|
||||||
// Find and update the specified column.
|
// Find and update the specified column.
|
||||||
updateBoardData({
|
updateBoardData({
|
||||||
columns: boardData.columns.map((col) =>
|
columns: boardData.columns.map((col) => (col.id === columnId ? { ...col, name: columnName } : col)),
|
||||||
col.id === columnId ? { ...col, name: columnName } : col
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
loggerData('updated-column', columnName);
|
loggerData('updated-column', columnName);
|
||||||
@@ -222,9 +215,7 @@ async function updateTask(req: NextRequest) {
|
|||||||
updateBoardData({
|
updateBoardData({
|
||||||
tasks: {
|
tasks: {
|
||||||
...boardData.tasks,
|
...boardData.tasks,
|
||||||
[columnId]: boardData.tasks[columnId].map((task) =>
|
[columnId]: boardData.tasks[columnId].map((task) => (task.id === taskData.id ? { ...task, ...taskData } : task)),
|
||||||
task.id === taskData.id ? { ...task, ...taskData } : task
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -31,10 +31,7 @@ export async function GET(req: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get filtered mails
|
// Get filtered mails
|
||||||
const filteredMails =
|
const filteredMails = label.type === 'custom' ? mails.filter((mail) => mail.labelIds.includes(labelId!)) : filterMailsByLabelId(mails, labelId);
|
||||||
label.type === 'custom'
|
|
||||||
? mails.filter((mail) => mail.labelIds.includes(labelId!))
|
|
||||||
: filterMailsByLabelId(mails, labelId);
|
|
||||||
|
|
||||||
logger(`[Mail] label-[${labelId}]`, filteredMails.length);
|
logger(`[Mail] label-[${labelId}]`, filteredMails.length);
|
||||||
|
|
||||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
|||||||
const products = _products();
|
const products = _products();
|
||||||
|
|
||||||
// Accept search by name or sku
|
// Accept search by name or sku
|
||||||
const results = products.filter(
|
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('[Product] search-results', results.length);
|
logger('[Product] search-results', results.length);
|
||||||
|
|
||||||
|
@@ -47,9 +47,7 @@ export async function GET(req: NextRequest) {
|
|||||||
products: paginatedProducts,
|
products: paginatedProducts,
|
||||||
totalPages,
|
totalPages,
|
||||||
totalItems,
|
totalItems,
|
||||||
categoryOptions: Array.from(
|
categoryOptions: Array.from(new Set(_products.map(({ category: c_category }) => c_category))), // Remove duplicate categories
|
||||||
new Set(_products.map(({ category: c_category }) => c_category))
|
|
||||||
), // Remove duplicate categories
|
|
||||||
},
|
},
|
||||||
STATUS.OK
|
STATUS.OK
|
||||||
);
|
);
|
||||||
@@ -70,9 +68,7 @@ function paginateProducts(products: Products, page: number, perPage: number) {
|
|||||||
function filterProducts(products: Products, searchQuery: string, category: string) {
|
function filterProducts(products: Products, searchQuery: string, category: string) {
|
||||||
return products.filter(({ id, name, category: prodCategory }) => {
|
return products.filter(({ id, name, category: prodCategory }) => {
|
||||||
// Accept search by id or name
|
// Accept search by id or name
|
||||||
const matchesSearch = searchQuery
|
const matchesSearch = searchQuery ? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery) : true;
|
||||||
? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery)
|
|
||||||
: true;
|
|
||||||
const matchesCategory = category ? prodCategory === category : true;
|
const matchesCategory = category ? prodCategory === category : true;
|
||||||
|
|
||||||
return matchesSearch && matchesCategory;
|
return matchesSearch && matchesCategory;
|
||||||
|
@@ -24,10 +24,7 @@ export async function GET(req: NextRequest) {
|
|||||||
const posts = _posts();
|
const posts = _posts();
|
||||||
|
|
||||||
// Accept search by title or description
|
// Accept search by title or description
|
||||||
const results = posts.filter(
|
const results = posts.filter(({ title, description }) => title.toLowerCase().includes(query) || description?.toLowerCase().includes(query));
|
||||||
({ title, description }) =>
|
|
||||||
title.toLowerCase().includes(query) || description?.toLowerCase().includes(query)
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('[Post] search-results', results.length);
|
logger('[Post] search-results', results.length);
|
||||||
|
|
||||||
|
46
03_source/cms_backend/src/app/api/product/create/route.ts
Normal file
46
03_source/cms_backend/src/app/api/product/create/route.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// 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';
|
||||||
|
import { createProduct } from 'src/app/services/product.service';
|
||||||
|
// import { createProduct } from 'src/app/services/product.service';
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** **************************************
|
||||||
|
* POST - Products
|
||||||
|
*************************************** */
|
||||||
|
export async function POST(req: NextRequest) {
|
||||||
|
const { productData } = await req.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isDev) {
|
||||||
|
console.log({ productData });
|
||||||
|
}
|
||||||
|
|
||||||
|
const created = await createProduct(productData);
|
||||||
|
// const created = await prisma.productItem.create({ data: productData });
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
|
console.log('create done');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response(created, STATUS.OK);
|
||||||
|
} catch (error) {
|
||||||
|
console.log({ hello: 'world', productData });
|
||||||
|
return handleError('Product - Create', error);
|
||||||
|
}
|
||||||
|
}
|
51
03_source/cms_backend/src/app/api/product/create/test.http
Normal file
51
03_source/cms_backend/src/app/api/product/create/test.http
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
###
|
||||||
|
|
||||||
|
POST http://localhost:7272/api/product/create
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"productData": {
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
@@ -1,75 +0,0 @@
|
|||||||
// src/app/api/product/createProduct/route.ts
|
|
||||||
//
|
|
||||||
// PURPOSE:
|
|
||||||
// create product to db
|
|
||||||
//
|
|
||||||
// RULES:
|
|
||||||
// T.B.A.
|
|
||||||
//
|
|
||||||
|
|
||||||
import type { NextRequest } from 'next/server';
|
|
||||||
|
|
||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
|
||||||
|
|
||||||
import prisma from '../../../lib/prisma';
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** **************************************
|
|
||||||
* POST - Products
|
|
||||||
*************************************** */
|
|
||||||
export async function POST(req: NextRequest) {
|
|
||||||
// logger('[Product] list', products.length);
|
|
||||||
const { data } = await req.json();
|
|
||||||
const createForm: CreateProductData = data as unknown as CreateProductData;
|
|
||||||
|
|
||||||
console.log({ createForm });
|
|
||||||
|
|
||||||
try {
|
|
||||||
console.log({ data });
|
|
||||||
await prisma.productItem.create({ data: createForm });
|
|
||||||
return response({ hello: 'world' }, STATUS.OK);
|
|
||||||
} catch (error) {
|
|
||||||
console.log({ hello: 'world', data });
|
|
||||||
return handleError('Product - Create', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateProductData = {
|
|
||||||
// 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;
|
|
||||||
inventoryType: string;
|
|
||||||
subDescription: string;
|
|
||||||
priceSale: number;
|
|
||||||
newLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
saleLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
// ratings: {
|
|
||||||
// name: string;
|
|
||||||
// starCount: number;
|
|
||||||
// reviewCount: number;
|
|
||||||
// }[];
|
|
||||||
};
|
|
22
03_source/cms_backend/src/app/api/product/delete/route.ts
Normal file
22
03_source/cms_backend/src/app/api/product/delete/route.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import type { NextRequest } from 'next/server';
|
||||||
|
|
||||||
|
import { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
|
import { deleteProduct } from 'src/app/services/product.service';
|
||||||
|
|
||||||
|
/** **************************************
|
||||||
|
* PATCH - Delete product
|
||||||
|
*************************************** */
|
||||||
|
export async function PATCH(req: NextRequest) {
|
||||||
|
try {
|
||||||
|
const { productId } = await req.json();
|
||||||
|
|
||||||
|
if (!productId) throw new Error('productId cannot be null');
|
||||||
|
|
||||||
|
await deleteProduct(productId);
|
||||||
|
|
||||||
|
return response({ productId }, STATUS.OK);
|
||||||
|
} catch (error) {
|
||||||
|
return handleError('Product - Delete', error);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,8 @@
|
|||||||
|
###
|
||||||
|
|
||||||
|
PATCH http://localhost:7272/api/product/delete
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"productId" :"e99f09a7-dd88-49d5-b1c8-1daf80c2d7b06"
|
||||||
|
}
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
###
|
|
||||||
|
|
||||||
DELETE http://localhost:7272/api/product/deleteProduct?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b06
|
|
@@ -1,5 +1,7 @@
|
|||||||
// src/app/api/product/details/route.ts
|
// src/app/api/product/details/route.ts
|
||||||
//
|
//
|
||||||
|
// REQ0182 frontend product details
|
||||||
|
//
|
||||||
// PURPOSE:
|
// PURPOSE:
|
||||||
// get product from db by id
|
// get product from db by id
|
||||||
//
|
//
|
||||||
@@ -13,7 +15,7 @@ import { STATUS, response, handleError } from 'src/utils/response';
|
|||||||
|
|
||||||
import { L_INFO, L_ERROR } from 'src/constants';
|
import { L_INFO, L_ERROR } from 'src/constants';
|
||||||
import { getProduct } from 'src/app/services/product.service';
|
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';
|
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||||
|
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
###
|
###
|
||||||
|
GET http://localhost:7272/api/product/details?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
||||||
|
|
||||||
|
###
|
||||||
GET http://localhost:7272/api/product/details?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
GET http://localhost:7272/api/product/details?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
||||||
|
@@ -11,7 +11,7 @@ import type { NextRequest } from 'next/server';
|
|||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
import { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
import { L_INFO, L_ERROR } from 'src/constants';
|
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 { listProducts } from 'src/app/services/product.service';
|
||||||
|
|
||||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
import { logger } from 'src/utils/logger';
|
|
||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
|
||||||
|
|
||||||
import { _products } from 'src/_mock/_product';
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
export const runtime = 'edge';
|
|
||||||
|
|
||||||
/** **************************************
|
|
||||||
* GET - Products
|
|
||||||
*************************************** */
|
|
||||||
export async function GET() {
|
|
||||||
try {
|
|
||||||
const products = _products();
|
|
||||||
|
|
||||||
logger('[Product] list', products.length);
|
|
||||||
|
|
||||||
return response({ products }, STATUS.OK);
|
|
||||||
} catch (error) {
|
|
||||||
return handleError('Product - Get list', error);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -3,11 +3,11 @@ import type { NextRequest } from 'next/server';
|
|||||||
import { logger } from 'src/utils/logger';
|
import { logger } from 'src/utils/logger';
|
||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
import { STATUS, response, handleError } from 'src/utils/response';
|
||||||
|
|
||||||
import { _products } from 'src/_mock/_product';
|
import { getProductBySkuOrName } from 'src/app/services/product.service';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export const runtime = 'edge';
|
// export const runtime = 'edge';
|
||||||
|
|
||||||
/** **************************************
|
/** **************************************
|
||||||
* GET - Search products
|
* GET - Search products
|
||||||
@@ -21,12 +21,9 @@ export async function GET(req: NextRequest) {
|
|||||||
return response({ results: [] }, STATUS.OK);
|
return response({ results: [] }, STATUS.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
const products = _products();
|
const results = await getProductBySkuOrName(query);
|
||||||
|
|
||||||
// Accept search by name or sku
|
logger('[Product] search-results', results?.length);
|
||||||
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
|
||||||
|
|
||||||
logger('[Product] search-results', results.length);
|
|
||||||
|
|
||||||
return response({ results }, STATUS.OK);
|
return response({ results }, STATUS.OK);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
###
|
||||||
|
GET http://localhost:7272/api/product/search?query=B
|
||||||
|
|
||||||
|
###
|
||||||
|
GET http://localhost:7272/api/product/search?query=Classic
|
||||||
|
|
||||||
|
###
|
||||||
|
GET http://localhost:7272/api/product/search?query=zzzzzz
|
@@ -17,58 +17,58 @@ import prisma from '../../../lib/prisma';
|
|||||||
/** **************************************
|
/** **************************************
|
||||||
* GET - Products
|
* GET - Products
|
||||||
*************************************** */
|
*************************************** */
|
||||||
export async function POST(req: NextRequest) {
|
export async function PUT(req: NextRequest) {
|
||||||
// logger('[Product] list', products.length);
|
// logger('[Product] list', products.length);
|
||||||
const { data } = await req.json();
|
const { productData } = await req.json();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const products = await prisma.productItem.updateMany({
|
const products = await prisma.productItem.updateMany({
|
||||||
data: {
|
data: {
|
||||||
name: data.name,
|
name: productData.name,
|
||||||
sku: data.sku,
|
sku: productData.sku,
|
||||||
code: data.code,
|
code: productData.code,
|
||||||
price: data.price,
|
price: productData.price,
|
||||||
taxes: data.taxes,
|
taxes: productData.taxes,
|
||||||
tags: data.tags,
|
tags: productData.tags,
|
||||||
sizes: data.sizes,
|
sizes: productData.sizes,
|
||||||
publish: data.publish,
|
publish: productData.publish,
|
||||||
gender: data.gender,
|
gender: productData.gender,
|
||||||
coverUrl: data.coverUrl,
|
coverUrl: productData.coverUrl,
|
||||||
images: data.images,
|
images: productData.images,
|
||||||
colors: data.colors,
|
colors: productData.colors,
|
||||||
quantity: data.quantity,
|
quantity: productData.quantity,
|
||||||
category: data.category,
|
category: productData.category,
|
||||||
available: data.available,
|
available: productData.available,
|
||||||
totalSold: data.totalSold,
|
totalSold: productData.totalSold,
|
||||||
description: data.description,
|
description: productData.description,
|
||||||
totalRatings: data.totalRatings,
|
totalRatings: productData.totalRatings,
|
||||||
totalReviews: data.totalReviews,
|
totalReviews: productData.totalReviews,
|
||||||
inventoryType: data.inventoryType,
|
inventoryType: productData.inventoryType,
|
||||||
subDescription: data.subDescription,
|
subDescription: productData.subDescription,
|
||||||
priceSale: data.priceSale,
|
priceSale: productData.priceSale,
|
||||||
//
|
//
|
||||||
newLabel: {
|
newLabel: {
|
||||||
content: data.newLabel?.content || '',
|
content: productData.newLabel?.content || '',
|
||||||
enabled: data.newLabel?.enabled ?? false,
|
enabled: productData.newLabel?.enabled ?? false,
|
||||||
},
|
},
|
||||||
saleLabel: {
|
saleLabel: {
|
||||||
content: data.saleLabel?.content || '',
|
content: productData.saleLabel?.content || '',
|
||||||
enabled: data.saleLabel?.enabled ?? false,
|
enabled: productData.saleLabel?.enabled ?? false,
|
||||||
},
|
},
|
||||||
ratings: {
|
ratings: {
|
||||||
set: data.ratings.map((rating: { name: string; starCount: number; reviewCount: number }) => ({
|
set: productData.ratings.map((rating: { name: string; starCount: number; reviewCount: number }) => ({
|
||||||
name: rating.name,
|
name: rating.name,
|
||||||
starCount: rating.starCount,
|
starCount: rating.starCount,
|
||||||
reviewCount: rating.reviewCount,
|
reviewCount: rating.reviewCount,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { id: data.id },
|
where: { id: productData.id },
|
||||||
});
|
});
|
||||||
|
|
||||||
return response({ data }, STATUS.OK);
|
return response({ data: productData }, STATUS.OK);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log({ data });
|
console.log({ data: productData });
|
||||||
return handleError('Product - Get list', error);
|
return handleError('Product - Get list', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
52
03_source/cms_backend/src/app/api/product/update/test.http
Normal file
52
03_source/cms_backend/src/app/api/product/update/test.http
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
###
|
||||||
|
|
||||||
|
PUT http://localhost:7272/api/product/update
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"productData": {
|
||||||
|
"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,
|
||||||
|
"ratings":[],
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,7 @@ import type { NextRequest } from 'next/server';
|
|||||||
|
|
||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
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 { 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 { 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';
|
// 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 { 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';
|
// import prisma from '../../lib/prisma';
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
import { logger } from 'src/utils/logger';
|
import { logger } from 'src/utils/logger';
|
||||||
import { STATUS, response, handleError } from 'src/utils/response';
|
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 { 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';
|
// import prisma from '../../lib/prisma';
|
||||||
|
|
||||||
|
@@ -24,9 +24,7 @@ export async function GET(req: NextRequest) {
|
|||||||
const products = _products();
|
const products = _products();
|
||||||
|
|
||||||
// Accept search by name or sku
|
// Accept search by name or sku
|
||||||
const results = products.filter(
|
const results = products.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||||
({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query)
|
|
||||||
);
|
|
||||||
|
|
||||||
logger('[Product] search-results', results.length);
|
logger('[Product] search-results', results.length);
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
// src/app/services/product.service.ts
|
// src/app/services/product.service.ts
|
||||||
//
|
//
|
||||||
|
// REQ0182 frontend product details
|
||||||
|
//
|
||||||
// PURPOSE:
|
// PURPOSE:
|
||||||
// - Service for handling ProductItem Record
|
// - Service for handling ProductItem Record
|
||||||
//
|
//
|
||||||
@@ -65,39 +67,29 @@ type UpdateProduct = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function listProducts(): Promise<ProductItem[]> {
|
async function listProducts(): Promise<ProductItem[]> {
|
||||||
return prisma.productItem.findMany();
|
return prisma.productItem.findMany({
|
||||||
|
include: { reviews: true },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProduct(productId: string): Promise<ProductItem | null> {
|
async function getProduct(productId: string): Promise<ProductItem | null> {
|
||||||
return prisma.productItem.findUnique({ where: { id: productId } });
|
return prisma.productItem.findUnique({
|
||||||
|
where: { id: productId },
|
||||||
|
include: { reviews: true },
|
||||||
|
//
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createProduct(createForm: CreateProduct) {
|
async function getProductBySkuOrName(searchText: string): Promise<ProductItem[] | null> {
|
||||||
// return prisma.productItem.create({
|
return prisma.productItem.findMany({
|
||||||
// data: {
|
where: { OR: [{ sku: { contains: searchText, mode: 'insensitive' } }, { name: { contains: searchText, mode: 'insensitive' } }] },
|
||||||
// ...createForm,
|
include: { reviews: true },
|
||||||
// code: createForm.code || '',
|
//
|
||||||
// taxes: createForm.taxes || 0,
|
});
|
||||||
// tags: createForm.tags || [],
|
}
|
||||||
// sizes: createForm.sizes || [],
|
|
||||||
// gender: createForm.gender || [],
|
async function createProduct(productData: any) {
|
||||||
// colors: createForm.colors || [],
|
return await prisma.productItem.create({ data: productData });
|
||||||
// category: createForm.category || '',
|
|
||||||
// quantity: createForm.quantity || 0,
|
|
||||||
// available: createForm.available || 0,
|
|
||||||
// coverUrl: createForm.coverUrl || '',
|
|
||||||
// images: createForm.images || [],
|
|
||||||
// description: createForm.description || '',
|
|
||||||
// subDescription: createForm.subDescription || '',
|
|
||||||
// publish: createForm.publish || 'published',
|
|
||||||
// totalSold: createForm.totalSold || 0,
|
|
||||||
// totalRatings: createForm.totalRatings || 0,
|
|
||||||
// totalReviews: createForm.totalReviews || 0,
|
|
||||||
// inventoryType: createForm.inventoryType || '',
|
|
||||||
// ratings: createForm.ratings || [],
|
|
||||||
// reviews: createForm.reviews || [],
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateProduct(productId: string, updateForm: UpdateProduct) {
|
async function updateProduct(productId: string, updateForm: UpdateProduct) {
|
||||||
@@ -111,4 +103,4 @@ async function deleteProduct(productId: string) {
|
|||||||
return prisma.productItem.delete({ where: { id: productId } });
|
return prisma.productItem.delete({ where: { id: productId } });
|
||||||
}
|
}
|
||||||
|
|
||||||
export { getProduct, listProducts, createProduct, updateProduct, deleteProduct, type CreateProduct, type UpdateProduct };
|
export { getProduct, listProducts, createProduct, updateProduct, deleteProduct, getProductBySkuOrName, type CreateProduct, type UpdateProduct };
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
const L_ERROR = 0;
|
const L_ERROR = 0;
|
||||||
const L_WARN = 1;
|
const L_WARN = 1;
|
||||||
const L_INFO = 2;
|
const L_INFO = 2;
|
||||||
const L_DEBUG = 3;
|
const L_DEBUG = 3;
|
||||||
const L_TRACE = 4;
|
const L_TRACE = 4;
|
||||||
|
|
||||||
export { L_WARN, L_INFO, L_ERROR, L_DEBUG, L_TRACE };
|
export { L_WARN, L_INFO, L_ERROR, L_DEBUG, L_TRACE, isDev };
|
||||||
|
@@ -13,8 +13,7 @@ type ConfigType = {
|
|||||||
|
|
||||||
export const CONFIG: ConfigType = {
|
export const CONFIG: ConfigType = {
|
||||||
appVersion: packageJson.version,
|
appVersion: packageJson.version,
|
||||||
basePath:
|
basePath: process.env.NODE_ENV === 'production' ? process.env.PRODUCTION_API : process.env.DEV_API,
|
||||||
process.env.NODE_ENV === 'production' ? process.env.PRODUCTION_API : process.env.DEV_API,
|
|
||||||
cors: {
|
cors: {
|
||||||
/**
|
/**
|
||||||
* [] = allow all origins
|
* [] = allow all origins
|
||||||
|
@@ -2,7 +2,6 @@ import bcrypt from 'bcrypt';
|
|||||||
|
|
||||||
const generateHash = async (password: string) => bcrypt.hash(password, await bcrypt.genSalt(10));
|
const generateHash = async (password: string) => bcrypt.hash(password, await bcrypt.genSalt(10));
|
||||||
|
|
||||||
const validatePassword = async (password: string, hash: string) =>
|
const validatePassword = async (password: string, hash: string) => bcrypt.compare(password, hash as string);
|
||||||
bcrypt.compare(password, hash as string);
|
|
||||||
|
|
||||||
export { generateHash, validatePassword };
|
export { generateHash, validatePassword };
|
||||||
|
@@ -40,11 +40,7 @@ export function logger(label: string, value: unknown, breakLine: boolean = false
|
|||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
formattedValue = String(value);
|
formattedValue = String(value);
|
||||||
} else if (type === 'object') {
|
} else if (type === 'object') {
|
||||||
formattedValue = JSON.stringify(
|
formattedValue = JSON.stringify(value, null, breakLine || JSON.stringify(value).length > 50 ? 2 : 0);
|
||||||
value,
|
|
||||||
null,
|
|
||||||
breakLine || JSON.stringify(value).length > 50 ? 2 : 0
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
formattedValue = String(value);
|
formattedValue = String(value);
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,8 @@ export function setDate(now: Date, options: { days?: number; hours?: number; min
|
|||||||
return new Date(`${year}-${month}-${days ?? today} ${hours}:${minutes}`).toJSON();
|
return new Date(`${year}-${month}-${days ?? today} ${hours}:${minutes}`).toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const subHours = (
|
export const subHours = (value: number, option: 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds') =>
|
||||||
value: number,
|
dayjs().subtract(value, option).format();
|
||||||
option: 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'
|
|
||||||
) => dayjs().subtract(value, option).format();
|
|
||||||
|
|
||||||
// years,
|
// years,
|
||||||
// months,
|
// months,
|
||||||
@@ -38,15 +36,7 @@ export type DurationProps = {
|
|||||||
milliseconds?: number;
|
milliseconds?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fSub({
|
export function fSub({ years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0, milliseconds = 0 }: DurationProps) {
|
||||||
years = 0,
|
|
||||||
months = 0,
|
|
||||||
days = 0,
|
|
||||||
hours = 0,
|
|
||||||
minutes = 0,
|
|
||||||
seconds = 0,
|
|
||||||
milliseconds = 0,
|
|
||||||
}: DurationProps) {
|
|
||||||
const result = dayjs()
|
const result = dayjs()
|
||||||
.subtract(
|
.subtract(
|
||||||
dayjs.duration({
|
dayjs.duration({
|
||||||
@@ -64,15 +54,7 @@ export function fSub({
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fAdd({
|
export function fAdd({ years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0, milliseconds = 0 }: DurationProps) {
|
||||||
years = 0,
|
|
||||||
months = 0,
|
|
||||||
days = 0,
|
|
||||||
hours = 0,
|
|
||||||
minutes = 0,
|
|
||||||
seconds = 0,
|
|
||||||
milliseconds = 0,
|
|
||||||
}: DurationProps) {
|
|
||||||
const result = dayjs()
|
const result = dayjs()
|
||||||
.add(
|
.add(
|
||||||
dayjs.duration({
|
dayjs.duration({
|
||||||
|
@@ -34,9 +34,8 @@
|
|||||||
"node_modules",
|
"node_modules",
|
||||||
".next",
|
".next",
|
||||||
//
|
//
|
||||||
"**/* copy *.tsx",
|
"**/* copy *.*",
|
||||||
"**/* copy.tsx",
|
"**/* copy.*",
|
||||||
"**/*.bak",
|
|
||||||
"**/*.bak",
|
"**/*.bak",
|
||||||
"**/*.bug",
|
"**/*.bug",
|
||||||
"**/*.del",
|
"**/*.del",
|
||||||
|
@@ -10,7 +10,7 @@ services:
|
|||||||
mobile:
|
mobile:
|
||||||
command: "sleep infinity"
|
command: "sleep infinity"
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 8081:3000
|
||||||
|
|
||||||
cms_backend:
|
cms_backend:
|
||||||
command: "sleep infinity"
|
command: "sleep infinity"
|
||||||
|
4
03_source/frontend/.gitignore
vendored
4
03_source/frontend/.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
|
**/*del
|
||||||
|
**/*bak
|
||||||
|
**/*copy*
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
@@ -92,6 +92,8 @@ const sortImportsRules = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'perfectionist/sort-named-imports': [1, { type: 'line-length', order: 'asc' }],
|
||||||
|
'perfectionist/sort-named-exports': [1, { type: 'line-length', order: 'asc' }],
|
||||||
'perfectionist/sort-exports': [
|
'perfectionist/sort-exports': [
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@@ -100,8 +102,6 @@ const sortImportsRules = () => {
|
|||||||
groupKind: 'values-first',
|
groupKind: 'values-first',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'perfectionist/sort-named-imports': [1, { type: 'line-length', order: 'asc' }],
|
|
||||||
'perfectionist/sort-named-exports': [1, { type: 'line-length', order: 'asc' }],
|
|
||||||
'perfectionist/sort-imports': [
|
'perfectionist/sort-imports': [
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
|
@@ -21,8 +21,10 @@
|
|||||||
"re:build": "yarn clean && yarn install && yarn build",
|
"re:build": "yarn clean && yarn install && yarn build",
|
||||||
"re:build-npm": "npm run clean && npm install && npm run build",
|
"re:build-npm": "npm run clean && npm install && npm run build",
|
||||||
"tsc:dev": "yarn dev & yarn tsc:watch",
|
"tsc:dev": "yarn dev & yarn tsc:watch",
|
||||||
|
"tsc:print": "npx tsc --showConfig",
|
||||||
|
"tsc:w": "npx nodemon --delay 3 --ext ts,tsx --exec \"yarn tsc\"",
|
||||||
"tsc:watch": "tsc --noEmit --watch",
|
"tsc:watch": "tsc --noEmit --watch",
|
||||||
"tsc:print": "npx tsc --showConfig"
|
"tsc": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
"@fontsource-variable/noto-sans-sc": "^5.2.5",
|
"@fontsource-variable/noto-sans-sc": "^5.2.5",
|
||||||
"@fontsource-variable/noto-sans-tc": "^5.2.5",
|
"@fontsource-variable/noto-sans-tc": "^5.2.5",
|
||||||
"@fontsource-variable/nunito-sans": "^5.2.5",
|
"@fontsource-variable/nunito-sans": "^5.2.5",
|
||||||
|
"@fontsource-variable/public-sans": "^5.2.5",
|
||||||
"@fontsource/barlow": "^5.2.5",
|
"@fontsource/barlow": "^5.2.5",
|
||||||
"@fullcalendar/core": "^6.1.15",
|
"@fullcalendar/core": "^6.1.15",
|
||||||
"@fullcalendar/daygrid": "^6.1.15",
|
"@fullcalendar/daygrid": "^6.1.15",
|
||||||
@@ -52,7 +55,7 @@
|
|||||||
"@fullcalendar/timegrid": "^6.1.15",
|
"@fullcalendar/timegrid": "^6.1.15",
|
||||||
"@fullcalendar/timeline": "^6.1.15",
|
"@fullcalendar/timeline": "^6.1.15",
|
||||||
"@hookform/resolvers": "^4.1.3",
|
"@hookform/resolvers": "^4.1.3",
|
||||||
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
|
"@ianvs/prettier-plugin-sort-imports": "^4.4.2",
|
||||||
"@iconify/react": "^5.2.0",
|
"@iconify/react": "^5.2.0",
|
||||||
"@mui/lab": "^7.0.0-beta.10",
|
"@mui/lab": "^7.0.0-beta.10",
|
||||||
"@mui/material": "^7.0.1",
|
"@mui/material": "^7.0.1",
|
||||||
|
@@ -12,7 +12,7 @@ const config = {
|
|||||||
trailingComma: 'es5',
|
trailingComma: 'es5',
|
||||||
plugins: [
|
plugins: [
|
||||||
//
|
//
|
||||||
// '@ianvs/prettier-plugin-sort-imports',
|
'@ianvs/prettier-plugin-sort-imports',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
yarn --dev
|
yarn --dev
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
# yarn tsc:print
|
# yarn tsc:print
|
||||||
yarn lint:print
|
yarn lint:print
|
||||||
|
@@ -1,3 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
rm -rf ./**/*Zone.Identifier
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
yarn fm:fix
|
||||||
|
|
||||||
|
yarn tsc
|
||||||
|
|
||||||
yarn build
|
yarn build
|
||||||
|
|
||||||
|
echo "done"
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { info, error, primary, success, warning, secondary } from 'src/theme/core';
|
import { error, info, primary, secondary, success, warning } from 'src/theme/core';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { _mock } from './_mock';
|
import { _mock } from './_mock';
|
||||||
import { _tags, _fileNames } from './assets';
|
import { _fileNames, _tags } from './assets';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
import { fSub, fAdd } from 'src/utils/format-time';
|
import { fAdd, fSub } from 'src/utils/format-time';
|
||||||
|
|
||||||
import { _mock } from './_mock';
|
import { _mock } from './_mock';
|
||||||
import { _tags } from './assets';
|
|
||||||
import { _addressBooks } from './_others';
|
import { _addressBooks } from './_others';
|
||||||
|
import { _tags } from './assets';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,36 +1,34 @@
|
|||||||
import { fSub } from 'src/utils/format-time';
|
|
||||||
|
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
import { fSub } from 'src/utils/format-time';
|
||||||
import {
|
import {
|
||||||
_id,
|
|
||||||
_ages,
|
_ages,
|
||||||
_roles,
|
|
||||||
_prices,
|
|
||||||
_emails,
|
|
||||||
_ratings,
|
|
||||||
_nativeS,
|
|
||||||
_nativeM,
|
|
||||||
_nativeL,
|
|
||||||
_percents,
|
|
||||||
_booleans,
|
_booleans,
|
||||||
_sentences,
|
|
||||||
_lastNames,
|
|
||||||
_fullNames,
|
|
||||||
_tourNames,
|
|
||||||
_jobTitles,
|
|
||||||
_taskNames,
|
|
||||||
_fileNames,
|
|
||||||
_postTitles,
|
|
||||||
_firstNames,
|
|
||||||
_eventNames,
|
|
||||||
_courseNames,
|
|
||||||
_fullAddress,
|
|
||||||
_companyNames,
|
_companyNames,
|
||||||
_productNames,
|
|
||||||
_descriptions,
|
|
||||||
_phoneNumbers,
|
|
||||||
_countryNames,
|
_countryNames,
|
||||||
|
_courseNames,
|
||||||
|
_descriptions,
|
||||||
|
_emails,
|
||||||
|
_eventNames,
|
||||||
|
_fileNames,
|
||||||
|
_firstNames,
|
||||||
|
_fullAddress,
|
||||||
|
_fullNames,
|
||||||
|
_id,
|
||||||
|
_jobTitles,
|
||||||
|
_lastNames,
|
||||||
|
_nativeL,
|
||||||
|
_nativeM,
|
||||||
|
_nativeS,
|
||||||
|
_percents,
|
||||||
|
_phoneNumbers,
|
||||||
|
_postTitles,
|
||||||
|
_prices,
|
||||||
|
_productNames,
|
||||||
|
_ratings,
|
||||||
|
_roles,
|
||||||
|
_sentences,
|
||||||
|
_taskNames,
|
||||||
|
_tourNames,
|
||||||
} from './assets';
|
} from './assets';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
import { today } from 'src/utils/format-time';
|
|
||||||
|
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
import { today } from 'src/utils/format-time';
|
||||||
import { _mock } from './_mock';
|
import { _mock } from './_mock';
|
||||||
|
|
||||||
// APP
|
// APP
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
import type { SWRConfiguration } from 'swr';
|
|
||||||
import type { IPostItem } from 'src/types/blog';
|
|
||||||
|
|
||||||
import useSWR from 'swr';
|
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import { endpoints, fetcher } from 'src/lib/axios';
|
||||||
import { fetcher, endpoints } from 'src/lib/axios';
|
import type { IPostItem } from 'src/types/blog';
|
||||||
|
import type { SWRConfiguration } from 'swr';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
import type { SWRConfiguration } from 'swr';
|
|
||||||
import type { ICalendarEvent } from 'src/types/calendar';
|
|
||||||
|
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import axios, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
|
import type { ICalendarEvent } from 'src/types/calendar';
|
||||||
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR, { mutate } from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
|
|
||||||
import axios, { fetcher, endpoints } from 'src/lib/axios';
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
const enableServer = false;
|
const enableServer = false;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
import type { SWRConfiguration } from 'swr';
|
|
||||||
import type { IChatMessage, IChatParticipant, IChatConversation } from 'src/types/chat';
|
|
||||||
|
|
||||||
import { useMemo } from 'react';
|
|
||||||
import { keyBy } from 'es-toolkit';
|
import { keyBy } from 'es-toolkit';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import axios, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
|
import type { IChatConversation, IChatMessage, IChatParticipant } from 'src/types/chat';
|
||||||
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR, { mutate } from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
|
|
||||||
import axios, { fetcher, endpoints } from 'src/lib/axios';
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
const enableServer = false;
|
const enableServer = false;
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
import type { SWRConfiguration } from 'swr';
|
|
||||||
import type { UniqueIdentifier } from '@dnd-kit/core';
|
import type { UniqueIdentifier } from '@dnd-kit/core';
|
||||||
import type { IKanban, IKanbanTask, IKanbanColumn } from 'src/types/kanban';
|
import { startTransition, useMemo } from 'react';
|
||||||
|
import axios, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
|
import type { IKanban, IKanbanColumn, IKanbanTask } from 'src/types/kanban';
|
||||||
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR, { mutate } from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
import { useMemo, startTransition } from 'react';
|
|
||||||
|
|
||||||
import axios, { fetcher, endpoints } from 'src/lib/axios';
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
import type { SWRConfiguration } from 'swr';
|
|
||||||
import type { IMail, IMailLabel } from 'src/types/mail';
|
|
||||||
|
|
||||||
import useSWR from 'swr';
|
|
||||||
import { useMemo } from 'react';
|
|
||||||
import { keyBy } from 'es-toolkit';
|
import { keyBy } from 'es-toolkit';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import { fetcher, endpoints } from 'src/lib/axios';
|
import { endpoints, fetcher } from 'src/lib/axios';
|
||||||
|
import type { IMail, IMailLabel } from 'src/types/mail';
|
||||||
|
import type { SWRConfiguration } from 'swr';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
// src/actions/order.ts
|
// src/actions/order.ts
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
import type { IProductItem } from 'src/types/product';
|
|
||||||
import type { IOrderItem } from 'src/types/order';
|
import type { IOrderItem } from 'src/types/order';
|
||||||
|
import type { IProductItem } from 'src/types/product';
|
||||||
import type { SWRConfiguration } from 'swr';
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
// src/actions/product.ts
|
// src/actions/product.ts
|
||||||
|
//
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
import type { IProductItem } from 'src/types/product';
|
import type { IProductItem } from 'src/types/product';
|
||||||
import type { SWRConfiguration } from 'swr';
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -22,11 +23,7 @@ type ProductsData = {
|
|||||||
export function useGetProducts() {
|
export function useGetProducts() {
|
||||||
const url = endpoints.product.list;
|
const url = endpoints.product.list;
|
||||||
|
|
||||||
const { data, isLoading, error, isValidating, mutate } = useSWR<ProductsData>(
|
const { data, isLoading, error, isValidating } = useSWR<ProductsData>(url, fetcher, swrOptions);
|
||||||
url,
|
|
||||||
fetcher,
|
|
||||||
swrOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
const memoizedValue = useMemo(
|
const memoizedValue = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -35,9 +32,8 @@ export function useGetProducts() {
|
|||||||
productsError: error,
|
productsError: error,
|
||||||
productsValidating: isValidating,
|
productsValidating: isValidating,
|
||||||
productsEmpty: !isLoading && !isValidating && !data?.products.length,
|
productsEmpty: !isLoading && !isValidating && !data?.products.length,
|
||||||
mutate,
|
|
||||||
}),
|
}),
|
||||||
[data?.products, error, isLoading, isValidating, mutate]
|
[data?.products, error, isLoading, isValidating]
|
||||||
);
|
);
|
||||||
|
|
||||||
return memoizedValue;
|
return memoizedValue;
|
||||||
@@ -56,10 +52,11 @@ export function useGetProduct(productId: string) {
|
|||||||
|
|
||||||
const memoizedValue = useMemo(
|
const memoizedValue = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
currentProduct: data?.product,
|
product: data?.product,
|
||||||
productLoading: isLoading,
|
productLoading: isLoading,
|
||||||
productError: error,
|
productError: error,
|
||||||
productValidating: isValidating,
|
productValidating: isValidating,
|
||||||
|
mutate,
|
||||||
}),
|
}),
|
||||||
[data?.product, error, isLoading, isValidating]
|
[data?.product, error, isLoading, isValidating]
|
||||||
);
|
);
|
||||||
@@ -97,140 +94,82 @@ export function useSearchProducts(query: string) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type SaveProductData = {
|
export async function createProduct(productData: IProductItem) {
|
||||||
// id: string;
|
/**
|
||||||
|
* Work on server
|
||||||
|
*/
|
||||||
|
const data = { productData };
|
||||||
|
const {
|
||||||
|
data: { id },
|
||||||
|
} = await axiosInstance.post(endpoints.product.create, data);
|
||||||
|
|
||||||
sku: string;
|
/**
|
||||||
name: string;
|
* Work in local
|
||||||
code: string;
|
*/
|
||||||
price: number | null;
|
mutate(
|
||||||
taxes: number | null;
|
endpoints.product.list,
|
||||||
tags: string[];
|
(currentData: any) => {
|
||||||
sizes: string[];
|
const currentProducts: IProductItem[] = currentData?.products;
|
||||||
// publish: string;
|
|
||||||
gender: string[];
|
|
||||||
// coverUrl: string;
|
|
||||||
images: (string | File)[];
|
|
||||||
colors: string[];
|
|
||||||
quantity: number | null;
|
|
||||||
category: string;
|
|
||||||
// available: number;
|
|
||||||
// totalSold: number;
|
|
||||||
description: string;
|
|
||||||
// totalRatings: number;
|
|
||||||
// totalReviews: number;
|
|
||||||
// inventoryType: string;
|
|
||||||
subDescription: string;
|
|
||||||
priceSale: number | null;
|
|
||||||
newLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
saleLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
// ratings: {
|
|
||||||
// name: string;
|
|
||||||
// starCount: number;
|
|
||||||
// reviewCount: number;
|
|
||||||
// }[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function saveProduct(productId: string, saveProductData: SaveProductData) {
|
const products = [...currentProducts, { ...productData, id }];
|
||||||
console.log('save product ?');
|
|
||||||
// const url = productId ? [endpoints.product.details, { params: { productId } }] : '';
|
|
||||||
|
|
||||||
const res = await axiosInstance.post('http://localhost:7272/api/product/saveProduct', {
|
return { ...currentData, products };
|
||||||
data: saveProductData,
|
},
|
||||||
});
|
false
|
||||||
|
);
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function uploadProductImage(saveProductData: SaveProductData) {
|
|
||||||
console.log('save product ?');
|
|
||||||
// const url = productId ? [endpoints.product.details, { params: { productId } }] : '';
|
|
||||||
|
|
||||||
const res = await axiosInstance.get('http://localhost:7272/api/product/helloworld');
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type CreateProductData = {
|
export async function updateProduct(productData: Partial<IProductItem>) {
|
||||||
// id: string;
|
/**
|
||||||
sku: string;
|
* Work on server
|
||||||
name: string;
|
*/
|
||||||
code: string;
|
const data = { productData };
|
||||||
price: number | null;
|
await axiosInstance.put(endpoints.product.update, data);
|
||||||
taxes: number | null;
|
|
||||||
tags: string[];
|
|
||||||
sizes: string[];
|
|
||||||
publish: string;
|
|
||||||
gender: string[];
|
|
||||||
coverUrl: string;
|
|
||||||
images: (string | File)[];
|
|
||||||
colors: string[];
|
|
||||||
quantity: number | null;
|
|
||||||
category: string;
|
|
||||||
available: number;
|
|
||||||
totalSold: number;
|
|
||||||
description: string;
|
|
||||||
totalRatings: number;
|
|
||||||
totalReviews: number;
|
|
||||||
inventoryType: string;
|
|
||||||
subDescription: string;
|
|
||||||
priceSale: number | null;
|
|
||||||
newLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
saleLabel: {
|
|
||||||
content: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
// ratings: {
|
|
||||||
// name: string;
|
|
||||||
// starCount: number;
|
|
||||||
// reviewCount: number;
|
|
||||||
// }[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function createProduct(createProductData: CreateProductData) {
|
/**
|
||||||
console.log('create product ?');
|
* Work in local
|
||||||
// const url = productId ? [endpoints.product.details, { params: { productId } }] : '';
|
*/
|
||||||
|
|
||||||
const res = await axiosInstance.post('http://localhost:7272/api/product/createProduct', {
|
mutate(
|
||||||
data: createProductData,
|
endpoints.product.list,
|
||||||
});
|
(currentData: any) => {
|
||||||
|
const currentProducts: IProductItem[] = currentData?.products;
|
||||||
|
|
||||||
return res;
|
const products = currentProducts.map((product) =>
|
||||||
|
product.id === productData.id ? { ...product, ...productData } : product
|
||||||
|
);
|
||||||
|
|
||||||
|
return { ...currentData, products };
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type DeleteProductResponse = {
|
export async function deleteProduct(productId: string) {
|
||||||
success: boolean;
|
/**
|
||||||
message?: string;
|
* Work on server
|
||||||
};
|
*/
|
||||||
|
const data = { productId };
|
||||||
|
await axiosInstance.patch(endpoints.product.delete, data);
|
||||||
|
|
||||||
export async function deleteProduct(productId: string): Promise<DeleteProductResponse> {
|
/**
|
||||||
const url = `http://localhost:7272/api/product/deleteProduct?productId=${productId}`;
|
* Work in local
|
||||||
|
*/
|
||||||
|
|
||||||
try {
|
mutate(
|
||||||
const res = await axiosInstance.delete(url);
|
endpoints.product.list,
|
||||||
console.log({ res });
|
(currentData: any) => {
|
||||||
|
console.log({ currentData });
|
||||||
|
const currentProducts: IProductItem[] = currentData?.products;
|
||||||
|
|
||||||
return {
|
const products = currentProducts.filter((product) => product.id !== productId);
|
||||||
success: true,
|
|
||||||
message: 'Product deleted successfully',
|
return { ...currentData, products };
|
||||||
};
|
},
|
||||||
} catch (error) {
|
false
|
||||||
return {
|
);
|
||||||
success: false,
|
|
||||||
message: error instanceof Error ? error.message : 'Failed to delete product',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { CONFIG } from 'src/global-config';
|
import { CONFIG } from 'src/global-config';
|
||||||
|
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
||||||
|
|
||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
import SvgIcon from '@mui/material/SvgIcon';
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import { memo } from 'react';
|
||||||
import { BackgroundShape } from './background-shape';
|
import { BackgroundShape } from './background-shape';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import type { Theme, SxProps } from '@mui/material/styles';
|
|
||||||
|
|
||||||
import Divider from '@mui/material/Divider';
|
import Divider from '@mui/material/Divider';
|
||||||
|
import type { SxProps, Theme } from '@mui/material/styles';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user