Compare commits
37 Commits
develop/cm
...
a4d0d8b746
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a4d0d8b746 | ||
![]() |
f8919b8c84 | ||
![]() |
583e31fd4d | ||
![]() |
ae7f005236 | ||
![]() |
834f9360ba | ||
![]() |
1cb018d4d5 | ||
![]() |
448825545e | ||
![]() |
7c7a532381 | ||
![]() |
eb515dbe68 | ||
![]() |
7a793be610 | ||
![]() |
1d89134ea2 | ||
![]() |
44d324b40e | ||
![]() |
ee2a377bf6 | ||
![]() |
0941ab6dd1 | ||
![]() |
e93c5dcf62 | ||
![]() |
17aaf97722 | ||
![]() |
47660be0cd | ||
![]() |
cf5cfb8d63 | ||
![]() |
a686dd55dd | ||
![]() |
8d52be9b96 | ||
![]() |
db16b2d5dd | ||
![]() |
7370316ea0 | ||
![]() |
77f7211317 | ||
![]() |
dfc9873815 | ||
![]() |
53b112e488 | ||
![]() |
a9dd265658 | ||
![]() |
ae39b7ca67 | ||
![]() |
4c2a06585d | ||
![]() |
816d88c2c1 | ||
![]() |
843e459527 | ||
![]() |
cd0ae5ba62 | ||
![]() |
ecdbc45c4a | ||
![]() |
4b64778b59 | ||
![]() |
a88de2f17f | ||
![]() |
d987b0fe36 | ||
![]() |
0142c9ba24 | ||
![]() |
48e1f821ad |
@@ -1,10 +1,10 @@
|
||||
---
|
||||
tags: frontend, product, update
|
||||
tags: frontend, party-event
|
||||
---
|
||||
|
||||
# REQ0185 frontend product update
|
||||
# REQ0185 frontend party-event
|
||||
|
||||
frontend page to update product
|
||||
frontend page to handle party-event (CRUD)
|
||||
|
||||
edit page T.B.A.
|
||||
|
||||
@@ -14,4 +14,5 @@ T.B.A.
|
||||
|
||||
## branch
|
||||
|
||||
develop/frontend/party-event/trunk
|
||||
develop/requirements/REQ0185
|
||||
|
17
01_Requirements/REQ0186/index.md
Normal file
17
01_Requirements/REQ0186/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
|
23
01_Requirements/REQ0187/index.md
Normal file
23
01_Requirements/REQ0187/index.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
tags: frontend, party-order
|
||||
---
|
||||
|
||||
# REQ0185 frontend party-order
|
||||
|
||||
frontend page to handle party-order (CRUD)
|
||||
|
||||
edit page T.B.A.
|
||||
|
||||
## TODO
|
||||
|
||||
- remove detail in left nav bar
|
||||
- implement `changeStatus`
|
||||
|
||||
## sources
|
||||
|
||||
T.B.A.
|
||||
|
||||
## branch
|
||||
|
||||
develop/frontend/party-order/trunk
|
||||
develop/requirements/REQ0187
|
20
01_Requirements/REQ0188/index.md
Normal file
20
01_Requirements/REQ0188/index.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
tags: frontend, party-user
|
||||
---
|
||||
|
||||
# REQ0188 frontend party-user
|
||||
|
||||
frontend page to handle party-user (CRUD)
|
||||
|
||||
edit page T.B.A.
|
||||
|
||||
## TODO
|
||||
|
||||
## sources
|
||||
|
||||
T.B.A.
|
||||
|
||||
## branch
|
||||
|
||||
develop/requirements/REQ0188
|
||||
develop/frontend/party-user/trunk
|
@@ -6,6 +6,7 @@ RUN npm install -g pnpm
|
||||
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y openssl
|
||||
RUN apt-get install -qqy psmisc
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
@@ -21,7 +21,7 @@
|
||||
"re:build-npm": "npm run clean && npm install && npm run build",
|
||||
"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:w": "npx nodemon --delay 1 --ext ts,tsx --exec \"yarn tsc\"",
|
||||
"tsc:watch": "tsc --noEmit --watch",
|
||||
"tsc": "tsc --noEmit",
|
||||
"migrate": "npx prisma migrate dev --skip-seed",
|
||||
@@ -34,7 +34,7 @@
|
||||
"db:studio": "prisma studio",
|
||||
"db:studio:w": "npx nodemon --delay 1 --watch prisma --ext \"prisma\" --exec \"yarn db:studio\"",
|
||||
"db:dev": "yarn db:push && yarn seed && yarn dev",
|
||||
"db:dev:w": "npx nodemon --delay 1 --ext \"ts,tsx,prisma\" --exec \"yarn db:dev\""
|
||||
"db:dev:w": "npx nodemon --delay 3 --ext \"ts,tsx,prisma\" --exec \"yarn db:dev\""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
|
@@ -31,17 +31,21 @@ model Account {
|
||||
oauth_token_secret String?
|
||||
oauth_token String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
PartyUser PartyUser? @relation(fields: [partyUserId], references: [id])
|
||||
partyUserId String?
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId String @map("user_id")
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId String @map("user_id")
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
PartyUser PartyUser? @relation(fields: [partyUserId], references: [id])
|
||||
partyUserId String?
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -1230,3 +1234,60 @@ model AccessLog {
|
||||
@@index([timestamp])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model PartyOrderItem {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
taxes Float
|
||||
status String
|
||||
shipping Float
|
||||
discount Float
|
||||
subtotal Float
|
||||
orderNumber String
|
||||
totalAmount Float
|
||||
totalQuantity Float
|
||||
history Json
|
||||
payment Json
|
||||
customer Json
|
||||
delivery Json
|
||||
items Json[]
|
||||
shippingAddress Json
|
||||
// OrderProductItem OrderProductItem[]
|
||||
// OrderHistory OrderHistory[]
|
||||
// OrderDelivery OrderDelivery[]
|
||||
// OrderCustomer OrderCustomer[]
|
||||
// OrderPayment OrderPayment[]
|
||||
// OrderShippingAddress OrderShippingAddress[]
|
||||
}
|
||||
|
||||
model PartyUser {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
username String? @unique
|
||||
password String?
|
||||
//
|
||||
name String?
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
avatarUrl String?
|
||||
bucketImage String?
|
||||
admin Boolean @default(false)
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
info Json?
|
||||
phoneNumber String @default("")
|
||||
company String @default("")
|
||||
status String @default("pending")
|
||||
role String @default("")
|
||||
isVerified Boolean @default(false)
|
||||
//
|
||||
country String @default("")
|
||||
state String @default("")
|
||||
city String @default("")
|
||||
address String @default("")
|
||||
zipCode String @default("")
|
||||
}
|
||||
|
@@ -31,6 +31,9 @@ import { EventReviewSeed } from './seeds/eventReview';
|
||||
import { appLogSeed } from './seeds/AppLog';
|
||||
import { accessLogSeed } from './seeds/AccessLog';
|
||||
import { userMetaSeed } from './seeds/userMeta';
|
||||
//
|
||||
import { partyOrderItemSeed } from './seeds/partyOrderItem';
|
||||
import { partyUserSeed } from './seeds/partyUser';
|
||||
|
||||
//
|
||||
// import { Blog } from './seeds/blog';
|
||||
@@ -59,6 +62,9 @@ import { userMetaSeed } from './seeds/userMeta';
|
||||
//
|
||||
await appLogSeed;
|
||||
await accessLogSeed;
|
||||
//
|
||||
await partyOrderItemSeed;
|
||||
await partyUserSeed;
|
||||
|
||||
// await Blog;
|
||||
// await Mail;
|
||||
|
@@ -125,7 +125,7 @@ const generateRatings = () =>
|
||||
const generateImages = () => Array.from({ length: 8 }, (_, index) => _mock.image.event(index));
|
||||
|
||||
const _events = () =>
|
||||
Array.from({ length: 2 }, (_, index) => {
|
||||
Array.from({ length: 5 }, (_, index) => {
|
||||
const reviews = generateReviews();
|
||||
const images = generateImages();
|
||||
const ratings = generateRatings();
|
||||
|
94
03_source/cms_backend/prisma/seeds/partyOrderItem.ts
Normal file
94
03_source/cms_backend/prisma/seeds/partyOrderItem.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { _mock } from './_mock';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const ITEMS = Array.from({ length: 3 }, (_, index) => ({
|
||||
id: _mock.id(index),
|
||||
sku: `16H9UR${index}`,
|
||||
quantity: index + 1,
|
||||
name: _mock.productName(index),
|
||||
coverUrl: _mock.image.product(index),
|
||||
price: _mock.number.price(index),
|
||||
}));
|
||||
|
||||
async function partyOrderItem() {
|
||||
await prisma.partyOrderItem.deleteMany({});
|
||||
|
||||
for (let index = 1; index < 20 + 1; index++) {
|
||||
const shipping = 10;
|
||||
const discount = 10;
|
||||
const taxes = 10;
|
||||
const items = (index % 2 && ITEMS.slice(0, 1)) || (index % 3 && ITEMS.slice(1, 3)) || ITEMS;
|
||||
const totalQuantity = items.reduce((accumulator, item) => accumulator + item.quantity, 0);
|
||||
const subtotal = items.reduce((accumulator, item) => accumulator + item.price * item.quantity, 0);
|
||||
const totalAmount = subtotal - shipping - discount + taxes;
|
||||
|
||||
const customer = {
|
||||
id: _mock.id(index),
|
||||
name: _mock.fullName(index),
|
||||
email: _mock.email(index),
|
||||
avatarUrl: _mock.image.avatar(index),
|
||||
ipAddress: '192.158.1.38',
|
||||
};
|
||||
|
||||
const delivery = { shipBy: 'DHL', speedy: 'Standard', trackingNumber: 'SPX037739199373' };
|
||||
|
||||
const history = {
|
||||
orderTime: _mock.time(1),
|
||||
paymentTime: _mock.time(2),
|
||||
deliveryTime: _mock.time(3),
|
||||
completionTime: _mock.time(4),
|
||||
timeline: [
|
||||
{ title: 'Delivery successful', time: _mock.time(1) },
|
||||
{ title: 'Transporting to [2]', time: _mock.time(2) },
|
||||
{ title: 'Transporting to [1]', time: _mock.time(3) },
|
||||
{ title: 'The shipping unit has picked up the goods', time: _mock.time(4) },
|
||||
{ title: 'Order has been created', time: _mock.time(5) },
|
||||
],
|
||||
};
|
||||
|
||||
const temp = await prisma.partyOrderItem.upsert({
|
||||
where: { id: index.toString() },
|
||||
update: {},
|
||||
create: {
|
||||
id: _mock.id(index),
|
||||
orderNumber: `#601${index}`,
|
||||
taxes,
|
||||
items,
|
||||
history,
|
||||
subtotal: items.reduce((accumulator, item) => accumulator + item.price * item.quantity, 0),
|
||||
shipping,
|
||||
discount,
|
||||
customer,
|
||||
delivery,
|
||||
totalAmount,
|
||||
totalQuantity,
|
||||
shippingAddress: {
|
||||
fullAddress: '19034 Verna Unions Apt. 164 - Honolulu, RI / 87535',
|
||||
phoneNumber: '365-374-4961',
|
||||
},
|
||||
payment: {
|
||||
//
|
||||
cardType: 'mastercard',
|
||||
cardNumber: '4111 1111 1111 1111',
|
||||
},
|
||||
status: (index % 2 && 'completed') || (index % 3 && 'pending') || (index % 4 && 'cancelled') || 'refunded',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('seed partyOrderItemSeed done');
|
||||
}
|
||||
|
||||
const partyOrderItemSeed = partyOrderItem()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { partyOrderItemSeed };
|
122
03_source/cms_backend/prisma/seeds/partyUser.ts
Normal file
122
03_source/cms_backend/prisma/seeds/partyUser.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import { faker as enFaker } from '@faker-js/faker/locale/en_US';
|
||||
import { faker as zhFaker } from '@faker-js/faker/locale/zh_CN';
|
||||
import { faker as jaFaker } from '@faker-js/faker/locale/ja';
|
||||
import { faker as koFaker } from '@faker-js/faker/locale/ko';
|
||||
import { faker as twFaker } from '@faker-js/faker/locale/zh_TW';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const ROLE = [
|
||||
`CEO`,
|
||||
`CTO`,
|
||||
`Project Coordinator`,
|
||||
`Team Leader`,
|
||||
`Software Developer`,
|
||||
`Marketing Strategist`,
|
||||
`Data Analyst`,
|
||||
`Product Owner`,
|
||||
`Graphic Designer`,
|
||||
`Operations Manager`,
|
||||
`Customer Support Specialist`,
|
||||
`Sales Manager`,
|
||||
`HR Recruiter`,
|
||||
`Business Consultant`,
|
||||
`Financial Planner`,
|
||||
`Network Engineer`,
|
||||
`Content Creator`,
|
||||
`Quality Assurance Tester`,
|
||||
`Public Relations Officer`,
|
||||
`IT Administrator`,
|
||||
`Compliance Officer`,
|
||||
`Event Planner`,
|
||||
`Legal Counsel`,
|
||||
`Training Coordinator`,
|
||||
];
|
||||
|
||||
const STATUS = ['active', 'pending', 'banned'];
|
||||
|
||||
async function partyUser() {
|
||||
const alice = await prisma.partyUser.upsert({
|
||||
where: { email: 'alice@prisma.io' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'alice@prisma.io',
|
||||
name: 'Alice',
|
||||
username: 'pualice',
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: '+85291234567',
|
||||
company: 'helloworld company',
|
||||
status: STATUS[0],
|
||||
role: ROLE[0],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.partyUser.upsert({
|
||||
where: { email: 'demo@minimals.cc' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'demo@minimals.cc',
|
||||
name: 'Demo',
|
||||
username: 'pudemo',
|
||||
password: '@2Minimal',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: '+85291234568',
|
||||
company: 'helloworld company',
|
||||
status: STATUS[1],
|
||||
role: ROLE[1],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const CJK_LOCALES = {
|
||||
en: enFaker,
|
||||
zh: zhFaker,
|
||||
ja: jaFaker,
|
||||
ko: koFaker,
|
||||
tw: twFaker,
|
||||
};
|
||||
|
||||
function getRandomCJKFaker() {
|
||||
const locales = Object.keys(CJK_LOCALES);
|
||||
const randomKey = locales[Math.floor(Math.random() * locales.length)] as keyof typeof CJK_LOCALES;
|
||||
return CJK_LOCALES[randomKey];
|
||||
}
|
||||
|
||||
const randomFaker = getRandomCJKFaker();
|
||||
|
||||
await prisma.partyUser.upsert({
|
||||
where: { email: `party_user${i}@prisma.io` },
|
||||
update: {},
|
||||
create: {
|
||||
email: `party_user${i}@prisma.io`,
|
||||
name: `Party Dummy ${i}`,
|
||||
username: `pu${i.toString()}`,
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: `+8529123456${i.toString()}`,
|
||||
company: randomFaker.company.name(),
|
||||
role: ROLE[Math.floor(Math.random() * ROLE.length)],
|
||||
status: STATUS[Math.floor(Math.random() * STATUS.length)],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('seed partyUser done');
|
||||
}
|
||||
|
||||
const partyUserSeed = partyUser()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { partyUserSeed };
|
@@ -5,14 +5,15 @@ yarn --dev
|
||||
clear
|
||||
|
||||
while true; do
|
||||
# yarn db:push
|
||||
# yarn seed
|
||||
|
||||
yarn db:studio &
|
||||
|
||||
npx nodemon --ext ts,tsx,prisma --exec "yarn dev"
|
||||
# npx nodemon --ext ts,tsx,prisma --exec "yarn db:push && yarn seed && yarn dev"
|
||||
# yarn dev
|
||||
|
||||
killall node
|
||||
killall yarn
|
||||
|
||||
echo "restarting..."
|
||||
sleep 1
|
||||
done
|
||||
|
@@ -4,8 +4,6 @@ yarn --dev
|
||||
|
||||
clear
|
||||
|
||||
while true; do
|
||||
npx nodemon --ext prisma --exec "yarn db:push && yarn seed"
|
||||
echo "restarting..."
|
||||
sleep 1
|
||||
done
|
||||
yarn db:push && yarn seed
|
||||
|
||||
echo "done"
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
set -x
|
||||
|
||||
killall node
|
||||
killall yarn
|
||||
rm -rf ./**/*Zone.Identifier
|
||||
|
||||
# yarn db:push
|
||||
|
14
03_source/cms_backend/src/app/api/_PROMPTS/clone_srevice.md
Normal file
14
03_source/cms_backend/src/app/api/_PROMPTS/clone_srevice.md
Normal file
@@ -0,0 +1,14 @@
|
||||
Hi,
|
||||
|
||||
i copied from
|
||||
`03_source/cms_backend/src/app/api/party-event`
|
||||
to
|
||||
`03_source/cms_backend/src/app/api/party-order`
|
||||
|
||||
with knowledge in `schema.prisma` file, and take a look into the sibling files in the same directory.
|
||||
|
||||
i want you to update `03_source/cms_backend/src/app/api/party-order` content to handle `party-order` (the purchase order of the party)
|
||||
`party-order.service.ts` is already prepared and you can use it
|
||||
please maintain same format and level of detail when you edit.
|
||||
|
||||
thanks.
|
35
03_source/cms_backend/src/app/api/party-event/_GUIDELINES.md
Normal file
35
03_source/cms_backend/src/app/api/party-event/_GUIDELINES.md
Normal file
@@ -0,0 +1,35 @@
|
||||
<!-- AI: please maintain same format and level of detail when edit this file -->
|
||||
|
||||
# GUIDELINE
|
||||
|
||||
- Party Event API endpoint for managing party events
|
||||
- Handles CRUD operations for party events
|
||||
- Follows single file for single db table/collection pattern
|
||||
|
||||
## `route.ts`
|
||||
|
||||
Handles HTTP methods:
|
||||
|
||||
- `GET` - Retrieve party events
|
||||
- `POST` - Create new party event
|
||||
- `PUT` - Update existing party event
|
||||
- `DELETE` - Remove party event
|
||||
|
||||
## `test.http`
|
||||
|
||||
Contains test requests for:
|
||||
|
||||
- Listing all party events
|
||||
- Creating new party event
|
||||
- Updating existing party event
|
||||
- Deleting party event
|
||||
|
||||
## `../../services/party-event.service.ts`
|
||||
|
||||
Party Event CRUD operations:
|
||||
|
||||
`listPartyEvents` - List all party events with optional filters
|
||||
`getPartyEvent` - Get single party event by ID
|
||||
`createNewPartyEvent` - Create new party event record
|
||||
`updatePartyEvent` - Update existing party event by ID
|
||||
`deletePartyEvent` - Delete party event by ID
|
@@ -9,13 +9,13 @@ import { deleteEvent } from 'src/app/services/party-event.service';
|
||||
*************************************** */
|
||||
export async function PATCH(req: NextRequest) {
|
||||
try {
|
||||
const { eventId } = await req.json();
|
||||
const { partyEventId } = await req.json();
|
||||
|
||||
if (!eventId) throw new Error('eventId cannot be null');
|
||||
if (!partyEventId) throw new Error('partyEventId cannot be null');
|
||||
|
||||
await deleteEvent(eventId);
|
||||
await deleteEvent(partyEventId);
|
||||
|
||||
return response({ eventId }, STATUS.OK);
|
||||
return response({ partyEventId }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyEvent - Delete', error);
|
||||
}
|
||||
|
@@ -4,5 +4,5 @@ PATCH http://localhost:7272/api/party-event/delete
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"eventId": "e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01"
|
||||
"partyEventId": "e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01"
|
||||
}
|
||||
|
@@ -31,23 +31,23 @@ export async function GET(req: NextRequest) {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: eventId must exist
|
||||
const eventId = searchParams.get('eventId');
|
||||
if (!eventId) {
|
||||
return response({ message: 'Event ID is required!' }, STATUS.BAD_REQUEST);
|
||||
const partyEventId = searchParams.get('partyEventId');
|
||||
if (!partyEventId) {
|
||||
return response({ message: 'PartyEvent ID is required!' }, STATUS.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// NOTE: eventId confirmed exist, run below
|
||||
const event = await getEvent(eventId);
|
||||
const partyEvent = await getEvent(partyEventId);
|
||||
|
||||
if (!event) {
|
||||
return response({ message: 'Event not found!' }, STATUS.NOT_FOUND);
|
||||
if (!partyEvent) {
|
||||
return response({ message: 'PartyEvent not found!' }, STATUS.NOT_FOUND);
|
||||
}
|
||||
|
||||
logger('[PartyEvent] details', event.id);
|
||||
logger('[PartyEvent] details', partyEvent.id);
|
||||
|
||||
createAppLog(L_INFO, 'Get event detail OK', debug);
|
||||
|
||||
return response({ event }, STATUS.OK);
|
||||
return response({ partyEvent }, STATUS.OK);
|
||||
} catch (error) {
|
||||
createAppLog(L_ERROR, 'event detail error', debug);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
###
|
||||
|
||||
# Get details for a specific party event
|
||||
GET http://localhost:7272/api/party-event/details?eventId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
||||
GET http://localhost:7272/api/party-event/details?partyEventId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
||||
|
||||
###
|
||||
|
||||
|
@@ -25,11 +25,11 @@ export async function GET(req: NextRequest) {
|
||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||
|
||||
try {
|
||||
const events = await listEvents();
|
||||
const partyEvents = await listEvents();
|
||||
|
||||
createAppLog(L_INFO, 'party-event list ok', {});
|
||||
|
||||
return response({ events }, STATUS.OK);
|
||||
return response({ partyEvents }, STATUS.OK);
|
||||
} catch (error) {
|
||||
createAppLog(L_ERROR, 'party-event list error', debug);
|
||||
|
||||
|
@@ -6,20 +6,15 @@ Content-Type: application/json
|
||||
{
|
||||
"partyEventData": {
|
||||
"id":"e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01",
|
||||
"title": "Summer Music Festival",
|
||||
"title": "Summer Music Festival 111",
|
||||
"name": "Summer Music Festival 111",
|
||||
"description": "Annual summer music festival featuring local bands and artists",
|
||||
"startDate": "2024-07-15T18:00:00Z",
|
||||
"endDate": "2024-07-15T23:00:00Z",
|
||||
"location": "Central Park, Hong Kong",
|
||||
"coverUrl": "",
|
||||
"images": [
|
||||
"data:image/png;base64,C",
|
||||
"data:image/png;base64,C"
|
||||
],
|
||||
"tags": [
|
||||
"Music",
|
||||
"Festival"
|
||||
],
|
||||
"images": [ "data:image/png;base64,C", "data:image/png;base64,C" ],
|
||||
"tags": [ "Music", "Festival" ],
|
||||
"status": "upcoming",
|
||||
"capacity": 500,
|
||||
"price": 150.00,
|
||||
@@ -30,6 +25,7 @@ Content-Type: application/json
|
||||
"requirements": "Age 18+",
|
||||
"schedule": "18:00 Doors open\n19:00 First performance\n21:00 Main act",
|
||||
"speakers": ["DJ Lee", "Band XYZ"],
|
||||
"sponsors": ["HK Radio", "Music Magazine"]
|
||||
"sponsors": ["HK Radio", "Music Magazine"],
|
||||
"reviews":[]
|
||||
}
|
||||
}
|
||||
|
35
03_source/cms_backend/src/app/api/party-order/_GUIDELINES.md
Normal file
35
03_source/cms_backend/src/app/api/party-order/_GUIDELINES.md
Normal file
@@ -0,0 +1,35 @@
|
||||
<!-- AI: please maintain same format and level of detail when edit this file -->
|
||||
|
||||
# GUIDELINE
|
||||
|
||||
- Party Order API endpoint for managing party orders
|
||||
- Handles CRUD operations for party orders
|
||||
- Follows single file for single db table/collection pattern
|
||||
|
||||
## `route.ts`
|
||||
|
||||
Handles HTTP methods:
|
||||
|
||||
- `GET` - Retrieve party orders
|
||||
- `POST` - Create new party order
|
||||
- `PUT` - Update existing party order
|
||||
- `DELETE` - Remove party order
|
||||
|
||||
## `test.http`
|
||||
|
||||
Contains test requests for:
|
||||
|
||||
- Listing all party orders
|
||||
- Creating new party order
|
||||
- Updating existing party order
|
||||
- Deleting party order
|
||||
|
||||
## `../../services/party-order.service.ts`
|
||||
|
||||
Party Order CRUD operations:
|
||||
|
||||
`listPartyOrders` - List all party orders with optional filters
|
||||
`getPartyOrder` - Get single party order by ID
|
||||
`createNewPartyOrder` - Create new party order record
|
||||
`updatePartyOrder` - Update existing party order by ID
|
||||
`deletePartyOrder` - Delete party order by ID
|
@@ -0,0 +1,40 @@
|
||||
// src/app/api/party-order/create/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Create new party order in 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 { createOrder } from 'src/app/services/party-order.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* POST - Create PartyOrder
|
||||
*************************************** */
|
||||
export async function POST(req: NextRequest) {
|
||||
const { partyOrderData } = await req.json();
|
||||
|
||||
try {
|
||||
if (isDev) {
|
||||
console.log({ partyOrderData });
|
||||
}
|
||||
|
||||
const created = await createOrder(partyOrderData);
|
||||
|
||||
if (isDev) {
|
||||
console.log('Order created successfully');
|
||||
}
|
||||
|
||||
return response(created, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.error('Error creating order:', { partyOrderData });
|
||||
return handleError('PartyOrder - Create', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
###
|
||||
|
||||
POST http://localhost:7272/api/party-order/create
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyOrderData": {
|
||||
"taxes": 15.00,
|
||||
"status": "pending",
|
||||
"shipping": 10.00,
|
||||
"discount": 20.00,
|
||||
"subtotal": 290.00,
|
||||
"orderNumber": "ORD_20231115001",
|
||||
"totalAmount": 300.00,
|
||||
"totalQuantity": 2.0,
|
||||
"history": "{\"actions\":[{\"timestamp\":\"2023-11-15T10:00:00Z\",\"action\":\"order_created\"}]}",
|
||||
"payment": "{\"method\":\"credit_card\",\"status\":\"unpaid\",\"transaction_id\":\"txn_123456\"}",
|
||||
"customer": "{\"name\":\"John Doe\",\"email\":\"john.doe@example.com\",\"phone\":\"+1234567890\"}",
|
||||
"delivery": "{\"method\":\"courier\",\"estimated_delivery\":\"2023-11-18\"}",
|
||||
"items": [
|
||||
{
|
||||
"id": "ticket_001",
|
||||
"name": "General Admission",
|
||||
"quantity": 2,
|
||||
"price": 150.00
|
||||
}
|
||||
],
|
||||
"shippingAddress": "{\"street\":\"123 Main St\",\"city\":\"New York\",\"state\":\"NY\",\"zip\":\"10001\",\"country\":\"USA\"}"
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { deleteOrder } from 'src/app/services/party-order.service';
|
||||
|
||||
/** **************************************
|
||||
* PATCH - Delete PartyOrder
|
||||
*************************************** */
|
||||
export async function PATCH(req: NextRequest) {
|
||||
try {
|
||||
const { partyOrderId } = await req.json();
|
||||
|
||||
if (!partyOrderId) throw new Error('orderId cannot be null');
|
||||
|
||||
await deleteOrder(partyOrderId);
|
||||
|
||||
return response({ partyOrderId }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyOrder - Delete', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
###
|
||||
|
||||
PATCH http://localhost:7272/api/party-order/delete
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyOrderId": "e99f09a7-dd88-49d5-b1c8-1daf80c2d7b02"
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
// src/app/api/party-order/details/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Get party order from db by id
|
||||
//
|
||||
// RULES:
|
||||
// Do not modify the format and level of details thanks.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { getOrder } from 'src/app/services/party-order.service';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* GET PartyOrder detail
|
||||
***************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest) {
|
||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: partyOrderId must exist
|
||||
const partyOrderId = searchParams.get('partyOrderId');
|
||||
if (!partyOrderId) {
|
||||
return response({ message: 'Order ID is required!' }, STATUS.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// NOTE: partyOrderId confirmed exist, run below
|
||||
const partyOrder = await getOrder(partyOrderId);
|
||||
|
||||
if (!partyOrder) {
|
||||
return response({ message: 'Order not found!' }, STATUS.NOT_FOUND);
|
||||
}
|
||||
|
||||
logger('[PartyOrder] details', partyOrder.id);
|
||||
|
||||
createAppLog(L_INFO, 'Get order detail OK', debug);
|
||||
|
||||
return response({ partyOrder }, STATUS.OK);
|
||||
} catch (error) {
|
||||
createAppLog(L_ERROR, 'order detail error', debug);
|
||||
|
||||
return handleError('PartyOrder - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
###
|
||||
|
||||
# Get details for a specific party order
|
||||
GET http://localhost:7272/api/party-order/details?partyOrderId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b13
|
||||
|
||||
###
|
||||
|
||||
# Alternative format with different ID
|
||||
GET http://localhost:7272/api/party-order/details?id=ord_987654321
|
@@ -0,0 +1,16 @@
|
||||
import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* GET - helloworld
|
||||
***************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
return response({ helloworld: 'party-order' }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Helloworld - Get all', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
###
|
||||
GET http://localhost:7272/api/party-order/helloworld
|
38
03_source/cms_backend/src/app/api/party-order/list/route.ts
Normal file
38
03_source/cms_backend/src/app/api/party-order/list/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// src/app/api/party-order/list/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// List all party orders from db
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { createAppLog } from 'src/app/services/app-log.service';
|
||||
import { listPartyOrders } from 'src/app/services/party-order.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET - PartyOrders list
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||
|
||||
try {
|
||||
const partyOrders = await listPartyOrders();
|
||||
|
||||
createAppLog(L_INFO, 'party-order list ok', {});
|
||||
|
||||
return response({ partyOrders }, STATUS.OK);
|
||||
} catch (error) {
|
||||
createAppLog(L_ERROR, 'party-order list error', debug);
|
||||
|
||||
return handleError('PartyOrder - Get list', error);
|
||||
}
|
||||
}
|
19
03_source/cms_backend/src/app/api/party-order/list/test.http
Normal file
19
03_source/cms_backend/src/app/api/party-order/list/test.http
Normal file
@@ -0,0 +1,19 @@
|
||||
###
|
||||
|
||||
# Basic list all orders
|
||||
GET http://localhost:7272/api/party-order/list
|
||||
|
||||
###
|
||||
|
||||
# List orders by status
|
||||
GET http://localhost:7272/api/party-order/list?status=completed
|
||||
|
||||
###
|
||||
|
||||
# List orders by user
|
||||
GET http://localhost:7272/api/party-order/list?userId=usr_987654321
|
||||
|
||||
###
|
||||
|
||||
# List orders by payment status
|
||||
GET http://localhost:7272/api/party-order/list?paymentStatus=paid
|
75
03_source/cms_backend/src/app/api/party-order/route.ts
Normal file
75
03_source/cms_backend/src/app/api/party-order/route.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listPartyOrders, deleteOrder, updateOrder, createOrder } from 'src/app/services/party-order.service';
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* GET - PartyOrder
|
||||
***************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
const orders = await listPartyOrders();
|
||||
return response(orders, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyOrder - Get list', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* POST - Create PartyOrder
|
||||
***************************************
|
||||
*/
|
||||
export async function POST(req: NextRequest) {
|
||||
const OPERATION = 'PartyOrder - Create';
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
const order = await createOrder(data);
|
||||
return response(OPERATION, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError(OPERATION, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* PUT - Update PartyOrder
|
||||
***************************************
|
||||
*/
|
||||
export async function PUT(req: NextRequest) {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const orderId = searchParams.get('orderId');
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
if (!orderId) throw new Error('orderId cannot be null');
|
||||
|
||||
const result = await updateOrder(orderId, data);
|
||||
return response(result, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyOrder - Update', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* DELETE - Delete PartyOrder
|
||||
***************************************
|
||||
*/
|
||||
export async function DELETE(req: NextRequest) {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const orderId = searchParams.get('orderId');
|
||||
|
||||
try {
|
||||
if (!orderId) throw new Error('orderId cannot be null');
|
||||
|
||||
await deleteOrder(orderId);
|
||||
return response({ success: true }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyOrder - Delete', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import type { IOrderItem } from '../update/route';
|
||||
|
||||
// import { searchEvents } from 'src/app/services/party-event.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET - Search PartyEvents
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const query = searchParams.get('query')?.trim().toLowerCase();
|
||||
|
||||
if (!query) {
|
||||
return response({ results: [] }, STATUS.OK);
|
||||
}
|
||||
|
||||
const results: IOrderItem[] = [];
|
||||
// TODO: search party event not implemented
|
||||
console.log('search party event not implemented');
|
||||
// const results = await searchEvents(query);
|
||||
|
||||
logger('[PartyEvent] search-results', results?.length);
|
||||
|
||||
return response({ results }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyEvent - Get search', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
###
|
||||
|
||||
# Search party events by title
|
||||
GET http://localhost:7272/api/party-event/search?query=Music
|
||||
|
||||
###
|
||||
|
||||
# Search party events by location
|
||||
GET http://localhost:7272/api/party-event/search?query=Central+Park
|
||||
|
||||
###
|
||||
|
||||
# Search party events by tag
|
||||
GET http://localhost:7272/api/party-event/search?query=Festival
|
||||
|
||||
###
|
||||
|
||||
# Combined search with multiple parameters
|
||||
GET http://localhost:7272/api/party-event/search?query=Summer&location=Hong+Kong&category=Music
|
||||
|
||||
###
|
||||
|
||||
# No results expected
|
||||
GET http://localhost:7272/api/party-event/search?query=zzzzzz
|
@@ -0,0 +1,51 @@
|
||||
// src/app/api/party-order/update/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Update party order in db by id
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { updateOrder } from 'src/app/services/party-order.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* PUT - Update PartyOrder
|
||||
*************************************** */
|
||||
export async function PUT(req: NextRequest) {
|
||||
const { orderData } = await req.json();
|
||||
const { id } = orderData;
|
||||
|
||||
if (!id) return response({ message: 'id not found' }, STATUS.ERROR);
|
||||
|
||||
try {
|
||||
const result = await updateOrder(id, orderData);
|
||||
|
||||
return response({ result }, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.error('Error updating order:', { orderData });
|
||||
return handleError('PartyOrder - Update', error);
|
||||
}
|
||||
}
|
||||
|
||||
export type IOrderItem = {
|
||||
id: string;
|
||||
eventId: string;
|
||||
userId: string;
|
||||
status: string;
|
||||
paymentStatus: string;
|
||||
totalAmount: number;
|
||||
items: {
|
||||
id: string;
|
||||
name: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
}[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
};
|
@@ -0,0 +1,51 @@
|
||||
###
|
||||
|
||||
PUT http://localhost:7272/api/party-order/update
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"orderData": {
|
||||
"id":"e99f09a7-dd88-49d5-b1c8-1daf80c2d7b02",
|
||||
"taxes": 10.50,
|
||||
"status": "completed",
|
||||
"shipping": 5.00,
|
||||
"discount": 20.00,
|
||||
"subtotal": 290.00,
|
||||
"orderNumber": "ORD-2023-001",
|
||||
"totalAmount": 300.00,
|
||||
"totalQuantity": 2,
|
||||
"history": {
|
||||
"payment": "2023-01-01",
|
||||
"status_changes": [
|
||||
"pending",
|
||||
"paid"
|
||||
]
|
||||
},
|
||||
"payment": {
|
||||
"method": "credit_card",
|
||||
"card_last4": "4321"
|
||||
},
|
||||
"customer": {
|
||||
"name": "John Doe",
|
||||
"email": "john@example.com"
|
||||
},
|
||||
"delivery": {
|
||||
"method": "express",
|
||||
"tracking_number": "TRK123456"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"id": "ticket_001",
|
||||
"name": "General Admission",
|
||||
"quantity": 2,
|
||||
"price": 150.00,
|
||||
"status": "used"
|
||||
}
|
||||
],
|
||||
"shippingAddress": {
|
||||
"street": "123 Main St",
|
||||
"city": "New York",
|
||||
"zip": "10001"
|
||||
}
|
||||
}
|
||||
}
|
60
03_source/cms_backend/src/app/api/party-user/_GUIDELINES.md
Normal file
60
03_source/cms_backend/src/app/api/party-user/_GUIDELINES.md
Normal file
@@ -0,0 +1,60 @@
|
||||
<!-- NOTES to AI: please maintain same format and level of detail when edit this file -->
|
||||
|
||||
# GUIDELINE
|
||||
|
||||
- Party-user Management API endpoint for managing party-user accounts
|
||||
- Handles party-user CRUD operations and profile updates
|
||||
- Follows Next.js API route conventions
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `create/route.ts`
|
||||
|
||||
Creates new party-user account with required details
|
||||
|
||||
### `delete/route.ts`
|
||||
|
||||
Deletes party-user account by ID
|
||||
|
||||
### `details/route.ts`
|
||||
|
||||
Gets detailed party-user information
|
||||
|
||||
### `helloworld/route.ts`
|
||||
|
||||
Simple test endpoint returning "Hello World"
|
||||
|
||||
### `list/route.ts`
|
||||
|
||||
Lists all party-users with pagination support
|
||||
|
||||
### `search/route.ts`
|
||||
|
||||
Searches party-users by name or email
|
||||
|
||||
### `update/route.ts`
|
||||
|
||||
Updates party-user profile information
|
||||
|
||||
## Testing
|
||||
|
||||
Test files are available per endpoint in their respective directories:
|
||||
|
||||
- `create/test.http`
|
||||
- `delete/test.http`
|
||||
- `details/test.http`
|
||||
- `helloworld/test.http`
|
||||
- `list/test.http`
|
||||
- `update/test.http`
|
||||
|
||||
## Related Services
|
||||
|
||||
`../../services/party-user.service.ts` (assumed) would handle:
|
||||
|
||||
`createUser` - Register new party-user account
|
||||
`updateUser` - Update party-user profile
|
||||
`deleteUser` - Remove party-user account
|
||||
`listUsers` - Get paginated party-user list
|
||||
`searchUsers` - Search party-users by criteria
|
||||
`changeUserRole` - Modify party-user permissions
|
||||
`uploadUserImage` - Handle profile picture uploads
|
34
03_source/cms_backend/src/app/api/party-user/create/route.ts
Normal file
34
03_source/cms_backend/src/app/api/party-user/create/route.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// src/app/api/party-user/create/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// create new party user in db
|
||||
//
|
||||
// RULES:
|
||||
// 1. Validates input data shape
|
||||
// 2. Returns created party user data
|
||||
//
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { createPartyUser } from 'src/app/services/party-user.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* POST - create PartyUser
|
||||
***************************************
|
||||
*/
|
||||
export async function POST(req: NextRequest) {
|
||||
const { partyUserData } = await req.json();
|
||||
|
||||
try {
|
||||
const partyUser = await createPartyUser(partyUserData);
|
||||
|
||||
return response({ partyUser }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyUser - Create', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
###
|
||||
|
||||
POST http://localhost:7272/api/party-user/create
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyUserData": {
|
||||
"name": "Alice 123321",
|
||||
"username": null,
|
||||
"email": "alice@123111321.io",
|
||||
"emailVerified": "2025-06-15T17:47:23.919Z",
|
||||
"password": "Aa12345678",
|
||||
"bucketImage": null,
|
||||
"admin": false,
|
||||
"info": null,
|
||||
"phoneNumber": "+85291234567",
|
||||
"avatarUrl": ""
|
||||
}
|
||||
}
|
35
03_source/cms_backend/src/app/api/party-user/delete/route.ts
Normal file
35
03_source/cms_backend/src/app/api/party-user/delete/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// src/app/api/party-user/delete/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// delete party user from db by id
|
||||
//
|
||||
// RULES:
|
||||
// 1. Requires valid party user ID
|
||||
// 2. Returns deleted party user ID
|
||||
// 3. Handles errors appropriately
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { deletePartyUser } from 'src/app/services/party-user.service';
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* PATCH - Delete party user
|
||||
***************************************
|
||||
*/
|
||||
|
||||
export async function PATCH(req: NextRequest) {
|
||||
try {
|
||||
const { partyUserId } = await req.json();
|
||||
|
||||
if (!partyUserId) throw new Error('partyUserId cannot be null');
|
||||
|
||||
await deletePartyUser(partyUserId);
|
||||
|
||||
return response({ partyUserId }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyUser - Delete', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
###
|
||||
|
||||
PATCH http://localhost:7272/api/party-user/delete
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyUserId": "cmbxz8t2b000oiigxib3o4jla"
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
// src/app/api/party-user/details/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// get party user details from db by id
|
||||
//
|
||||
// RULES:
|
||||
// 1. Requires valid partyUserId parameter
|
||||
// 2. Returns party user details if found
|
||||
// 3. Handles not found case appropriately
|
||||
// 4. Logs the operation
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { getPartyUser } from 'src/app/services/party-user.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET PartyUser detail
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: userId must exist
|
||||
const partyUserId = searchParams.get('partyUserId');
|
||||
if (!partyUserId) return response({ message: 'partyUserId is required!' }, STATUS.BAD_REQUEST);
|
||||
|
||||
// NOTE: userId confirmed exist, run below
|
||||
const partyUser = await getPartyUser(partyUserId);
|
||||
|
||||
if (!partyUser) return response({ message: 'User not found!' }, STATUS.NOT_FOUND);
|
||||
|
||||
logger('[User] details', partyUser.id);
|
||||
|
||||
return response({ partyUser }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyUser - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/party-user/details?partyUserId=cmbxziat6000b715hmhrnwlx2
|
||||
|
@@ -0,0 +1,11 @@
|
||||
import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
return response({ helloworld: 'party-user' }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('GET - helloworld', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/party-user/helloworld
|
33
03_source/cms_backend/src/app/api/party-user/list/route.ts
Normal file
33
03_source/cms_backend/src/app/api/party-user/list/route.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
// src/app/api/party-user/update/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// update existing party user in db
|
||||
//
|
||||
// RULES:
|
||||
// 1. Requires valid party user ID
|
||||
// 2. Validates input data shape
|
||||
//
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listPartyUsers } from 'src/app/services/party-user.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* GET - Products
|
||||
***************************************
|
||||
*/
|
||||
export async function GET() {
|
||||
try {
|
||||
const partyUsers = await listPartyUsers();
|
||||
|
||||
logger('[User] list', partyUsers.length);
|
||||
|
||||
return response({ partyUsers }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Product - Get list', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
###
|
||||
GET http://localhost:7272/api/party-user/list
|
35
03_source/cms_backend/src/app/api/party-user/search/route.ts
Normal file
35
03_source/cms_backend/src/app/api/party-user/search/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
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 - Search products
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const query = searchParams.get('query')?.trim().toLowerCase();
|
||||
|
||||
if (!query) {
|
||||
return response({ results: [] }, STATUS.OK);
|
||||
}
|
||||
|
||||
const products = _products();
|
||||
|
||||
// Accept search by name or sku
|
||||
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);
|
||||
} catch (error) {
|
||||
return handleError('Product - Get search', error);
|
||||
}
|
||||
}
|
88
03_source/cms_backend/src/app/api/party-user/update/route.ts
Normal file
88
03_source/cms_backend/src/app/api/party-user/update/route.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
// src/app/api/party-user/update/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// update existing party user in db
|
||||
//
|
||||
// RULES:
|
||||
// 1. Requires valid party user ID
|
||||
// 2. Validates input data shape
|
||||
// 3. Returns updated party user data
|
||||
// 4. Handles errors appropriately
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { updatePartyUser } from 'src/app/services/party-user.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* PUT - Update PartyUser
|
||||
*************************************** */
|
||||
export async function PUT(req: NextRequest) {
|
||||
// logger('[Product] list', products.length);
|
||||
const { partyUserData } = await req.json();
|
||||
|
||||
try {
|
||||
await updatePartyUser(partyUserData.id, partyUserData);
|
||||
return response({ partyUserData }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('PartyUser - Update', error);
|
||||
}
|
||||
}
|
||||
|
||||
export type IProductItem = {
|
||||
id: string;
|
||||
sku: string;
|
||||
name: string;
|
||||
code: string;
|
||||
price: number;
|
||||
taxes: number;
|
||||
tags: string[];
|
||||
sizes: string[];
|
||||
publish: string;
|
||||
gender: string[];
|
||||
coverUrl: string;
|
||||
images: string[];
|
||||
colors: string[];
|
||||
quantity: number;
|
||||
category: string;
|
||||
available: number;
|
||||
totalSold: number;
|
||||
description: string;
|
||||
totalRatings: number;
|
||||
totalReviews: number;
|
||||
// createdAt: IDateValue;
|
||||
inventoryType: string;
|
||||
subDescription: string;
|
||||
priceSale: number | null;
|
||||
// reviews: IProductReview[];
|
||||
newLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
saleLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
ratings: {
|
||||
name: string;
|
||||
starCount: number;
|
||||
reviewCount: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type IDateValue = string | number | null;
|
||||
|
||||
export type IProductReview = {
|
||||
id: string;
|
||||
name: string;
|
||||
rating: number;
|
||||
comment: string;
|
||||
helpful: number;
|
||||
avatarUrl: string;
|
||||
postedAt: IDateValue;
|
||||
isPurchased: boolean;
|
||||
attachments?: string[];
|
||||
};
|
@@ -0,0 +1,22 @@
|
||||
###
|
||||
|
||||
PUT http://localhost:7272/api/party-user/update
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyUserData": {
|
||||
"id": "cmc0cedkx000boln3viy77598",
|
||||
"createdAt": "2025-06-15T17:47:24.547Z",
|
||||
"updatedAt": "2025-06-15T17:47:24.547Z",
|
||||
"name": "Alice 123321",
|
||||
"username": null,
|
||||
"email": "alice@prisma.io",
|
||||
"emailVerified": "2025-06-15T17:47:23.919Z",
|
||||
"password": "Aa12345678",
|
||||
"image": null,
|
||||
"bucketImage": null,
|
||||
"admin": false,
|
||||
"info": null,
|
||||
"phoneNumber": "+85291234567"
|
||||
}
|
||||
}
|
@@ -13,10 +13,7 @@ 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';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
81
03_source/cms_backend/src/app/api/user/_GUIDELINES.md
Normal file
81
03_source/cms_backend/src/app/api/user/_GUIDELINES.md
Normal file
@@ -0,0 +1,81 @@
|
||||
<!-- AI: please maintain same format and level of detail when edit this file -->
|
||||
|
||||
# GUIDELINE
|
||||
|
||||
- User Management API endpoint for managing user accounts
|
||||
- Handles user CRUD operations, role management and profile updates
|
||||
- Follows Next.js API route conventions
|
||||
|
||||
## `route.ts`
|
||||
|
||||
Main user route handler with HTTP methods:
|
||||
|
||||
- `GET` - Get current user details
|
||||
- `POST` - Create new user account
|
||||
- `PUT` - Update user profile
|
||||
- `DELETE` - Delete user account
|
||||
|
||||
## Sub-routes
|
||||
|
||||
### `changeToAdmin/route.ts`
|
||||
|
||||
Changes user role to admin
|
||||
|
||||
### `changeToUser/route.ts`
|
||||
|
||||
Changes user role to regular user
|
||||
|
||||
### `checkAdmin/route.ts`
|
||||
|
||||
Verifies if user has admin privileges
|
||||
|
||||
### `createUser/route.ts`
|
||||
|
||||
Creates new user account with required details
|
||||
|
||||
### `deleteUser/route.ts`
|
||||
|
||||
Deletes user account by ID
|
||||
|
||||
### `details/route.ts`
|
||||
|
||||
Gets detailed user information
|
||||
|
||||
### `list/route.ts`
|
||||
|
||||
Lists all users with pagination support
|
||||
|
||||
### `saveUser/route.ts`
|
||||
|
||||
Saves user profile changes
|
||||
|
||||
### `search/route.ts`
|
||||
|
||||
Searches users by name or email
|
||||
|
||||
### `image/upload/route.ts`
|
||||
|
||||
Handles user profile picture uploads
|
||||
|
||||
## `test.http`
|
||||
|
||||
Contains test requests for:
|
||||
|
||||
- User authentication
|
||||
- Role changes (admin/user)
|
||||
- Profile updates
|
||||
- Account creation/deletion
|
||||
- User listing/searching
|
||||
- Image uploads
|
||||
|
||||
## Related Services
|
||||
|
||||
`../../services/user.service.ts` (assumed) would handle:
|
||||
|
||||
`createUser` - Register new user account
|
||||
`updateUser` - Update user profile
|
||||
`deleteUser` - Remove user account
|
||||
`listUsers` - Get paginated user list
|
||||
`searchUsers` - Search users by criteria
|
||||
`changeUserRole` - Modify user permissions
|
||||
`uploadUserImage` - Handle profile picture uploads
|
@@ -1,7 +1,13 @@
|
||||
with knowledge in schema.prisma file,
|
||||
please refer the below helloworld example `helloworld.service.ts`
|
||||
and create `user.service.ts` to cover user record
|
||||
Hi,
|
||||
|
||||
thanks
|
||||
i copied from
|
||||
`03_source/cms_backend/src/app/services/user.service.ts`
|
||||
to
|
||||
`03_source/cms_backend/src/app/services/party-user.service.ts`
|
||||
|
||||
`/home/logic/_wsl_workspace/001_github_ws/HKSingleParty-ws/HKSingleParty/03_source/cms_backend/src/app/services/helloworld.service.ts`
|
||||
with knowledge in `schema.prisma` file, and reference to the sibling files in same folder
|
||||
|
||||
i want you to update `party-user.service.ts` content to handle `party user` (the user joining party)
|
||||
please use the model `PartyUser` to handle it.
|
||||
|
||||
thanks.
|
||||
|
@@ -76,10 +76,57 @@ async function createEvent(eventData: any) {
|
||||
return await prisma.eventItem.create({ data: eventData });
|
||||
}
|
||||
|
||||
async function updateEvent(eventId: string, updateForm: UpdateEvent) {
|
||||
async function updateEvent(eventId: string, updateForm: any) {
|
||||
return prisma.eventItem.update({
|
||||
where: { id: eventId },
|
||||
data: updateForm,
|
||||
data: {
|
||||
available: updateForm.available,
|
||||
category: updateForm.category,
|
||||
code: updateForm.code,
|
||||
colors: updateForm.colors,
|
||||
coverUrl: updateForm.coverUrl,
|
||||
description: updateForm.description,
|
||||
gender: updateForm.gender,
|
||||
images: updateForm.images,
|
||||
inventoryType: updateForm.inventoryType,
|
||||
name: updateForm.name,
|
||||
newLabel: updateForm.newLabel,
|
||||
price: updateForm.price,
|
||||
priceSale: updateForm.priceSale,
|
||||
publish: updateForm.publish,
|
||||
quantity: updateForm.quantity,
|
||||
ratings: updateForm.ratings,
|
||||
saleLabel: updateForm.saleLabel,
|
||||
sizes: updateForm.sizes,
|
||||
sku: updateForm.sku,
|
||||
subDescription: updateForm.subDescription,
|
||||
tags: updateForm.tags,
|
||||
taxes: updateForm.taxes,
|
||||
totalRatings: updateForm.totalRatings,
|
||||
totalReviews: updateForm.totalReviews,
|
||||
totalSold: updateForm.totalSold,
|
||||
//
|
||||
ageBottom: updateForm.ageBottom,
|
||||
ageTop: updateForm.ageTop,
|
||||
avatar: updateForm.avatar,
|
||||
currency: updateForm.currency,
|
||||
capacity: updateForm.capacity,
|
||||
duration_m: updateForm.duration_m,
|
||||
endDate: updateForm.endDate,
|
||||
eventDate: updateForm.eventDate,
|
||||
isFeatured: updateForm.isFeatured,
|
||||
joinMembers: updateForm.joinMembers,
|
||||
location: updateForm.location,
|
||||
organizer: updateForm.organizer,
|
||||
registrationDeadline: updateForm.registrationDeadline,
|
||||
requirements: updateForm.requirements,
|
||||
schedule: updateForm.schedule,
|
||||
speakers: updateForm.speakers,
|
||||
sponsors: updateForm.sponsors,
|
||||
startDate: updateForm.startDate,
|
||||
status: updateForm.status,
|
||||
title: updateForm.title,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,66 @@
|
||||
// src/app/services/party-order.service.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// - Service for handling PartyOrderItem Record
|
||||
//
|
||||
|
||||
import type { PartyOrderItem } from '@prisma/client';
|
||||
|
||||
import prisma from '../lib/prisma';
|
||||
|
||||
type CreateOrder = {
|
||||
status: string;
|
||||
taxes: number;
|
||||
shipping: number;
|
||||
discount: number;
|
||||
items: any[];
|
||||
customer: any;
|
||||
payment: any;
|
||||
delivery: any;
|
||||
shippingAddress: any;
|
||||
billingAddress: any;
|
||||
};
|
||||
|
||||
type UpdateOrder = {
|
||||
status?: string;
|
||||
taxes?: number;
|
||||
shipping?: number;
|
||||
discount?: number;
|
||||
items?: any[];
|
||||
customer?: any;
|
||||
payment?: any;
|
||||
delivery?: any;
|
||||
shippingAddress?: any;
|
||||
billingAddress?: any;
|
||||
};
|
||||
|
||||
async function listPartyOrders(): Promise<PartyOrderItem[]> {
|
||||
return prisma.partyOrderItem.findMany();
|
||||
}
|
||||
|
||||
async function getPartyOrder(partyOrderId: string): Promise<PartyOrderItem | null> {
|
||||
return prisma.partyOrderItem.findUnique({
|
||||
where: { id: partyOrderId },
|
||||
});
|
||||
}
|
||||
|
||||
async function createOrder(orderData: any) {
|
||||
return prisma.partyOrderItem.create({
|
||||
data: orderData,
|
||||
});
|
||||
}
|
||||
|
||||
async function updateOrder(orderId: string, updateData: UpdateOrder) {
|
||||
return prisma.partyOrderItem.update({
|
||||
where: { id: orderId },
|
||||
data: updateData,
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteOrder(orderId: string) {
|
||||
return prisma.partyOrderItem.delete({
|
||||
where: { id: orderId },
|
||||
});
|
||||
}
|
||||
|
||||
export { getPartyOrder as getOrder, createOrder, updateOrder, deleteOrder, listPartyOrders, type CreateOrder, type UpdateOrder };
|
76
03_source/cms_backend/src/app/services/party-user.service.ts
Normal file
76
03_source/cms_backend/src/app/services/party-user.service.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
// src/app/services/user.service.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// - Handle User Record CRUD operations
|
||||
//
|
||||
// RULES:
|
||||
// - Follow Prisma best practices for database operations
|
||||
// - Validate input data before processing
|
||||
//
|
||||
|
||||
import type { User, PartyUser } from '@prisma/client';
|
||||
|
||||
import prisma from '../lib/prisma';
|
||||
|
||||
type CreateUser = {
|
||||
email: string;
|
||||
// name?: string;
|
||||
// password: string;
|
||||
// role?: Role;
|
||||
// isEmailVerified?: boolean;
|
||||
// admin?: boolean;
|
||||
};
|
||||
|
||||
type UpdateUser = {
|
||||
email?: string;
|
||||
// name?: string;
|
||||
// password?: string;
|
||||
// role?: Role;
|
||||
// isEmailVerified?: boolean;
|
||||
isAdmin?: boolean;
|
||||
};
|
||||
|
||||
async function listPartyUsers(): Promise<PartyUser[]> {
|
||||
return prisma.partyUser.findMany({});
|
||||
}
|
||||
|
||||
async function getPartyUser(partyUserId: string): Promise<PartyUser | null> {
|
||||
return prisma.partyUser.findUnique({
|
||||
where: { id: partyUserId },
|
||||
// include: { reviews: true },
|
||||
});
|
||||
}
|
||||
|
||||
async function getUserById(id: string): Promise<User | null> {
|
||||
return prisma.user.findFirst({ where: { id } });
|
||||
}
|
||||
|
||||
async function createPartyUser(partyUserData: any): Promise<PartyUser> {
|
||||
return prisma.partyUser.create({ data: partyUserData });
|
||||
}
|
||||
|
||||
async function updatePartyUser(partyUserId: string, partyUserData: any): Promise<PartyUser | null> {
|
||||
return prisma.partyUser.update({
|
||||
where: { id: partyUserId },
|
||||
data: partyUserData,
|
||||
});
|
||||
}
|
||||
|
||||
async function deletePartyUser(partyUserId: string): Promise<PartyUser | null> {
|
||||
return prisma.partyUser.delete({
|
||||
where: { id: partyUserId },
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
getUserById,
|
||||
getPartyUser,
|
||||
listPartyUsers,
|
||||
createPartyUser,
|
||||
updatePartyUser,
|
||||
deletePartyUser,
|
||||
//
|
||||
type CreateUser,
|
||||
type UpdateUser,
|
||||
//
|
||||
};
|
@@ -6,6 +6,7 @@ set -ex
|
||||
DOCKER_COMPOSE_FILES=" -f docker-compose.yml -f docker-compose.dev.yml"
|
||||
|
||||
# docker compose $DOCKER_COMPOSE_FILES build
|
||||
# docker compose $DOCKER_COMPOSE_FILES push
|
||||
docker compose $DOCKER_COMPOSE_FILES up -d
|
||||
|
||||
# cd ../api_server
|
||||
|
40
03_source/frontend/.env.example
Normal file
40
03_source/frontend/.env.example
Normal file
@@ -0,0 +1,40 @@
|
||||
# Server url
|
||||
# Local server configuration at: https://docs.minimals.cc/mock-server/
|
||||
VITE_SERVER_URL=http://localhost:7272
|
||||
# VITE_SERVER_URL=https://api-dev-minimal-v630.pages.dev
|
||||
|
||||
# Public resource directory
|
||||
VITE_ASSETS_DIR=
|
||||
|
||||
# Mapbox
|
||||
VITE_MAPBOX_API_KEY=
|
||||
|
||||
# Firebase
|
||||
VITE_FIREBASE_API_KEY=
|
||||
VITE_FIREBASE_AUTH_DOMAIN=
|
||||
VITE_FIREBASE_PROJECT_ID=
|
||||
VITE_FIREBASE_STORAGE_BUCKET=
|
||||
VITE_FIREBASE_MESSAGING_SENDER_ID=
|
||||
VITE_FIREBASE_APPID=
|
||||
|
||||
# Aws
|
||||
VITE_AWS_AMPLIFY_USER_POOL_ID=
|
||||
VITE_AWS_AMPLIFY_USER_POOL_WEB_CLIENT_ID=
|
||||
VITE_AWS_AMPLIFY_REGION=
|
||||
|
||||
# Auth0
|
||||
VITE_AUTH0_DOMAIN=
|
||||
VITE_AUTH0_CLIENT_ID=
|
||||
VITE_AUTH0_CALLBACK_URL=
|
||||
|
||||
# Supabase
|
||||
VITE_SUPABASE_URL=https://prhsilyjzxbkufchywxt.supabase.co
|
||||
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InByaHNpbHlqenhia3VmY2h5d3h0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzY2NjM5MTEsImV4cCI6MjA1MjIzOTkxMX0.UBvxEhKEMtsRuDWBSDTglfnupKf9fyPI9IvQBxS5F6U
|
||||
|
||||
# Google Calendar
|
||||
GOOGLE_CLIENT_ID=463956183839-i7j5nt5rkpbm4npukg21vfnhav5vvgeh.apps.googleusercontent.com
|
||||
GOOGLE_CLIENT_SECRET=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
|
||||
GOOGLE_CALENDAR_API_KEY=AIzaSyDh4-SOuKTopXe45oDM9nQA7R4cNJ1So0c
|
||||
|
||||
VITE_GOOGLE_CLIENT_ID=463956183839-i7j5nt5rkpbm4npukg21vfnhav5vvgeh.apps.googleusercontent.com
|
||||
VITE_GOOGLE_CALENDAR_API_KEY=AIzaSyDh4-SOuKTopXe45oDM9nQA7R4cNJ1So0c
|
@@ -3,6 +3,8 @@ FROM node:20-slim
|
||||
|
||||
# Install pnpm globally
|
||||
RUN npm install -g pnpm
|
||||
RUN apt-get update
|
||||
RUN apt-get install -qqy psmisc
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
@@ -23,7 +23,7 @@
|
||||
"re:build-npm": "npm run clean && npm install && npm run build",
|
||||
"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:w": "npx nodemon --delay 1 --ext ts,tsx --exec \"yarn tsc\"",
|
||||
"tsc:watch": "tsc --noEmit --watch",
|
||||
"tsc": "tsc --noEmit"
|
||||
},
|
||||
|
@@ -10,6 +10,9 @@ while true; do
|
||||
|
||||
yarn dev --force --clearScreen
|
||||
|
||||
killall node
|
||||
killall yarn
|
||||
|
||||
echo "restarting..."
|
||||
sleep 1
|
||||
done
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
set -x
|
||||
|
||||
killall node
|
||||
killall yarn
|
||||
rm -rf ./**/*Zone.Identifier
|
||||
|
||||
set -ex
|
||||
|
70
03_source/frontend/src/_mock/_party-event.ts
Normal file
70
03_source/frontend/src/_mock/_party-event.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
export const PARTY_EVENT_GENDER_OPTIONS = [
|
||||
{ label: 'Men', value: 'Men' },
|
||||
{ label: 'Women', value: 'Women' },
|
||||
{ label: 'Kids', value: 'Kids' },
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_CATEGORY_OPTIONS = ['Shose', 'Apparel', 'Accessories'];
|
||||
|
||||
export const PARTY_EVENT_RATING_OPTIONS = ['up4Star', 'up3Star', 'up2Star', 'up1Star'];
|
||||
|
||||
export const PARTY_EVENT_COLOR_OPTIONS = [
|
||||
'#FF4842',
|
||||
'#1890FF',
|
||||
'#FFC0CB',
|
||||
'#00AB55',
|
||||
'#FFC107',
|
||||
'#7F00FF',
|
||||
'#000000',
|
||||
'#FFFFFF',
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_COLOR_NAME_OPTIONS = [
|
||||
{ value: '#FF4842', label: 'Red' },
|
||||
{ value: '#1890FF', label: 'Blue' },
|
||||
{ value: '#FFC0CB', label: 'Pink' },
|
||||
{ value: '#00AB55', label: 'Green' },
|
||||
{ value: '#FFC107', label: 'Yellow' },
|
||||
{ value: '#7F00FF', label: 'Violet' },
|
||||
{ value: '#000000', label: 'Black' },
|
||||
{ value: '#FFFFFF', label: 'White' },
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_SIZE_OPTIONS = [
|
||||
{ value: '7', label: '7' },
|
||||
{ value: '8', label: '8' },
|
||||
{ value: '8.5', label: '8.5' },
|
||||
{ value: '9', label: '9' },
|
||||
{ value: '9.5', label: '9.5' },
|
||||
{ value: '10', label: '10' },
|
||||
{ value: '10.5', label: '10.5' },
|
||||
{ value: '11', label: '11' },
|
||||
{ value: '11.5', label: '11.5' },
|
||||
{ value: '12', label: '12' },
|
||||
{ value: '13', label: '13' },
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_STOCK_OPTIONS = [
|
||||
{ value: 'in stock', label: 'In stock' },
|
||||
{ value: 'low stock', label: 'Low stock' },
|
||||
{ value: 'out of stock', label: 'Out of stock' },
|
||||
];
|
||||
|
||||
// not used due to i18n
|
||||
export const PARTY_EVENT_PUBLISH_OPTIONS = [
|
||||
{ value: 'published', label: 'Published' },
|
||||
{ value: 'draft', label: 'Draft' },
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_SORT_OPTIONS = [
|
||||
{ value: 'featured', label: 'Featured' },
|
||||
{ value: 'newest', label: 'Newest' },
|
||||
{ value: 'priceDesc', label: 'Price: High - Low' },
|
||||
{ value: 'priceAsc', label: 'Price: Low - High' },
|
||||
];
|
||||
|
||||
export const PARTY_EVENT_CATEGORY_GROUP_OPTIONS = [
|
||||
{ group: 'Clothing', classify: ['Shirts', 'T-shirts', 'Jeans', 'Leather', 'Accessories'] },
|
||||
{ group: 'Tailored', classify: ['Suits', 'Blazers', 'Trousers', 'Waistcoats', 'Apparel'] },
|
||||
{ group: 'Accessories', classify: ['Shoes', 'Backpacks and bags', 'Bracelets', 'Face masks'] },
|
||||
];
|
89
03_source/frontend/src/_mock/_party-order.ts
Normal file
89
03_source/frontend/src/_mock/_party-order.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { _mock } from './_mock';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const PARTY_ORDER_STATUS_OPTIONS = [
|
||||
{ value: 'pending', label: 'Pending' },
|
||||
{ value: 'completed', label: 'Completed' },
|
||||
{ value: 'cancelled', label: 'Cancelled' },
|
||||
{ value: 'refunded', label: 'Refunded' },
|
||||
];
|
||||
|
||||
const ITEMS = Array.from({ length: 3 }, (_, index) => ({
|
||||
id: _mock.id(index),
|
||||
sku: `16H9UR${index}`,
|
||||
quantity: index + 1,
|
||||
name: _mock.productName(index),
|
||||
coverUrl: _mock.image.product(index),
|
||||
price: _mock.number.price(index),
|
||||
}));
|
||||
|
||||
export const _party_orders = Array.from({ length: 20 }, (_, index) => {
|
||||
const shipping = 10;
|
||||
|
||||
const discount = 10;
|
||||
|
||||
const taxes = 10;
|
||||
|
||||
const items = (index % 2 && ITEMS.slice(0, 1)) || (index % 3 && ITEMS.slice(1, 3)) || ITEMS;
|
||||
|
||||
const totalQuantity = items.reduce((accumulator, item) => accumulator + item.quantity, 0);
|
||||
|
||||
const subtotal = items.reduce((accumulator, item) => accumulator + item.price * item.quantity, 0);
|
||||
|
||||
const totalAmount = subtotal - shipping - discount + taxes;
|
||||
|
||||
const customer = {
|
||||
id: _mock.id(index),
|
||||
name: _mock.fullName(index),
|
||||
email: _mock.email(index),
|
||||
avatarUrl: _mock.image.avatar(index),
|
||||
ipAddress: '192.158.1.38',
|
||||
};
|
||||
|
||||
const delivery = { shipBy: 'DHL', speedy: 'Standard', trackingNumber: 'SPX037739199373' };
|
||||
|
||||
const history = {
|
||||
orderTime: _mock.time(1),
|
||||
paymentTime: _mock.time(2),
|
||||
deliveryTime: _mock.time(3),
|
||||
completionTime: _mock.time(4),
|
||||
timeline: [
|
||||
{ title: 'Delivery successful', time: _mock.time(1) },
|
||||
{ title: 'Transporting to [2]', time: _mock.time(2) },
|
||||
{ title: 'Transporting to [1]', time: _mock.time(3) },
|
||||
{ title: 'The shipping unit has picked up the goods', time: _mock.time(4) },
|
||||
{ title: 'Order has been created', time: _mock.time(5) },
|
||||
],
|
||||
};
|
||||
|
||||
return {
|
||||
id: _mock.id(index),
|
||||
orderNumber: `#601${index}`,
|
||||
createdAt: _mock.time(index),
|
||||
taxes,
|
||||
items,
|
||||
history,
|
||||
subtotal,
|
||||
shipping,
|
||||
discount,
|
||||
customer,
|
||||
delivery,
|
||||
totalAmount,
|
||||
totalQuantity,
|
||||
shippingAddress: {
|
||||
fullAddress: '19034 Verna Unions Apt. 164 - Honolulu, RI / 87535',
|
||||
phoneNumber: '365-374-4961',
|
||||
},
|
||||
payment: {
|
||||
//
|
||||
cardType: 'mastercard',
|
||||
cardNumber: '**** **** **** 5678',
|
||||
},
|
||||
status:
|
||||
(index % 2 && 'completed') ||
|
||||
(index % 3 && 'pending') ||
|
||||
(index % 4 && 'cancelled') ||
|
||||
'refunded',
|
||||
};
|
||||
});
|
@@ -23,3 +23,7 @@ export * from './_product';
|
||||
export * from './_overview';
|
||||
|
||||
export * from './_calendar';
|
||||
|
||||
export * from './_party-event';
|
||||
|
||||
export * from './_party-order';
|
||||
|
177
03_source/frontend/src/actions/party-event.ts
Normal file
177
03_source/frontend/src/actions/party-event.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
// src/actions/party-event.ts
|
||||
//
|
||||
import { useMemo } from 'react';
|
||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||
import type { IPartyEventItem } from 'src/types/party-event';
|
||||
import type { SWRConfiguration } from 'swr';
|
||||
import useSWR, { mutate } from 'swr';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const swrOptions: SWRConfiguration = {
|
||||
revalidateIfStale: false,
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyEventsData = {
|
||||
partyEvents: IPartyEventItem[];
|
||||
};
|
||||
|
||||
export function useGetPartyEvents() {
|
||||
const url = endpoints.partyEvent.list;
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyEventsData>(
|
||||
url,
|
||||
fetcher,
|
||||
swrOptions
|
||||
);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyEvents: data?.partyEvents || [],
|
||||
partyEventsLoading: isLoading,
|
||||
partyEventsError: error,
|
||||
partyEventsValidating: isValidating,
|
||||
partyEventsEmpty: !isLoading && !isValidating && !data?.partyEvents.length,
|
||||
}),
|
||||
[data?.partyEvents, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyEventData = {
|
||||
partyEvent: IPartyEventItem;
|
||||
};
|
||||
|
||||
export function useGetPartyEvent(partyEventId: string) {
|
||||
const url = partyEventId ? [endpoints.partyEvent.details, { params: { partyEventId } }] : '';
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyEventData>(url, fetcher, swrOptions);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyEvent: data?.partyEvent,
|
||||
partyEventLoading: isLoading,
|
||||
partyEventError: error,
|
||||
partyEventValidating: isValidating,
|
||||
mutate,
|
||||
}),
|
||||
[data?.partyEvent, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type SearchResultsData = {
|
||||
results: IPartyEventItem[];
|
||||
};
|
||||
|
||||
// TODO: update useSearchPartyEvents
|
||||
export function useSearchProducts(query: string) {
|
||||
const url = query ? [endpoints.product.search, { params: { query } }] : '';
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<SearchResultsData>(url, fetcher, {
|
||||
...swrOptions,
|
||||
keepPreviousData: true,
|
||||
});
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
searchResults: data?.results || [],
|
||||
searchLoading: isLoading,
|
||||
searchError: error,
|
||||
searchValidating: isValidating,
|
||||
searchEmpty: !isLoading && !isValidating && !data?.results.length,
|
||||
}),
|
||||
[data?.results, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function createPartyEvent(partyEventData: IPartyEventItem) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyEventData };
|
||||
const {
|
||||
data: { id },
|
||||
} = await axiosInstance.post(endpoints.partyEvent.create, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyEvent.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyEvents: IPartyEventItem[] = currentData?.partyEvents;
|
||||
|
||||
const partyEvents = [...currentPartyEvents, { ...partyEventData, id }];
|
||||
|
||||
return { ...currentData, partyEvents };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function updatePartyEvent(partyEventData: Partial<IPartyEventItem>) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyEventData };
|
||||
await axiosInstance.put(endpoints.partyEvent.update, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyEvent.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyEvents: IPartyEventItem[] = currentData?.partyEvents;
|
||||
|
||||
const partyEvents = currentPartyEvents.map((partyEvent) =>
|
||||
partyEvent.id === partyEventData.id ? { ...partyEvent, ...partyEventData } : partyEvent
|
||||
);
|
||||
|
||||
return { ...currentData, partyEvents };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function deletePartyEvent(partyEventId: string) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyEventId };
|
||||
await axiosInstance.patch(endpoints.partyEvent.delete, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyEvent.list,
|
||||
(currentData: any) => {
|
||||
const currentProducts: IPartyEventItem[] = currentData?.partyEvents;
|
||||
|
||||
const partyEvents = currentProducts.filter((partyEvent) => partyEvent.id !== partyEventId);
|
||||
|
||||
return { ...currentData, partyEvents };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
208
03_source/frontend/src/actions/party-order.ts
Normal file
208
03_source/frontend/src/actions/party-order.ts
Normal file
@@ -0,0 +1,208 @@
|
||||
// src/actions/party-order.ts
|
||||
//
|
||||
import { useMemo } from 'react';
|
||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||
import type { IPartyOrderItem } from 'src/types/party-order';
|
||||
import type { SWRConfiguration } from 'swr';
|
||||
import useSWR, { mutate } from 'swr';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const swrOptions: SWRConfiguration = {
|
||||
revalidateIfStale: false,
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyOrdersData = {
|
||||
partyOrders: IPartyOrderItem[];
|
||||
};
|
||||
|
||||
export function useGetPartyOrders() {
|
||||
const url = endpoints.partyOrder.list;
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyOrdersData>(
|
||||
url,
|
||||
fetcher,
|
||||
swrOptions
|
||||
);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyOrders: data?.partyOrders || [],
|
||||
partyOrdersLoading: isLoading,
|
||||
partyOrdersError: error,
|
||||
partyOrdersValidating: isValidating,
|
||||
partyOrdersEmpty: !isLoading && !isValidating && !data?.partyOrders.length,
|
||||
}),
|
||||
[data?.partyOrders, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyOrderData = {
|
||||
partyOrder: IPartyOrderItem;
|
||||
};
|
||||
|
||||
export function useGetPartyOrder(partyOrderId: string) {
|
||||
const url = partyOrderId ? [endpoints.partyOrder.details, { params: { partyOrderId } }] : '';
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyOrderData>(url, fetcher, swrOptions);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyOrder: data?.partyOrder,
|
||||
partyOrderLoading: isLoading,
|
||||
partyOrderError: error,
|
||||
partyOrderValidating: isValidating,
|
||||
}),
|
||||
[data?.partyOrder, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type SearchResultsData = {
|
||||
results: IPartyOrderItem[];
|
||||
};
|
||||
|
||||
export function useSearchProducts(query: string) {
|
||||
const url = query ? [endpoints.product.search, { params: { query } }] : '';
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<SearchResultsData>(url, fetcher, {
|
||||
...swrOptions,
|
||||
keepPreviousData: true,
|
||||
});
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
searchResults: data?.results || [],
|
||||
searchLoading: isLoading,
|
||||
searchError: error,
|
||||
searchValidating: isValidating,
|
||||
searchEmpty: !isLoading && !isValidating && !data?.results.length,
|
||||
}),
|
||||
[data?.results, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function createPartyOrder(partyOrderData: IPartyOrderItem) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyOrderData };
|
||||
const {
|
||||
data: { id },
|
||||
} = await axiosInstance.post(endpoints.partyOrder.create, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyOrder.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyOrders: IPartyOrderItem[] = currentData?.partyOrders;
|
||||
|
||||
const partyOrders = [...currentPartyOrders, { ...partyOrderData, id }];
|
||||
|
||||
return { ...currentData, partyOrders };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function updatePartyOrder(partyOrderData: Partial<IPartyOrderItem>) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyOrderData };
|
||||
await axiosInstance.put(endpoints.partyOrder.update, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
|
||||
mutate(
|
||||
endpoints.partyOrder.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyOrders: IPartyOrderItem[] = currentData?.partyOrders;
|
||||
|
||||
const partyOrders = currentPartyOrders.map((partyOrder) =>
|
||||
partyOrder.id === partyOrderData.id ? { ...partyOrder, ...partyOrderData } : partyOrder
|
||||
);
|
||||
|
||||
return { ...currentData, partyOrders };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function deletePartyOrder(partyOrderId: string) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyOrderId };
|
||||
await axiosInstance.patch(endpoints.partyOrder.delete, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
|
||||
mutate(
|
||||
endpoints.partyOrder.list,
|
||||
(currentData: any) => {
|
||||
const currentProducts: IPartyOrderItem[] = currentData?.partyOrders;
|
||||
|
||||
const partyOrders = currentProducts.filter((partyOrder) => partyOrder.id !== partyOrderId);
|
||||
|
||||
return { ...currentData, partyOrders };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// TODO: implement partyOrder changeStatus with url below
|
||||
// const url = endpoints.order.changeStatus(orderId);
|
||||
export async function changeStatus(partyOrderData: any, dummy: any) {
|
||||
return true;
|
||||
// /**
|
||||
// * Work on server
|
||||
// */
|
||||
// const data = { partyOrderData };
|
||||
// await axiosInstance.put(endpoints.partyOrder.update, data);
|
||||
|
||||
// /**
|
||||
// * Work in local
|
||||
// */
|
||||
|
||||
// mutate(
|
||||
// endpoints.partyOrder.list,
|
||||
// (currentData: any) => {
|
||||
// const currentPartyOrders: IPartyOrderItem[] = currentData?.partyOrders;
|
||||
|
||||
// const partyOrders = currentPartyOrders.map((partyOrder) =>
|
||||
// partyOrder.id === partyOrderData.id ? { ...partyOrder, ...partyOrderData } : partyOrder
|
||||
// );
|
||||
|
||||
// return { ...currentData, partyOrders };
|
||||
// },
|
||||
// false
|
||||
// );
|
||||
}
|
237
03_source/frontend/src/actions/party-user.ts
Normal file
237
03_source/frontend/src/actions/party-user.ts
Normal file
@@ -0,0 +1,237 @@
|
||||
// src/actions/party-user.ts
|
||||
//
|
||||
import { useMemo } from 'react';
|
||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||
import type { IPartyUserItem } from 'src/types/party-user';
|
||||
import type { IProductItem } from 'src/types/product';
|
||||
import type { SWRConfiguration } from 'swr';
|
||||
import useSWR, { mutate } from 'swr';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const swrOptions: SWRConfiguration = {
|
||||
revalidateIfStale: false,
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyUsersData = {
|
||||
partyUsers: IPartyUserItem[];
|
||||
};
|
||||
|
||||
// TODO: i want to refactor / tidy here
|
||||
export function useGetPartyUsers() {
|
||||
const url = endpoints.partyUser.list;
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyUsersData>(url, fetcher, swrOptions);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyUsers: data?.partyUsers || [],
|
||||
partyUsersLoading: isLoading,
|
||||
partyUsersError: error,
|
||||
partyUsersValidating: isValidating,
|
||||
partyUsersEmpty: !isLoading && !isValidating && !data?.partyUsers.length,
|
||||
}),
|
||||
[data?.partyUsers, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type PartyUserData = {
|
||||
partyUser: IPartyUserItem;
|
||||
};
|
||||
|
||||
export function useGetPartyUser(partyUserId: string) {
|
||||
const { data, isLoading, error, isValidating } = useSWR<PartyUserData>(
|
||||
endpoints.partyUser.detailsByPartyUserId(partyUserId),
|
||||
fetcher,
|
||||
swrOptions
|
||||
);
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
partyUser: data?.partyUser,
|
||||
partyUserLoading: isLoading,
|
||||
partyUserError: error,
|
||||
partyUserValidating: isValidating,
|
||||
}),
|
||||
[data?.partyUser, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type SearchResultsData = {
|
||||
results: IProductItem[];
|
||||
};
|
||||
|
||||
// TODO: update useSearchProducts
|
||||
export function useSearchProducts(query: string) {
|
||||
const url = query ? [endpoints.product.search, { params: { query } }] : '';
|
||||
|
||||
const { data, isLoading, error, isValidating } = useSWR<SearchResultsData>(url, fetcher, {
|
||||
...swrOptions,
|
||||
keepPreviousData: true,
|
||||
});
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
() => ({
|
||||
searchResults: data?.results || [],
|
||||
searchLoading: isLoading,
|
||||
searchError: error,
|
||||
searchValidating: isValidating,
|
||||
searchEmpty: !isLoading && !isValidating && !data?.results.length,
|
||||
}),
|
||||
[data?.results, error, isLoading, isValidating]
|
||||
);
|
||||
|
||||
return memoizedValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type SaveUserData = {
|
||||
name: string;
|
||||
city: string;
|
||||
role: string;
|
||||
email: string;
|
||||
state: string;
|
||||
status: string;
|
||||
address: string;
|
||||
country: string;
|
||||
zipCode: string;
|
||||
company: string;
|
||||
avatarUrl: string;
|
||||
phoneNumber: string;
|
||||
isVerified: boolean;
|
||||
//
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export async function createPartyUser(partyUserData: CreateUserData) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyUserData };
|
||||
const {
|
||||
data: { id },
|
||||
} = await axiosInstance.post(endpoints.partyUser.create, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyUser.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyUsers: IPartyUserItem[] = currentData?.partyUsers;
|
||||
|
||||
const partyUsers = [...currentPartyUsers, { ...partyUserData, id }];
|
||||
|
||||
return { ...currentData, partyUsers };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export async function updatePartyUser(partyUserData: Partial<IPartyUserItem>) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyUserData };
|
||||
await axiosInstance.put(endpoints.partyUser.update, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyUser.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyUsers: IPartyUserItem[] = currentData?.partyUsers;
|
||||
|
||||
const partyUsers = currentPartyUsers.map((partyUser) =>
|
||||
partyUser.id === partyUserData.id ? { ...partyUser, ...partyUserData } : partyUser
|
||||
);
|
||||
|
||||
return { ...currentData, partyUsers };
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
const partyUserId: string = partyUserData.id || '';
|
||||
mutate(
|
||||
endpoints.partyUser.detailsByPartyUserId(partyUserId),
|
||||
(currentData: any) => {
|
||||
const currentPartyUser: IPartyUserItem = currentData?.partyUser;
|
||||
|
||||
console.log({ currentPartyUser });
|
||||
const partyUser = partyUserData;
|
||||
|
||||
return { ...currentData, partyUser };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
export async function uploadUserImage(saveUserData: SaveUserData) {
|
||||
console.log('uploadUserImage ?');
|
||||
// const url = userId ? [endpoints.user.details, { params: { userId } }] : '';
|
||||
|
||||
const res = await axiosInstance.get('http://localhost:7272/api/product/helloworld');
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type CreateUserData = {
|
||||
name: string;
|
||||
city: string;
|
||||
role: string;
|
||||
email: string;
|
||||
state: string;
|
||||
status: string;
|
||||
address: string;
|
||||
country: string;
|
||||
zipCode: string;
|
||||
company: string;
|
||||
avatarUrl: string;
|
||||
phoneNumber: string;
|
||||
isVerified: boolean;
|
||||
//
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export async function deletePartyUser(partyUserId: string) {
|
||||
/**
|
||||
* Work on server
|
||||
*/
|
||||
const data = { partyUserId };
|
||||
await axiosInstance.patch(endpoints.partyUser.delete, data);
|
||||
|
||||
/**
|
||||
* Work in local
|
||||
*/
|
||||
mutate(
|
||||
endpoints.partyUser.list,
|
||||
(currentData: any) => {
|
||||
const currentPartyUsers: IPartyUserItem[] = currentData?.partyUsers;
|
||||
|
||||
const partyUsers = currentPartyUsers.filter((partyUser) => partyUser.id !== partyUserId);
|
||||
|
||||
return { ...currentData, partyUsers };
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
@@ -91,6 +91,39 @@ export const navData: NavSectionProps['data'] = [
|
||||
{ title: 'Account', path: paths.dashboard.user.account },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'party-event',
|
||||
path: paths.dashboard.partyEvent.root,
|
||||
icon: ICONS.product,
|
||||
children: [
|
||||
{ title: 'List', path: paths.dashboard.partyEvent.root },
|
||||
{ title: 'Details', path: paths.dashboard.partyEvent.demo.details },
|
||||
{ title: 'Create', path: paths.dashboard.partyEvent.new },
|
||||
{ title: 'Edit', path: paths.dashboard.partyEvent.demo.edit },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'party-order',
|
||||
path: paths.dashboard.partyOrder.root,
|
||||
icon: ICONS.order,
|
||||
children: [
|
||||
{ title: 'List', path: paths.dashboard.partyOrder.root },
|
||||
{ title: 'Details', path: paths.dashboard.partyOrder.demo.details },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'party-user',
|
||||
path: paths.dashboard.partyUser.root,
|
||||
icon: ICONS.user,
|
||||
children: [
|
||||
{ title: 'Profile', path: paths.dashboard.partyUser.root },
|
||||
{ title: 'Cards', path: paths.dashboard.partyUser.cards },
|
||||
{ title: 'List', path: paths.dashboard.partyUser.list },
|
||||
{ title: 'Create', path: paths.dashboard.partyUser.new },
|
||||
{ title: 'Edit', path: paths.dashboard.partyUser.demo.edit },
|
||||
{ title: 'Account', path: paths.dashboard.partyUser.account },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Product',
|
||||
path: paths.dashboard.product.root,
|
||||
|
@@ -84,4 +84,37 @@ export const endpoints = {
|
||||
changeStatus: (invoiceId: string) => `/api/invoice/changeStatus?invoiceId=${invoiceId}`,
|
||||
search: '/api/invoice/search',
|
||||
},
|
||||
//
|
||||
//
|
||||
//
|
||||
partyEvent: {
|
||||
list: '/api/party-event/list',
|
||||
details: '/api/party-event/details',
|
||||
search: '/api/party-event/search',
|
||||
create: '/api/party-event/create',
|
||||
update: '/api/party-event/update',
|
||||
delete: '/api/party-event/delete',
|
||||
},
|
||||
partyOrder: {
|
||||
create: '/api/party-order/create',
|
||||
delete: '/api/party-order/delete',
|
||||
list: '/api/party-order/list',
|
||||
profile: '/api/party-order/profile',
|
||||
update: '/api/party-order/update',
|
||||
settings: '/api/party-order/settings',
|
||||
details: '/api/party-order/details',
|
||||
changeStatus: (partyOrderId: string) =>
|
||||
`/api/party-order/changeStatus?partyOrderId=${partyOrderId}`,
|
||||
},
|
||||
partyUser: {
|
||||
list: '/api/party-user/list',
|
||||
details: '/api/party-user/details',
|
||||
search: '/api/party-user/search',
|
||||
create: '/api/party-user/create',
|
||||
update: '/api/party-user/update',
|
||||
delete: '/api/party-user/delete',
|
||||
//
|
||||
detailsByPartyUserId: (partyUserId: string) =>
|
||||
`/api/party-user/details?partyUserId=${partyUserId}`,
|
||||
},
|
||||
};
|
||||
|
@@ -22,7 +22,7 @@ i18next
|
||||
.init({
|
||||
...i18nOptions(lng),
|
||||
detection: { caches: ['localStorage'] },
|
||||
debug: isDev,
|
||||
debug: false,
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@@ -0,0 +1,28 @@
|
||||
// src/pages/dashboard/party-event/details.tsx
|
||||
|
||||
import { useGetPartyEvent } from 'src/actions/party-event';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { useParams } from 'src/routes/hooks';
|
||||
import { PartyEventDetailsView } from 'src/sections/party-event/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `PartyEvent details | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { id = '' } = useParams();
|
||||
|
||||
const { partyEvent, partyEventLoading, partyEventError } = useGetPartyEvent(id);
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyEventDetailsView
|
||||
partyEvent={partyEvent}
|
||||
loading={partyEventLoading}
|
||||
error={partyEventError}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
22
03_source/frontend/src/pages/dashboard/party-event/edit.tsx
Normal file
22
03_source/frontend/src/pages/dashboard/party-event/edit.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useGetPartyEvent } from 'src/actions/party-event';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { useParams } from 'src/routes/hooks';
|
||||
import { PartyEventEditView } from 'src/sections/party-event/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `PartyEvent edit | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { id = '' } = useParams();
|
||||
|
||||
const { partyEvent } = useGetPartyEvent(id);
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyEventEditView partyEvent={partyEvent} />
|
||||
</>
|
||||
);
|
||||
}
|
18
03_source/frontend/src/pages/dashboard/party-event/list.tsx
Normal file
18
03_source/frontend/src/pages/dashboard/party-event/list.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
// src/pages/dashboard/party-event/list.tsx
|
||||
//
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { PartyEventListView } from 'src/sections/party-event/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `PartyEvent list | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyEventListView />
|
||||
</>
|
||||
);
|
||||
}
|
16
03_source/frontend/src/pages/dashboard/party-event/new.tsx
Normal file
16
03_source/frontend/src/pages/dashboard/party-event/new.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { PartyEventCreateView } from 'src/sections/party-event/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Create a new party-event | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyEventCreateView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
// src/pages/dashboard/order/details.tsx
|
||||
//
|
||||
import { useGetPartyOrder } from 'src/actions/party-order';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { useParams } from 'src/routes/hooks';
|
||||
import { PartyOrderDetailsView } from 'src/sections/party-order/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Order details | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { id = '' } = useParams();
|
||||
|
||||
// const currentOrder = _orders.find((order) => order.id === id);
|
||||
// TODO: error handling
|
||||
const { partyOrder, partyOrderLoading, partyOrderError } = useGetPartyOrder(id);
|
||||
|
||||
if (!partyOrder) return <></>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyOrderDetailsView partyOrder={partyOrder} />
|
||||
</>
|
||||
);
|
||||
}
|
18
03_source/frontend/src/pages/dashboard/party-order/list.tsx
Normal file
18
03_source/frontend/src/pages/dashboard/party-order/list.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
// src/pages/dashboard/party-order/list.tsx
|
||||
//
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { PartyOrderListView } from 'src/sections/party-order/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Order list | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyOrderListView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { AccountBillingView } from 'src/sections/account/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Account billing settings | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<AccountBillingView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { AccountChangePasswordView } from 'src/sections/account/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Account change password settings | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<AccountChangePasswordView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { AccountGeneralView } from 'src/sections/account/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Account general settings | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<AccountGeneralView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { AccountNotificationsView } from 'src/sections/account/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = {
|
||||
title: `Account notifications settings | Dashboard - ${CONFIG.appName}`,
|
||||
};
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<AccountNotificationsView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { AccountSocialsView } from 'src/sections/account/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Account socials settings | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<AccountSocialsView />
|
||||
</>
|
||||
);
|
||||
}
|
16
03_source/frontend/src/pages/dashboard/party-user/cards.tsx
Normal file
16
03_source/frontend/src/pages/dashboard/party-user/cards.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { UserCardsView } from 'src/sections/user/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `User cards | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<UserCardsView />
|
||||
</>
|
||||
);
|
||||
}
|
25
03_source/frontend/src/pages/dashboard/party-user/edit.tsx
Normal file
25
03_source/frontend/src/pages/dashboard/party-user/edit.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
// import { _userList } from 'src/_mock/_user';
|
||||
import { useGetPartyUser } from 'src/actions/party-user';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { useParams } from 'src/routes/hooks';
|
||||
import { PartyUserEditView } from 'src/sections/party-user/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `User edit | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { id = '' } = useParams();
|
||||
|
||||
// TODO: remove unused code
|
||||
// const currentUser = _userList.find((user) => user.id === id);
|
||||
const { partyUser: user } = useGetPartyUser(id);
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyUserEditView user={user} />
|
||||
</>
|
||||
);
|
||||
}
|
16
03_source/frontend/src/pages/dashboard/party-user/list.tsx
Normal file
16
03_source/frontend/src/pages/dashboard/party-user/list.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { PartyUserListView } from 'src/sections/party-user/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `User list | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyUserListView />
|
||||
</>
|
||||
);
|
||||
}
|
16
03_source/frontend/src/pages/dashboard/party-user/new.tsx
Normal file
16
03_source/frontend/src/pages/dashboard/party-user/new.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { UserCreateView } from 'src/sections/party-user/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Create a new user | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<UserCreateView />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { UserProfileView } from 'src/sections/user/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `User profile | Dashboard - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<UserProfileView />
|
||||
</>
|
||||
);
|
||||
}
|
16
03_source/frontend/src/pages/party-event/checkout.tsx
Normal file
16
03_source/frontend/src/pages/party-event/checkout.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { CheckoutView } from 'src/sections/checkout/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Checkout - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<CheckoutView />
|
||||
</>
|
||||
);
|
||||
}
|
22
03_source/frontend/src/pages/party-event/details.tsx
Normal file
22
03_source/frontend/src/pages/party-event/details.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useGetProduct } from 'src/actions/product';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { useParams } from 'src/routes/hooks';
|
||||
import { ProductShopDetailsView } from 'src/sections/product/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Product details - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { id = '' } = useParams();
|
||||
|
||||
const { product, productLoading, productError } = useGetProduct(id);
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<ProductShopDetailsView product={product} loading={productLoading} error={productError} />
|
||||
</>
|
||||
);
|
||||
}
|
5
03_source/frontend/src/pages/party-event/helloworld.tsx
Normal file
5
03_source/frontend/src/pages/party-event/helloworld.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
function Helloworld() {
|
||||
return <>helloworld</>;
|
||||
}
|
||||
|
||||
export default Helloworld;
|
19
03_source/frontend/src/pages/party-event/list.tsx
Normal file
19
03_source/frontend/src/pages/party-event/list.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useGetPartyEvents } from 'src/actions/party-event';
|
||||
import { CONFIG } from 'src/global-config';
|
||||
import { PartyEventShopView } from 'src/sections/party-event/view';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const metadata = { title: `Product shop - ${CONFIG.appName}` };
|
||||
|
||||
export default function Page() {
|
||||
const { partyEvents, partyEventsLoading } = useGetPartyEvents();
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{metadata.title}</title>
|
||||
|
||||
<PartyEventShopView products={partyEvents} loading={partyEventsLoading} />
|
||||
</>
|
||||
);
|
||||
}
|
@@ -87,6 +87,13 @@ export const paths = {
|
||||
verify: `${ROOTS.AUTH_DEMO}/centered/verify`,
|
||||
},
|
||||
},
|
||||
//
|
||||
partyEvent: {
|
||||
root: `/party-event`,
|
||||
checkout: `/party-event/checkout`,
|
||||
details: (id: string) => `/party-event/${id}`,
|
||||
demo: { details: `/party-event/${MOCK_ID}` },
|
||||
},
|
||||
// DASHBOARD
|
||||
dashboard: {
|
||||
root: ROOTS.DASHBOARD,
|
||||
@@ -171,5 +178,33 @@ export const paths = {
|
||||
edit: `${ROOTS.DASHBOARD}/tour/${MOCK_ID}/edit`,
|
||||
},
|
||||
},
|
||||
//
|
||||
//
|
||||
//
|
||||
partyEvent: {
|
||||
root: `${ROOTS.DASHBOARD}/party-event`,
|
||||
new: `${ROOTS.DASHBOARD}/party-event/new`,
|
||||
details: (id: string) => `${ROOTS.DASHBOARD}/party-event/${id}`,
|
||||
edit: (id: string) => `${ROOTS.DASHBOARD}/party-event/${id}/edit`,
|
||||
demo: {
|
||||
details: `${ROOTS.DASHBOARD}/party-event/${MOCK_ID}`,
|
||||
edit: `${ROOTS.DASHBOARD}/party-event/${MOCK_ID}/edit`,
|
||||
},
|
||||
},
|
||||
partyOrder: {
|
||||
root: `${ROOTS.DASHBOARD}/party-order`,
|
||||
details: (id: string) => `${ROOTS.DASHBOARD}/party-order/${id}`,
|
||||
demo: { details: `${ROOTS.DASHBOARD}/party-order/${MOCK_ID}` },
|
||||
},
|
||||
partyUser: {
|
||||
root: `${ROOTS.DASHBOARD}/party-user`,
|
||||
new: `${ROOTS.DASHBOARD}/party-user/new`,
|
||||
list: `${ROOTS.DASHBOARD}/party-user/list`,
|
||||
cards: `${ROOTS.DASHBOARD}/party-user/cards`,
|
||||
profile: `${ROOTS.DASHBOARD}/party-user/profile`,
|
||||
account: `${ROOTS.DASHBOARD}/party-user/account`,
|
||||
edit: (id: string) => `${ROOTS.DASHBOARD}/party-user/${id}/edit`,
|
||||
demo: { edit: `${ROOTS.DASHBOARD}/party-user/${MOCK_ID}/edit` },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// src/routes/sections/dashboard.tsx
|
||||
//
|
||||
import { lazy, Suspense } from 'react';
|
||||
import type { RouteObject } from 'react-router';
|
||||
import { Outlet } from 'react-router';
|
||||
@@ -75,6 +77,23 @@ const PermissionDeniedPage = lazy(() => import('src/pages/dashboard/permission')
|
||||
const ParamsPage = lazy(() => import('src/pages/dashboard/params'));
|
||||
const BlankPage = lazy(() => import('src/pages/dashboard/blank'));
|
||||
|
||||
// PartyEvent
|
||||
const PartyEventDetailsPage = lazy(() => import('src/pages/dashboard/party-event/details'));
|
||||
const PartyEventListPage = lazy(() => import('src/pages/dashboard/party-event/list'));
|
||||
const PartyEventCreatePage = lazy(() => import('src/pages/dashboard/party-event/new'));
|
||||
const PartyEventEditPage = lazy(() => import('src/pages/dashboard/party-event/edit'));
|
||||
|
||||
// PartyOrder
|
||||
const PartyOrderListPage = lazy(() => import('src/pages/dashboard/party-order/list'));
|
||||
const PartyOrderDetailsPage = lazy(() => import('src/pages/dashboard/party-order/details'));
|
||||
|
||||
// PartyUser
|
||||
const PartyUserProfilePage = lazy(() => import('src/pages/dashboard/party-user/profile'));
|
||||
const PartyUserCardsPage = lazy(() => import('src/pages/dashboard/party-user/cards'));
|
||||
const PartyUserListPage = lazy(() => import('src/pages/dashboard/party-user/list'));
|
||||
const PartyUserCreatePage = lazy(() => import('src/pages/dashboard/party-user/new'));
|
||||
const PartyUserEditPage = lazy(() => import('src/pages/dashboard/party-user/edit'));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
function SuspenseOutlet() {
|
||||
@@ -198,6 +217,47 @@ export const dashboardRoutes: RouteObject[] = [
|
||||
{ path: 'permission', element: <PermissionDeniedPage /> },
|
||||
{ path: 'params', element: <ParamsPage /> },
|
||||
{ path: 'blank', element: <BlankPage /> },
|
||||
//
|
||||
{
|
||||
path: 'party-event',
|
||||
children: [
|
||||
{ index: true, element: <PartyEventListPage /> },
|
||||
{ path: 'list', element: <PartyEventListPage /> },
|
||||
{ path: ':id', element: <PartyEventDetailsPage /> },
|
||||
{ path: 'new', element: <PartyEventCreatePage /> },
|
||||
{ path: ':id/edit', element: <PartyEventEditPage /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'party-order',
|
||||
children: [
|
||||
{ index: true, element: <PartyOrderListPage /> },
|
||||
{ path: 'list', element: <PartyOrderListPage /> },
|
||||
{ path: ':id', element: <PartyOrderDetailsPage /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'party-user',
|
||||
children: [
|
||||
{ index: true, element: <PartyUserProfilePage /> },
|
||||
{ path: 'profile', element: <PartyUserProfilePage /> },
|
||||
{ path: 'cards', element: <PartyUserCardsPage /> },
|
||||
{ path: 'list', element: <PartyUserListPage /> },
|
||||
{ path: 'new', element: <PartyUserCreatePage /> },
|
||||
{ path: ':id/edit', element: <PartyUserEditPage /> },
|
||||
{
|
||||
path: 'account',
|
||||
element: accountLayout(),
|
||||
children: [
|
||||
{ index: true, element: <AccountGeneralPage /> },
|
||||
{ path: 'billing', element: <AccountBillingPage /> },
|
||||
{ path: 'notifications', element: <AccountNotificationsPage /> },
|
||||
{ path: 'socials', element: <AccountSocialsPage /> },
|
||||
{ path: 'change-password', element: <AccountChangePasswordPage /> },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// AI: this file store page routeing of app
|
||||
//
|
||||
import { lazy, Suspense } from 'react';
|
||||
import type { RouteObject } from 'react-router';
|
||||
import { SplashScreen } from 'src/components/loading-screen';
|
||||
|
@@ -27,6 +27,10 @@ const Page403 = lazy(() => import('src/pages/error/403'));
|
||||
const Page404 = lazy(() => import('src/pages/error/404'));
|
||||
// Blank
|
||||
const BlankPage = lazy(() => import('src/pages/blank'));
|
||||
// PartyEvent
|
||||
const PartyEventDetailsPage = lazy(() => import('src/pages/dashboard/party-event/details'));
|
||||
const PartyEventListPage = lazy(() => import('src/pages/dashboard/party-event/list'));
|
||||
const PartyEventCheckoutPage = lazy(() => import('src/pages/party-event/checkout'));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -58,6 +62,15 @@ export const mainRoutes: RouteObject[] = [
|
||||
{ path: 'checkout', element: <ProductCheckoutPage /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'party-event',
|
||||
children: [
|
||||
{ index: true, element: <PartyEventListPage /> },
|
||||
{ path: 'list', element: <PartyEventListPage /> },
|
||||
{ path: ':id', element: <PartyEventDetailsPage /> },
|
||||
{ path: 'checkout', element: <PartyEventCheckoutPage /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'post',
|
||||
children: [
|
||||
|
@@ -13,7 +13,7 @@ import { useBoolean, useSetState } from 'minimal-shared/hooks';
|
||||
import { varAlpha } from 'minimal-shared/utils';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { _orders, ORDER_STATUS_OPTIONS } from 'src/_mock';
|
||||
import { _party_orders, ORDER_STATUS_OPTIONS } from 'src/_mock';
|
||||
import { deleteOrder, useGetOrders } from 'src/actions/order';
|
||||
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
||||
import { ConfirmDialog } from 'src/components/custom-dialog';
|
||||
|
45
03_source/frontend/src/sections/party-event/cart-icon.tsx
Normal file
45
03_source/frontend/src/sections/party-event/cart-icon.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import Badge from '@mui/material/Badge';
|
||||
import type { BoxProps } from '@mui/material/Box';
|
||||
import Box from '@mui/material/Box';
|
||||
import { Iconify } from 'src/components/iconify';
|
||||
import { RouterLink } from 'src/routes/components';
|
||||
import { paths } from 'src/routes/paths';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = BoxProps<'a'> & {
|
||||
totalItems: number;
|
||||
};
|
||||
|
||||
export function CartIcon({ totalItems, sx, ...other }: Props) {
|
||||
return (
|
||||
<Box
|
||||
component={RouterLink}
|
||||
href={paths.product.checkout}
|
||||
sx={[
|
||||
(theme) => ({
|
||||
right: 0,
|
||||
top: 112,
|
||||
zIndex: 999,
|
||||
display: 'flex',
|
||||
cursor: 'pointer',
|
||||
position: 'fixed',
|
||||
color: 'text.primary',
|
||||
borderTopLeftRadius: 16,
|
||||
borderBottomLeftRadius: 16,
|
||||
bgcolor: 'background.paper',
|
||||
padding: theme.spacing(1, 3, 1, 2),
|
||||
boxShadow: theme.vars.customShadows.dropdown,
|
||||
transition: theme.transitions.create(['opacity']),
|
||||
'&:hover': { opacity: 0.72 },
|
||||
}),
|
||||
...(Array.isArray(sx) ? sx : [sx]),
|
||||
]}
|
||||
{...other}
|
||||
>
|
||||
<Badge showZero badgeContent={totalItems} color="error" max={99}>
|
||||
<Iconify icon="solar:cart-3-bold" width={24} />
|
||||
</Badge>
|
||||
</Box>
|
||||
);
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
import Box from '@mui/material/Box';
|
||||
import { useEffect } from 'react';
|
||||
import {
|
||||
Carousel,
|
||||
CarouselArrowNumberButtons,
|
||||
CarouselThumb,
|
||||
CarouselThumbs,
|
||||
useCarousel,
|
||||
} from 'src/components/carousel';
|
||||
import { Image } from 'src/components/image';
|
||||
import { Lightbox, useLightBox } from 'src/components/lightbox';
|
||||
import type { IPartyEventItem } from 'src/types/party-event';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
images?: IPartyEventItem['images'];
|
||||
};
|
||||
|
||||
export function ProductDetailsCarousel({ images }: Props) {
|
||||
const carousel = useCarousel({ thumbs: { slidesToShow: 'auto' } });
|
||||
|
||||
const slides = images?.map((img) => ({ src: img })) || [];
|
||||
|
||||
const lightbox = useLightBox(slides);
|
||||
|
||||
useEffect(() => {
|
||||
if (lightbox.open) {
|
||||
carousel.mainApi?.scrollTo(lightbox.selected, true);
|
||||
}
|
||||
}, [carousel.mainApi, lightbox.open, lightbox.selected]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<Box sx={{ mb: 2.5, position: 'relative' }}>
|
||||
<CarouselArrowNumberButtons
|
||||
{...carousel.arrows}
|
||||
options={carousel.options}
|
||||
totalSlides={carousel.dots.dotCount}
|
||||
selectedIndex={carousel.dots.selectedIndex + 1}
|
||||
sx={{ right: 16, bottom: 16, position: 'absolute' }}
|
||||
/>
|
||||
|
||||
<Carousel carousel={carousel} sx={{ borderRadius: 2 }}>
|
||||
{slides.map((slide) => (
|
||||
<Image
|
||||
key={slide.src}
|
||||
alt={slide.src}
|
||||
src={slide.src}
|
||||
ratio="1/1"
|
||||
onClick={() => lightbox.onOpen(slide.src)}
|
||||
sx={{ cursor: 'zoom-in', minWidth: 320 }}
|
||||
/>
|
||||
))}
|
||||
</Carousel>
|
||||
</Box>
|
||||
|
||||
<CarouselThumbs
|
||||
ref={carousel.thumbs.thumbsRef}
|
||||
options={carousel.options?.thumbs}
|
||||
slotProps={{ disableMask: true }}
|
||||
sx={{ width: 360 }}
|
||||
>
|
||||
{slides.map((item, index) => (
|
||||
<CarouselThumb
|
||||
key={item.src}
|
||||
index={index}
|
||||
src={item.src}
|
||||
selected={index === carousel.thumbs.selectedIndex}
|
||||
onClick={() => carousel.thumbs.onClickThumb(index)}
|
||||
/>
|
||||
))}
|
||||
</CarouselThumbs>
|
||||
</div>
|
||||
|
||||
<Lightbox
|
||||
index={lightbox.selected}
|
||||
slides={slides}
|
||||
open={lightbox.open}
|
||||
close={lightbox.onClose}
|
||||
onGetCurrentIndex={(index) => lightbox.setSelected(index)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user