diff --git a/03_source/cms_backend/prisma/schema.prisma b/03_source/cms_backend/prisma/schema.prisma
index 48dcc14..0560fc6 100644
--- a/03_source/cms_backend/prisma/schema.prisma
+++ b/03_source/cms_backend/prisma/schema.prisma
@@ -1267,12 +1267,13 @@ model PartyUser {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//
- name String?
username String? @unique
+ password String?
+ //
+ name String?
email String @unique
emailVerified DateTime?
- password String?
- image String?
+ avatarUrl String?
bucketImage String?
admin Boolean @default(false)
accounts Account[]
@@ -1283,4 +1284,10 @@ model PartyUser {
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("")
}
diff --git a/03_source/cms_backend/src/app/api/party-user/create/test.http b/03_source/cms_backend/src/app/api/party-user/create/test.http
index 2fb346e..2142929 100644
--- a/03_source/cms_backend/src/app/api/party-user/create/test.http
+++ b/03_source/cms_backend/src/app/api/party-user/create/test.http
@@ -5,16 +5,15 @@ Content-Type: application/json
{
"partyUserData": {
- "createdAt": "2025-06-15T17:47:24.547Z",
- "updatedAt": "2025-06-15T17:47:24.547Z",
- "name": "Alice",
+ "name": "Alice 123321",
"username": null,
- "email": "alice@prisma.io",
+ "email": "alice@123111321.io",
"emailVerified": "2025-06-15T17:47:23.919Z",
"password": "Aa12345678",
- "image": null,
"bucketImage": null,
"admin": false,
- "info": null
+ "info": null,
+ "phoneNumber": "+85291234567",
+ "avatarUrl": ""
}
}
diff --git a/03_source/frontend/src/actions/party-user.ts b/03_source/frontend/src/actions/party-user.ts
index d5b4812..f1e24f2 100644
--- a/03_source/frontend/src/actions/party-user.ts
+++ b/03_source/frontend/src/actions/party-user.ts
@@ -184,15 +184,29 @@ type CreateUserData = {
password: string;
};
-export async function createUser(createUserData: CreateUserData) {
- console.log('create product ?');
- // const url = productId ? [endpoints.product.details, { params: { productId } }] : '';
+export async function createPartyUser(partyUserData: CreateUserData) {
+ /**
+ * Work on server
+ */
+ const data = { partyUserData };
+ const {
+ data: { id },
+ } = await axiosInstance.post(endpoints.partyUser.create, data);
- const res = await axiosInstance.post('http://localhost:7272/api/user/createUser', {
- data: createUserData,
- });
+ /**
+ * Work in local
+ */
+ mutate(
+ endpoints.partyUser.list,
+ (currentData: any) => {
+ const currentPartyUsers: IPartyUserItem[] = currentData?.partyUsers;
- return res;
+ const partyUsers = [...currentPartyUsers, { ...partyUserData, id }];
+
+ return { ...currentData, partyUsers };
+ },
+ false
+ );
}
// ----------------------------------------------------------------------
diff --git a/03_source/frontend/src/sections/party-user/party-user-new-edit-form.tsx b/03_source/frontend/src/sections/party-user/party-user-new-edit-form.tsx
index 792b2fe..e3baf79 100644
--- a/03_source/frontend/src/sections/party-user/party-user-new-edit-form.tsx
+++ b/03_source/frontend/src/sections/party-user/party-user-new-edit-form.tsx
@@ -11,7 +11,7 @@ import { useState } from 'react';
import { Controller, useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { isValidPhoneNumber } from 'react-phone-number-input/input';
-import { createUser, deletePartyUser, updatePartyUser } from 'src/actions/party-user';
+import { createPartyUser, deletePartyUser, updatePartyUser } from 'src/actions/party-user';
import { Field, Form, schemaHelper } from 'src/components/hook-form';
import { Label } from 'src/components/label';
import { toast } from 'src/components/snackbar';
@@ -49,6 +49,7 @@ export const NewUserSchema = zod.object({
avatarUrl: zod.string().optional().or(zod.literal('')),
phoneNumber: zod.string().optional().or(zod.literal('')),
isVerified: zod.boolean().default(true),
+ //
username: zod.string().optional().or(zod.literal('')),
password: zod.string().optional().or(zod.literal('')),
});
@@ -119,9 +120,6 @@ export function PartyUserNewEditForm({ currentUser }: Props) {
const onSubmit = handleSubmit(async (data: any) => {
try {
- await new Promise((resolve) => setTimeout(resolve, 500));
- reset();
-
const temp: any = data.avatarUrl;
if (temp instanceof File) {
data.avatarUrl = await fileToBase64(temp);
@@ -134,7 +132,7 @@ export function PartyUserNewEditForm({ currentUser }: Props) {
await updatePartyUser(sanitizedValues);
} else {
// perform create
- await createUser(sanitizedValues);
+ await createPartyUser(sanitizedValues);
}
toast.success(currentUser ? t('Update success!') : t('Create success!'));
@@ -289,14 +287,13 @@ export function PartyUserNewEditForm({ currentUser }: Props) {
- <>{JSON.stringify({ errors })}>
diff --git a/03_source/frontend/src/sections/party-user/view/party-user-create-view.tsx b/03_source/frontend/src/sections/party-user/view/party-user-create-view.tsx
index a304319..ffe9ffa 100644
--- a/03_source/frontend/src/sections/party-user/view/party-user-create-view.tsx
+++ b/03_source/frontend/src/sections/party-user/view/party-user-create-view.tsx
@@ -12,12 +12,12 @@ export function UserCreateView() {
return (