feat(reset-password): implement reset password functionality for admins and customers

- Added new ResetPasswordModalContent component for displaying generated passwords.
- Integrated reset password functionality in the AdminsTable and CustomersTable components, allowing users to reset passwords for admins and customers.
- Created useResetPasswordModalPresenter hook to manage password visibility and clipboard copying.
- Updated API services and hooks to support reset password requests for both admins and customers.
- Enhanced tooltip functionality for reset password actions in the tables.
This commit is contained in:
AmirReza Jamali
2026-05-30 12:09:57 +03:30
parent 746107e977
commit 5ef0298840
16 changed files with 480 additions and 9 deletions
+2
View File
@@ -13,6 +13,7 @@ export const API_ENDPOINTS = {
ADMINS: "users",
ADMIN_DETAILS: (id: string) => `users/${id}`,
CHANGE_ADMIN_STATUS: (id: string) => `users/${id}/status`,
RESET_ADMIN_PASSWORD: (id: string) => `users/${id}/reset-password`,
},
FILES: {
UPLOAD: "files/upload",
@@ -55,6 +56,7 @@ export const API_ENDPOINTS = {
DELETE: (id: string) => `customers/${id}`,
DETAILS: (id: string) => `customers/${id}`,
ASSIGN_COMPANY_TO_CUSTOMER: (id: string) => `customers/${id}/companies`,
RESET_PASSWORD: (id: string) => `customers/${id}/reset-password`,
},
FEEDBACK: {
READ_ALL: "feedback",
+14 -1
View File
@@ -1,6 +1,6 @@
import api from "../axios";
import { API_ENDPOINTS } from "../endpoints";
import { ApiResponse } from "../types";
import { ApiResponse, TResetPasswordResponse } from "../types";
import {
CreateCustomerCredentials,
CustomerListResponseSchema,
@@ -57,6 +57,19 @@ export const customersService = {
const response = await api.get(API_ENDPOINTS.CUSTOMERS.DETAILS(id));
return response.data;
},
resetCustomerPassword: async (
id: string,
): Promise<ApiResponse<TResetPasswordResponse>> => {
try {
return (await api.post(API_ENDPOINTS.CUSTOMERS.RESET_PASSWORD(id))).data;
} catch (error) {
console.error(
"ERROR caught in Customers Service Reset Password:",
error,
);
throw error;
}
},
assignCompanyToCustomer: async ({
credentials,
id,
+11
View File
@@ -10,6 +10,7 @@ import {
LoginResponseSchema,
LogoutResponseSchema,
TChangeAdminStatusCredentials,
TResetPasswordResponse,
} from "../types";
export const userService = {
@@ -92,6 +93,16 @@ export const userService = {
throw error;
}
},
resetAdminPassword: async (
id: string,
): Promise<ApiResponse<TResetPasswordResponse>> => {
try {
return (await api.post(API_ENDPOINTS.USER.RESET_ADMIN_PASSWORD(id))).data;
} catch (error) {
console.error("ERROR caught in User Service Reset Admin Password", error);
throw error;
}
},
changeAdminStatus: async ({
id,
credentials,
+6
View File
@@ -69,6 +69,9 @@ export const LogoutResponse = z.object({
export const changeAdminStatusCredentialsSchema = z.object({
status: z.string(),
});
export const ResetPasswordResponseSchema = z.object({
password: z.string(),
});
export type IUser = z.infer<typeof UserSchema>;
export type ILogoutResponse = z.infer<typeof LogoutResponse>;
export type ILoginCredentials = z.infer<typeof LoginCredentials>;
@@ -77,6 +80,9 @@ export type IAdminListResponse = z.infer<typeof AdminListResponse>;
export type TChangeAdminStatusCredentials = z.infer<
typeof changeAdminStatusCredentialsSchema
>;
export type TResetPasswordResponse = z.infer<
typeof ResetPasswordResponseSchema
>;
export const LogoutResponseSchema = createApiResponseSchema(LogoutResponse);
export const LoginResponseSchema = createApiResponseSchema(LoginResponse);
export const AdminListResponseSchema =