2022-02-09 11:44:08 +05:30
|
|
|
import axios from 'api';
|
|
|
|
|
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
|
|
|
import { AxiosError } from 'axios';
|
|
|
|
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
2022-05-03 15:27:09 +05:30
|
|
|
import { PayloadProps, Props } from 'types/api/user/changeMyPassword';
|
2022-02-09 11:44:08 +05:30
|
|
|
|
2022-05-03 15:27:09 +05:30
|
|
|
const changeMyPassword = async (
|
2022-02-09 11:44:08 +05:30
|
|
|
props: Props,
|
|
|
|
|
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
|
|
|
|
|
try {
|
2022-05-03 15:27:09 +05:30
|
|
|
const response = await axios.post(`/changePassword/${props.userId}`, {
|
2022-02-09 11:44:08 +05:30
|
|
|
...props,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
statusCode: 200,
|
|
|
|
|
error: null,
|
|
|
|
|
message: response.data.status,
|
|
|
|
|
payload: response.data,
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return ErrorResponseHandler(error as AxiosError);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-03 15:27:09 +05:30
|
|
|
export default changeMyPassword;
|