From 44d324b40e93de86071f69eaad5e82a7bbee534c Mon Sep 17 00:00:00 2001 From: louiscklaw Date: Mon, 16 Jun 2025 10:20:09 +0800 Subject: [PATCH] feat: update frontend references from User to PartyUser for party user management module --- 03_source/frontend/src/actions/party-user.ts | 7 +++---- .../src/sections/party-user/party-user-new-edit-form.tsx | 8 ++++---- .../sections/party-user/view/party-user-create-view.tsx | 4 ++-- .../src/sections/party-user/view/party-user-edit-view.tsx | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/03_source/frontend/src/actions/party-user.ts b/03_source/frontend/src/actions/party-user.ts index 40dbee2..0a53956 100644 --- a/03_source/frontend/src/actions/party-user.ts +++ b/03_source/frontend/src/actions/party-user.ts @@ -22,7 +22,7 @@ type UsersData = { // TODO: i want to refactor / tidy here export function useGetPartyUsers() { - const url = `http://localhost:7272/api/party-user/list`; + const url = endpoints.partyUser.list; const { data, isLoading, error, isValidating } = useSWR(url, fetcher, swrOptions); @@ -180,13 +180,12 @@ export async function deletePartyUser(partyUserId: string) { /** * Work in local */ - mutate( endpoints.partyUser.list, (currentData: any) => { - const currentProducts: IPartyUserItem[] = currentData?.partyUsers; + const currentPartyUsers: IPartyUserItem[] = currentData?.partyUsers; - const partyUsers = currentProducts.filter((partyUser) => partyUser.id !== partyUserId); + const partyUsers = currentPartyUsers.filter((partyUser) => partyUser.id !== partyUserId); return { ...currentData, partyUsers }; }, 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 f920951..2390a0e 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 @@ -56,7 +56,7 @@ type Props = { currentUser?: IPartyUserItem; }; -export function UserNewEditForm({ currentUser }: Props) { +export function PartyUserNewEditForm({ currentUser }: Props) { const { t } = useTranslation(); const router = useRouter(); @@ -103,8 +103,8 @@ export function UserNewEditForm({ currentUser }: Props) { try { if (currentUser) { await deletePartyUser(currentUser.id); - toast.success(t('user deleted')); - router.push(paths.dashboard.user.list); + toast.success(t('party user deleted')); + router.push(paths.dashboard.partyUser.list); } } catch (error) { console.error(error); @@ -133,7 +133,7 @@ export function UserNewEditForm({ currentUser }: Props) { toast.success(currentUser ? t('Update success!') : t('Create success!')); - router.push(paths.dashboard.user.list); + router.push(paths.dashboard.partyUser.list); // console.info('DATA', data); } catch (error) { 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 4cb9aff..a304319 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 @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'; import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs'; import { DashboardContent } from 'src/layouts/dashboard'; import { paths } from 'src/routes/paths'; -import { UserNewEditForm } from '../party-user-new-edit-form'; +import { PartyUserNewEditForm } from '../party-user-new-edit-form'; // ---------------------------------------------------------------------- @@ -22,7 +22,7 @@ export function UserCreateView() { sx={{ mb: { xs: 3, md: 5 } }} /> - + ); } diff --git a/03_source/frontend/src/sections/party-user/view/party-user-edit-view.tsx b/03_source/frontend/src/sections/party-user/view/party-user-edit-view.tsx index c9b9d25..fe8a2c4 100644 --- a/03_source/frontend/src/sections/party-user/view/party-user-edit-view.tsx +++ b/03_source/frontend/src/sections/party-user/view/party-user-edit-view.tsx @@ -3,7 +3,7 @@ import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs'; import { DashboardContent } from 'src/layouts/dashboard'; import { paths } from 'src/routes/paths'; import type { IPartyUserItem } from 'src/types/party-user'; -import { UserNewEditForm } from '../party-user-new-edit-form'; +import { PartyUserNewEditForm } from '../party-user-new-edit-form'; // ---------------------------------------------------------------------- @@ -18,16 +18,16 @@ export function PartyUserEditView({ user: currentUser }: Props) { - + ); }