feat: update frontend references from User to PartyUser for party user management module
This commit is contained in:
@@ -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<UsersData>(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 };
|
||||
},
|
||||
|
@@ -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) {
|
||||
|
@@ -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 } }}
|
||||
/>
|
||||
|
||||
<UserNewEditForm />
|
||||
<PartyUserNewEditForm />
|
||||
</DashboardContent>
|
||||
);
|
||||
}
|
||||
|
@@ -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) {
|
||||
<DashboardContent>
|
||||
<CustomBreadcrumbs
|
||||
heading="Edit"
|
||||
backHref={paths.dashboard.user.list}
|
||||
backHref={paths.dashboard.partyUser.list}
|
||||
links={[
|
||||
{ name: t('Dashboard'), href: paths.dashboard.root },
|
||||
{ name: t('User'), href: paths.dashboard.user.root },
|
||||
{ name: t('Party User'), href: paths.dashboard.partyUser.root },
|
||||
{ name: currentUser?.name },
|
||||
]}
|
||||
sx={{ mb: { xs: 3, md: 5 } }}
|
||||
/>
|
||||
|
||||
<UserNewEditForm currentUser={currentUser} />
|
||||
<PartyUserNewEditForm currentUser={currentUser} />
|
||||
</DashboardContent>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user