Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EE-87 fix: register logic. #90

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/frontend/src/modules/Auth/views/CheckEmailButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ interface CheckEmailButtonProps {
export default function CheckEmailButton({ isCheck, onChange }: CheckEmailButtonProps) {
const methods = useFormContext();
const toast = useToast();
const email = methods.getValues('email') as string;

const mutation = useMutation({
mutationFn: checkEmail,
onSuccess: ({ isExisting }) => {
onChange(isExisting);
if (!isExisting) {
onChange(!isExisting);
if (isExisting) {
Comment on lines +17 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逻辑错误:当电子邮件存在时,不应显示错误消息。

-      if (isExisting) {
-        toast.error('The email address is not registered. Please check the email address again.');
+      if (!isExisting) {
+        toast.error('The email address is not registered. Please check the email address again.');

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
onChange(!isExisting);
if (isExisting) {
onChange(!isExisting);
if (!isExisting) {
toast.error('The email address is not registered. Please check the email address again.');

toast.error('The email address is not registered. Please check the email address again.');
}
},
});

return (
<EzIconButton
className={isCheck ? 'text-green-500' : ''}
name={isCheck ? 'CheckCircleOutline' : 'LiveHelp'}
onClick={() => {
const email = methods.getValues('email') as string;
mutation.mutateAsync({ email });
}}
/>
Expand Down
Loading