feat(admins): implement admin status management

This commit introduces the functionality for super admins to change the status of other admin users to either 'Active' or 'Inactive'. This provides better control over admin account access.

Key changes include:
- A 'Status' column with a visual badge has been added to the admins table.
- A new 'Change Status' action button, using a new `UserSettingIcon`, opens a modal for status updates.
- The backend service and frontend mutation for updating an admin's status are implemented.
- The `IUser` type and a new `AdminStatus` enum have been added to support this feature.

Additionally, the confirmation modal implementation has been simplified across the admin and customer tables by removing the `modalConfig` state.
This commit is contained in:
AmirReza Jamali
2025-09-21 13:18:53 +03:30
parent e00e75b8be
commit 1d78b2b65d
18 changed files with 274 additions and 173 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ export const API_ENDPOINTS = {
REFRESH_TOKEN: "profile/refresh-token",
ADMINS: "users",
ADMIN_DETAILS: (id: string) => `users/${id}`,
CHANGE_ADMIN_STATUS: (id: string) => `users/${id}/status`,
},
PROFILE: {
READ: "profile",
@@ -25,7 +26,7 @@ export const API_ENDPOINTS = {
UPDATE: (id: string) => `company-categories/${id}`,
DELETE: (id: string) => `company-categories/${id}`,
DETAILS: (id: string) => `company-categories/${id}`,
TOGGLE_PUBLISHED:(id:string) => `company-categories/${id}/publish`,
TOGGLE_PUBLISHED: (id: string) => `company-categories/${id}/publish`,
},
},
TENDERS: {
+17
View File
@@ -9,6 +9,7 @@ import {
ILogoutResponse,
LoginResponseSchema,
LogoutResponseSchema,
TChangeAdminStatusCredentials,
} from "../types";
export const userService = {
@@ -87,4 +88,20 @@ export const userService = {
throw error;
}
},
changeAdminStatus: async ({
id,
credentials,
}: {
id: string;
credentials: TChangeAdminStatusCredentials;
}) => {
try {
return (
await api.put(API_ENDPOINTS.USER.CHANGE_ADMIN_STATUS(id), credentials)
).data;
} catch (error) {
console.error("ERROR Caught in user service => change status", error);
throw error;
}
},
};
+6 -2
View File
@@ -58,13 +58,17 @@ export const LoginResponse = z.object({
export const LogoutResponse = z.object({
message: z.string(),
});
export const changeAdminStatusCredentialsSchema = z.object({
status: z.string(),
});
export type IUser = z.infer<typeof UserSchema>;
export type ILogoutResponse = z.infer<typeof LogoutResponse>;
export type ILoginCredentials = z.infer<typeof LoginCredentials>;
export type ILoginResponse = z.infer<typeof LoginResponse>;
export type IAdminListResponse = z.infer<typeof AdminListResponse>;
export type TChangeAdminStatusCredentials = z.infer<
typeof changeAdminStatusCredentialsSchema
>;
export const LogoutResponseSchema = createApiResponseSchema(LogoutResponse);
export const LoginResponseSchema = createApiResponseSchema(LoginResponse);
export const AdminListResponseSchema =