Fixed admin user access
Admin Layout & Pages - app/(application)/admin/_layout.tsx - app/(application)/admin/user-access/index.tsx Admin Components - components/Drawer/NavbarMenu.tsx - components/_ShareComponent/Admin/BoxTitlePage.tsx - components/_ShareComponent/Admin/AdminBasicBox.tsx Admin Screens - screens/Admin/User-Access/ API – Admin User Access - service/api-admin/api-admin-user-access.ts Docs - docs/prompt-for-qwen-code.md ### No issue
This commit is contained in:
@@ -3,15 +3,31 @@ import { apiConfig } from "../api-config";
|
||||
export const apiAdminUserAccessGetAll = async ({
|
||||
search,
|
||||
category,
|
||||
page = "1",
|
||||
}: {
|
||||
search?: string;
|
||||
category: "only-user" | "only-admin" | "all-role";
|
||||
page?: string;
|
||||
}) => {
|
||||
try {
|
||||
const response = await apiConfig.get(`/mobile/admin/user?category=${category}&search=${search}`);
|
||||
return response.data;
|
||||
const response = await apiConfig.get(
|
||||
`/mobile/admin/user?category=${category}&search=${search}&page=${page}`,
|
||||
);
|
||||
// Pastikan mengembalikan struktur data yang konsisten
|
||||
return {
|
||||
success: response.data.success,
|
||||
message: response.data.message,
|
||||
data: response.data.data || [], // Gunakan data yang sebenarnya atau array kosong
|
||||
pagination: response.data.pagination, // Jika ada info pagination
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
success: false,
|
||||
message: "Error fetching data",
|
||||
data: [],
|
||||
pagination: null,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,12 +52,15 @@ export const apiAdminUserAccessUpdateStatus = async ({
|
||||
category: "access" | "role";
|
||||
}) => {
|
||||
try {
|
||||
const response = await apiConfig.put(`/mobile/admin/user/${id}?category=${category}`, {
|
||||
data: {
|
||||
active,
|
||||
role,
|
||||
const response = await apiConfig.put(
|
||||
`/mobile/admin/user/${id}?category=${category}`,
|
||||
{
|
||||
data: {
|
||||
active,
|
||||
role,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
Reference in New Issue
Block a user