diff --git a/src/pages/settings/user/manage-user/blocks/DeleteDialog.tsx b/src/pages/settings/user/manage-user/blocks/DeleteDialog.tsx
index f16da88..3e6173a 100644
--- a/src/pages/settings/user/manage-user/blocks/DeleteDialog.tsx
+++ b/src/pages/settings/user/manage-user/blocks/DeleteDialog.tsx
@@ -16,7 +16,7 @@ import { useCallApi } from '@/hooks';
import { doSaveLogActivity } from '@/actions/GlobalActions';
import { EnforceSwitch } from '@/components/switch';
-const API_URL = apiConfig.service_dashboard;
+const API_URL = apiConfig.service_user;
const DeleteDialog = () => {
const { showDeleteDialog, handleDeleteDialog, selectedUser } = useUserContext();
diff --git a/src/pages/settings/user/manage-user/blocks/EditDialog.tsx b/src/pages/settings/user/manage-user/blocks/EditDialog.tsx
index 22d29d1..ac615ec 100644
--- a/src/pages/settings/user/manage-user/blocks/EditDialog.tsx
+++ b/src/pages/settings/user/manage-user/blocks/EditDialog.tsx
@@ -39,8 +39,8 @@ import {
validateFormCreateUser
} from './Types';
-const API_URL_CUSTOMER = apiConfig.service_customer;
-const API_URL = apiConfig.service_dashboard;
+// const API_URL_CUSTOMER = apiConfig.service_customer;
+const API_URL = apiConfig.service_user;
const EditDialog = () => {
const parentRef = useRef
(null);
@@ -109,59 +109,59 @@ const EditDialog = () => {
[selectedUser, formField]
);
- const doFetchUserRole = useCallback(async (sorting: any) => {
- try {
- sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
- const response = await GetData(`${API_URL}/user_role/list`, {
- limit: 100,
- page: 1,
- with_deleted: false,
- order_field: sorting[0].id,
- order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
- });
+ // const doFetchUserRole = useCallback(async (sorting: any) => {
+ // try {
+ // sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
+ // const response = await GetData(`${API_URL}/user_role/list`, {
+ // limit: 100,
+ // page: 1,
+ // with_deleted: false,
+ // order_field: sorting[0].id,
+ // order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
+ // });
- setRoles(response?.data.list);
- } catch (error) {
- console.error('Error fetching role', error);
- }
- }, []);
+ // setRoles(response?.data.list);
+ // } catch (error) {
+ // console.error('Error fetching role', error);
+ // }
+ // }, []);
- const getCustomerList = async (sorting: any, filterValue: string) => {
- const filter: any =
- filterValue?.trim().length === 0 ? {} : { fullname: { like: `%${filterValue}%` } };
+ // const getCustomerList = async (sorting: any, filterValue: string) => {
+ // const filter: any =
+ // filterValue?.trim().length === 0 ? {} : { fullname: { like: `%${filterValue}%` } };
- sorting = sorting.length == 0 ? [{ id: 'created_at', desc: false }] : sorting;
+ // sorting = sorting.length == 0 ? [{ id: 'created_at', desc: false }] : sorting;
- const query: any = {
- limit: 100,
- page: 1,
- with_deleted: false,
- order_field: sorting[0].id,
- order_direction: sorting[0].desc ? 'DESC' : 'ASC'
- };
+ // const query: any = {
+ // limit: 100,
+ // page: 1,
+ // with_deleted: false,
+ // order_field: sorting[0].id,
+ // order_direction: sorting[0].desc ? 'DESC' : 'ASC'
+ // };
- if (filter && Object.keys(filter).length > 0) {
- query.filter = JSON.stringify(filter);
- }
- try {
- const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, query);
+ // if (filter && Object.keys(filter).length > 0) {
+ // query.filter = JSON.stringify(filter);
+ // }
+ // try {
+ // const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, query);
- if (response?.status) {
- setCustomers(response?.data.list);
- } else {
- toast.error(response?.message);
- }
- } catch (error) {
- toast.error('Failed to fetch customer list');
- } finally {
- setIsLoadingCustomer(false);
- }
- };
+ // if (response?.status) {
+ // setCustomers(response?.data.list);
+ // } else {
+ // toast.error(response?.message);
+ // }
+ // } catch (error) {
+ // toast.error('Failed to fetch customer list');
+ // } finally {
+ // setIsLoadingCustomer(false);
+ // }
+ // };
const doFetchUserData = useCallback(async (id: string) => {
setIsFetching(true);
- const response = await GetData(`${API_URL}/user/detail/${id}`, { id });
+ const response = await GetData(`${API_URL}/user/profile/${id}`, { id });
if (response?.status) {
setFormField((prev) => ({
@@ -169,9 +169,9 @@ const EditDialog = () => {
name: response.data.name,
username: response.data.username,
email: response.data.email,
- id_role: response.data.idRole,
+ // id_role: response.data.idRole,
status: response.data.status,
- customerid: response.data.customer?.id || ''
+ // customerid: response.data.customer?.id || ''
}));
} else {
setFormField((prev) => ({
@@ -179,30 +179,30 @@ const EditDialog = () => {
name: '',
username: '',
email: '',
- id_role: '',
+ // id_role: '',
status: '',
- customerid: ''
+ // customerid: ''
}));
}
setIsFetching(false);
}, []);
- const handleCustomerSearch = (e: React.ChangeEvent) => {
- setIsLoadingCustomer(true);
- setSearchTerm(e.target.value);
- setSelectedCustomerName(e.target.value);
- setDropdownOpen(true);
- const timer = setTimeout(() => {
- getCustomerList([{ id: 'fullname', desc: false }], e.target.value);
- }, 500);
- return () => clearTimeout(timer);
- };
+ // const handleCustomerSearch = (e: React.ChangeEvent) => {
+ // setIsLoadingCustomer(true);
+ // setSearchTerm(e.target.value);
+ // setSelectedCustomerName(e.target.value);
+ // setDropdownOpen(true);
+ // const timer = setTimeout(() => {
+ // getCustomerList([{ id: 'fullname', desc: false }], e.target.value);
+ // }, 500);
+ // return () => clearTimeout(timer);
+ // };
- const handleCustomerSelect = (customer: CustomerProps) => {
- setFormField({ ...formField, customerid: customer.id });
- setSelectedCustomerName(customer.fullname);
- setDropdownOpen(false);
- };
+ // const handleCustomerSelect = (customer: CustomerProps) => {
+ // setFormField({ ...formField, customerid: customer.id });
+ // setSelectedCustomerName(customer.fullname);
+ // setDropdownOpen(false);
+ // };
const filteredCustomer = customers
.filter((item) => item.fullname.toLowerCase().includes(searchTerm.toLowerCase()))
@@ -216,8 +216,8 @@ const EditDialog = () => {
}, [showEditDialog]);
useEffect(() => {
- getCustomerList([{ id: 'created_at', desc: false }], '');
- doFetchUserRole([{ id: 'name', desc: false }]);
+ // getCustomerList([{ id: 'created_at', desc: false }], '');
+ // doFetchUserRole([{ id: 'name', desc: false }]);
}, []);
useEffect(() => {
@@ -316,7 +316,7 @@ const EditDialog = () => {
{/* Customer */}
-
diff --git a/src/pages/settings/user/manage-user/blocks/Types.ts b/src/pages/settings/user/manage-user/blocks/Types.ts
index d7ec902..02ac076 100644
--- a/src/pages/settings/user/manage-user/blocks/Types.ts
+++ b/src/pages/settings/user/manage-user/blocks/Types.ts
@@ -21,7 +21,7 @@ export interface CreateUserParams {
password: string;
retype_password: string;
name: string;
- id_role: string;
+ // id_role: string;
status: string;
}
@@ -31,18 +31,18 @@ export const initialStateCreateUser: {
password: string;
retype_password: string;
name: string;
- id_role: string;
+ // id_role: string;
status: string;
- customerid: string;
+ // customerid: string;
} = {
email: '',
username: '',
password: '',
retype_password: '',
name: '',
- id_role: '',
+ // id_role: '',
status: '',
- customerid: ''
+ // customerid: ''
};
export const validateFormCreateUser = (
@@ -56,7 +56,7 @@ export const validateFormCreateUser = (
{ key: 'name', label: 'Name' },
{ key: 'username', label: 'Username' },
{ key: 'email', label: 'Email' },
- { key: 'id_role', label: 'Role' },
+ // { key: 'id_role', label: 'Role' },
{ key: 'status', label: 'Status' },
{ key: 'password', label: 'Password' },
{ key: 'retype_password', label: 'Retype Password' }
@@ -65,7 +65,7 @@ export const validateFormCreateUser = (
{ key: 'name', label: 'Name' },
{ key: 'username', label: 'Username' },
{ key: 'email', label: 'Email' },
- { key: 'id_role', label: 'Role' },
+ // { key: 'id_role', label: 'Role' },
{ key: 'status', label: 'Status' }
];
diff --git a/src/pages/settings/user/manage-user/hooks/ManageUserContext.tsx b/src/pages/settings/user/manage-user/hooks/ManageUserContext.tsx
index 91cca04..715b2f8 100644
--- a/src/pages/settings/user/manage-user/hooks/ManageUserContext.tsx
+++ b/src/pages/settings/user/manage-user/hooks/ManageUserContext.tsx
@@ -35,10 +35,10 @@ interface SelectedUser {
name: string;
email: string;
username: string;
- role: string;
+ // role: string;
new_password: string;
check_new_password: string;
- customer: string;
+ // customer: string;
}
const initialProps: ContextProps = {
@@ -57,7 +57,7 @@ const initialProps: ContextProps = {
const ManageUserContext = createContext
(initialProps);
-const API_URL = apiConfig.service_dashboard;
+const API_URL = apiConfig.service_user;
const ManageUserContextProvider = ({ children }: { children: React.ReactNode }) => {
/* state */
@@ -98,16 +98,16 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
enableSorting: true,
enableHiding: false
},
- {
- accessorFn: (row) => row.customer?.username,
- id: 'Users.customer',
- header: ({ column }) => ,
- enableSorting: true,
- enableHiding: false,
- meta: {
- headerClassName: 'w-[300px]'
- }
- },
+ // {
+ // accessorFn: (row) => row.customer?.username,
+ // id: 'Users.customer',
+ // header: ({ column }) => ,
+ // enableSorting: true,
+ // enableHiding: false,
+ // meta: {
+ // headerClassName: 'w-[300px]'
+ // }
+ // },
{
accessorFn: (row) => row.email,
id: 'email',
@@ -128,23 +128,23 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
headerClassName: 'w-[250px]'
}
},
- {
- accessorFn: (row) => row.role.name,
- id: 'Users.role',
- header: ({ column }) => ,
- enableSorting: true,
- enableHiding: false,
- cell: (data: any) => {
- const { role } = data.row.original;
- // console.log('role :', role);
- let html = Unassigned
;
- if (role && role.name) html = role.name;
- return html;
- },
- meta: {
- headerClassName: 'w-[350px]'
- }
- },
+ // {
+ // accessorFn: (row) => row.role.name,
+ // id: 'Users.role',
+ // header: ({ column }) => ,
+ // enableSorting: true,
+ // enableHiding: false,
+ // cell: (data: any) => {
+ // const { role } = data.row.original;
+ // // console.log('role :', role);
+ // let html = Unassigned
;
+ // if (role && role.name) html = role.name;
+ // return html;
+ // },
+ // meta: {
+ // headerClassName: 'w-[350px]'
+ // }
+ // },
{
accessorFn: (row) => row.status,
id: 'status',
@@ -192,8 +192,8 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
setSelectedUser(row.id);
}}
>
-
- QR Code
+ {/*
+ QR Code */}
handleEditDialog(true, row.id)}>
@@ -223,16 +223,16 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
// ➕ Tambahkan prefix ke field dari tabel Users
const mappedSorting = sorting.map((sort: any) => ({
...sort,
- id: USER_TABLE_COLUMNS.includes(sort.id) ? `Users.${sort.id}` : sort.id
+ id: USER_TABLE_COLUMNS.includes(sort.id) ? `${sort.id}` : sort.id
}));
- const orderField = mappedSorting[0]?.id ?? 'Users.username';
+ const orderField = mappedSorting[0]?.id ?? 'username';
const orderDirection = mappedSorting[0]?.desc === false ? 'DESC' : 'ASC';
filter =
filter.length == 0
? {}
- : { 'Users.username': { like: `%${filter[0].value?.toLowerCase()}%` } };
+ : { 'username': { like: `%${filter[0].value?.toLowerCase()}%` } };
const response = await GetData(`${API_URL}/user/list`, {
limit: limit,
page: page + 1,
@@ -241,7 +241,7 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
order_direction: orderDirection,
filter: JSON.stringify(filter)
});
- // console.log('response api:', response);
+ console.log('response api:', response);
return { data: response?.data.list, totalCount: response?.data.total_count };
};
@@ -267,17 +267,12 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
pagination={{ size: 10 }}
toolbar={}
layout={{ card: true }}
- sorting={[{ id: 'Users.created_at', desc: false }]}
+ sorting={[{ id: 'created_at', desc: false }]}
serverSide={true}
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
doGetListData(pageIndex, pageSize, sorting, columnFilters)
}
>
-
{children}
diff --git a/src/routing/AppRoutingSetup.tsx b/src/routing/AppRoutingSetup.tsx
index 93ae249..d5d08fc 100644
--- a/src/routing/AppRoutingSetup.tsx
+++ b/src/routing/AppRoutingSetup.tsx
@@ -64,6 +64,7 @@ const AppRoutingSetup = (): ReactElement => {
} />
} />
} />
+ } />
{/* } />
} />
@@ -128,7 +129,6 @@ const AppRoutingSetup = (): ReactElement => {
} />
} />
} />
- } />
} />