mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-25 06:01:29 +10:00
release: v4.1.0
This commit is contained in:
@ -28,7 +28,8 @@ export const useLogin = () => {
|
||||
mutationFn: login,
|
||||
onSuccess: (data) => {
|
||||
if (data.status === "2fa_required") {
|
||||
return navigate("/auth/verify-otp");
|
||||
navigate("/auth/verify-otp");
|
||||
return;
|
||||
}
|
||||
|
||||
setUser(data.user);
|
||||
|
||||
@ -5,12 +5,10 @@ import { AxiosResponse } from "axios";
|
||||
import { axios } from "@/client/libs/axios";
|
||||
|
||||
export const forgotPassword = async (data: ForgotPasswordDto) => {
|
||||
const response = await axios.post<void, AxiosResponse<void>, ForgotPasswordDto>(
|
||||
return axios.post<undefined, AxiosResponse<undefined>, ForgotPasswordDto>(
|
||||
"/auth/forgot-password",
|
||||
data,
|
||||
);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useForgotPassword = () => {
|
||||
|
||||
@ -5,12 +5,10 @@ import { AxiosResponse } from "axios";
|
||||
import { axios } from "@/client/libs/axios";
|
||||
|
||||
export const resetPassword = async (data: ResetPasswordDto) => {
|
||||
const response = await axios.post<void, AxiosResponse<void>, ResetPasswordDto>(
|
||||
return axios.post<undefined, AxiosResponse<undefined>, ResetPasswordDto>(
|
||||
"/auth/reset-password",
|
||||
data,
|
||||
);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useResetPassword = () => {
|
||||
|
||||
@ -3,44 +3,63 @@ import { ErrorMessage } from "@reactive-resume/utils";
|
||||
|
||||
export const translateError = (error: ErrorMessage) => {
|
||||
switch (error) {
|
||||
case ErrorMessage.InvalidCredentials:
|
||||
case ErrorMessage.InvalidCredentials: {
|
||||
return t`It doesn't look like a user exists with the credentials you provided.`;
|
||||
case ErrorMessage.UserAlreadyExists:
|
||||
}
|
||||
case ErrorMessage.UserAlreadyExists: {
|
||||
return t`A user with this email address and/or username already exists.`;
|
||||
case ErrorMessage.SecretsNotFound:
|
||||
}
|
||||
case ErrorMessage.SecretsNotFound: {
|
||||
return t`User does not have an associated 'secrets' record. Please report this issue on GitHub.`;
|
||||
case ErrorMessage.OAuthUser:
|
||||
}
|
||||
case ErrorMessage.OAuthUser: {
|
||||
return t`This email address is associated with an OAuth account. Please sign in with your OAuth provider.`;
|
||||
case ErrorMessage.InvalidResetToken:
|
||||
}
|
||||
case ErrorMessage.InvalidResetToken: {
|
||||
return t`It looks like the reset token you provided is invalid. Please try restarting the password reset process again.`;
|
||||
case ErrorMessage.InvalidVerificationToken:
|
||||
}
|
||||
case ErrorMessage.InvalidVerificationToken: {
|
||||
return t`It looks like the verification token you provided is invalid. Please try restarting the verification process again.`;
|
||||
case ErrorMessage.EmailAlreadyVerified:
|
||||
}
|
||||
case ErrorMessage.EmailAlreadyVerified: {
|
||||
return t`It looks like your email address has already been verified.`;
|
||||
case ErrorMessage.TwoFactorNotEnabled:
|
||||
}
|
||||
case ErrorMessage.TwoFactorNotEnabled: {
|
||||
return t`Two-factor authentication is not enabled for this account.`;
|
||||
case ErrorMessage.TwoFactorAlreadyEnabled:
|
||||
}
|
||||
case ErrorMessage.TwoFactorAlreadyEnabled: {
|
||||
return t`Two-factor authentication is already enabled for this account.`;
|
||||
case ErrorMessage.InvalidTwoFactorCode:
|
||||
}
|
||||
case ErrorMessage.InvalidTwoFactorCode: {
|
||||
return t`It looks like the two-factor authentication code you provided is invalid. Please try again.`;
|
||||
case ErrorMessage.InvalidTwoFactorBackupCode:
|
||||
}
|
||||
case ErrorMessage.InvalidTwoFactorBackupCode: {
|
||||
return t`It looks like the backup code you provided is invalid or used. Please try again.`;
|
||||
case ErrorMessage.InvalidBrowserConnection:
|
||||
}
|
||||
case ErrorMessage.InvalidBrowserConnection: {
|
||||
return t`There was an error connecting to the browser. Please make sure 'chrome' is running and reachable.`;
|
||||
case ErrorMessage.ResumeSlugAlreadyExists:
|
||||
}
|
||||
case ErrorMessage.ResumeSlugAlreadyExists: {
|
||||
return t`A resume with this slug already exists, please pick a different unique identifier.`;
|
||||
case ErrorMessage.ResumeNotFound:
|
||||
}
|
||||
case ErrorMessage.ResumeNotFound: {
|
||||
return t`It looks like the resume you're looking for doesn't exist.`;
|
||||
case ErrorMessage.ResumeLocked:
|
||||
}
|
||||
case ErrorMessage.ResumeLocked: {
|
||||
return t`The resume you want to update is locked, please unlock if you wish to make any changes to it.`;
|
||||
case ErrorMessage.ResumePrinterError:
|
||||
}
|
||||
case ErrorMessage.ResumePrinterError: {
|
||||
return t`Something went wrong while printing your resume. Please try again later or raise an issue on GitHub.`;
|
||||
case ErrorMessage.ResumePreviewError:
|
||||
}
|
||||
case ErrorMessage.ResumePreviewError: {
|
||||
return t`Something went wrong while grabbing a preview your resume. Please try again later or raise an issue on GitHub.`;
|
||||
case ErrorMessage.SomethingWentWrong:
|
||||
}
|
||||
case ErrorMessage.SomethingWentWrong: {
|
||||
return t`Something went wrong while processing your request. Please try again later or raise an issue on GitHub.`;
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -34,7 +34,7 @@ export const useContributors = () => {
|
||||
queryFn: fetchCrowdinContributors,
|
||||
});
|
||||
|
||||
const error = githubError || crowdinError;
|
||||
const error = githubError ?? crowdinError;
|
||||
const loading = githubLoading || crowdinLoading;
|
||||
|
||||
return { github, crowdin, loading, error };
|
||||
|
||||
@ -19,7 +19,7 @@ export const usePrintResume = () => {
|
||||
} = useMutation({
|
||||
mutationFn: printResume,
|
||||
onError: (error) => {
|
||||
const message = error?.message;
|
||||
const message = error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import { ResumeDto } from "@reactive-resume/dto";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { RESUME_KEY } from "@/client/constants/query-keys";
|
||||
import { axios } from "@/client/libs/axios";
|
||||
import { useResumeStore } from "@/client/stores/resume";
|
||||
|
||||
export const findResumeById = async (data: { id: string }) => {
|
||||
const response = await axios.get<ResumeDto>(`/resume/${data.id}`);
|
||||
@ -16,19 +13,3 @@ export const findResumeByUsernameSlug = async (data: { username: string; slug: s
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useResume = (id: string) => {
|
||||
const {
|
||||
error,
|
||||
isPending: loading,
|
||||
data: resume,
|
||||
} = useQuery({
|
||||
queryKey: [RESUME_KEY, { id }],
|
||||
queryFn: () => findResumeById({ id }),
|
||||
});
|
||||
|
||||
useResumeStore.setState({ resume });
|
||||
useResumeStore.temporal.getState().clear();
|
||||
|
||||
return { resume, loading, error };
|
||||
};
|
||||
|
||||
@ -7,7 +7,9 @@ import { axios } from "@/client/libs/axios";
|
||||
import { useAuthStore } from "@/client/stores/auth";
|
||||
|
||||
export const fetchUser = async () => {
|
||||
const response = await axios.get<UserDto, AxiosResponse<UserDto>>("/user/me");
|
||||
const response = await axios.get<UserDto | undefined, AxiosResponse<UserDto | undefined>>(
|
||||
"/user/me",
|
||||
);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
@ -25,7 +27,7 @@ export const useUser = () => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setUser(user ? user : null);
|
||||
setUser(user ?? null);
|
||||
}, [user, setUser]);
|
||||
|
||||
return { user: user, loading, error };
|
||||
|
||||
Reference in New Issue
Block a user