Skip to content

Commit 65cd127

Browse files
committed
bug fix in forms inside of dialog not submitting
1 parent 3319a4b commit 65cd127

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed

server/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ MAILGUN_USER_NAME=
1212
MAILGUN_PASSWORD=
1313
SMTP_PROVIDER=
1414
CONFIRMATION_LINK=
15-
CHANGE_PASSWORD_LINK=
15+
CHANGE_PASSWORD_LINK=
16+
ALLOWED_DOMAIN=

server/src/common/emailer/emailer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl EmailerSendService for Emailer {
105105
match mailer.send(&email) {
106106
Ok(_) => Ok(()),
107107
Err(e) => {
108-
println!("{}", e);
108+
error!("{}", e);
109109
Err(EmailError::EmailConfirmationSendFailed)
110110
}
111111
}

server/src/common/repository/developers/repo.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ mod internal {
288288
entity,
289289
unique_key: uuid
290290
}),
291-
Err(e) => Err(e.into())
291+
Err(e) => {
292+
error!("Send email confirm error: {}", e);
293+
Err(e.into())
294+
}
292295
}
293296
},
294297
Err(e) => Err(e)

webclient/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ dist-ssr
2323
*.sln
2424
*.sw?
2525

26-
ssl
26+
ssl
27+
.env

webclient/src/presentation/components/authentication/ChangePassword.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeEvent, FormEvent, useState } from "react";
1+
import { ChangeEvent, MouseEvent, useState } from "react";
22
import { ValidationMsgView } from "../controls/ValidationMsgView";
33
import { changePassword } from "../../../domain/repository/UserRepo";
44
import { useProfile } from "../../common/redux/profile/ProfileHooks";
@@ -28,7 +28,7 @@ export function ChangePassword({ userType }: ChangePasswordProps) {
2828
setNewPassword(e.target.value);
2929
};
3030

31-
const onSubmitChangePassword = async (e: FormEvent<HTMLFormElement>) => {
31+
const onSubmitChangePassword = async (e: MouseEvent<HTMLButtonElement>) => {
3232
e.preventDefault();
3333

3434
if (!profile || !profile.accessToken) {
@@ -72,7 +72,7 @@ export function ChangePassword({ userType }: ChangePasswordProps) {
7272
};
7373

7474
return (
75-
<form className="login-form" onSubmit={onSubmitChangePassword}>
75+
<form className="login-form">
7676
<div style={{ padding: "2em", width: "100%" }}>
7777
<section className="form-section">
7878
<span>Current Password</span>
@@ -100,7 +100,11 @@ export function ChangePassword({ userType }: ChangePasswordProps) {
100100
className="form-section"
101101
style={{ marginTop: "1.5em", justifyContent: "flex-end" }}
102102
>
103-
<PrimaryButton type="submit" disabled={disableSubmit}>
103+
<PrimaryButton
104+
type="submit"
105+
disabled={disableSubmit}
106+
onClick={onSubmitChangePassword}
107+
>
104108
change
105109
</PrimaryButton>
106110
</section>

webclient/src/presentation/components/authentication/Profile/ProfileForm.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeEvent, FormEvent, useEffect, useRef, useState } from "react";
1+
import { ChangeEvent, MouseEvent, useEffect, useRef, useState } from "react";
22
import { UiDevOrEmployer } from "../../../models/DevOrEmployer";
33
import DropDown, { OptionType } from "../../controls/DropDown";
44
import { getLanguages } from "../../../../domain/repository/LanguageRepo";
@@ -60,6 +60,7 @@ interface ProfileFormProps {
6060
}
6161

6262
/// form to register or edit profile
63+
/// note: form's onSubmit does not work inside a <dialog>
6364
export function ProfileForm({
6465
isModalMode,
6566
editMode,
@@ -173,7 +174,7 @@ export function ProfileForm({
173174
// Add more custom styles for other parts
174175
};
175176

176-
const createOrEditProfile = async (e: FormEvent<HTMLFormElement>) => {
177+
const createOrEditProfile = async (e: MouseEvent<HTMLButtonElement>) => {
177178
e.preventDefault();
178179

179180
if (!isValidProfile()) return;
@@ -544,7 +545,7 @@ export function ProfileForm({
544545

545546
return (
546547
<div style={{ width: "100%" }}>
547-
<form className="login-form" onSubmit={createOrEditProfile}>
548+
<form className="login-form">
548549
{isModalMode ? (
549550
<div className="login-item">
550551
<span className="title-font">Welcome to SyntaxMakers</span>
@@ -718,8 +719,12 @@ export function ProfileForm({
718719
className="form-section"
719720
style={{ marginTop: "1.5em", justifyContent: "flex-end" }}
720721
>
721-
<PrimaryButton type="submit" disabled={disableSubmit}>
722-
{editMode === ProfileFormEditMode.Edit ? "edit" : "create"}
722+
<PrimaryButton
723+
type="submit"
724+
disabled={disableSubmit}
725+
onClick={createOrEditProfile}
726+
>
727+
{editMode === ProfileFormEditMode.Edit ? "Edit" : "Create"}
723728
</PrimaryButton>
724729
</section>
725730
<section className="form-section" style={{ marginTop: "1em" }}>

webclient/src/presentation/components/authentication/login/Login.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function LoginView({ toggleOpen, toggleIsLogin }: LoginViewProps) {
7575
setProfile(profile);
7676
toggleOpen();
7777
});
78+
toggleOpen();
7879
} else {
7980
setProfile(null);
8081
setErrorMessage(`Failed to find user with email ${email}`);
@@ -161,10 +162,15 @@ function LoginView({ toggleOpen, toggleIsLogin }: LoginViewProps) {
161162
</button>
162163
</div>
163164
<div className="login-item" style={{ alignItems: "flex-end" }}>
164-
<PrimaryButton onClick={onClickLogin}>Login</PrimaryButton>
165+
<PrimaryButton type="submit" onClick={onClickLogin}>
166+
Login
167+
</PrimaryButton>
165168
</div>
166169
<div className="login-item">
167-
<span>{errorMessage}</span>
170+
<ValidationMsgView
171+
successMessage={""}
172+
validationMessage={errorMessage}
173+
/>
168174
</div>
169175
</div>
170176
);

0 commit comments

Comments
 (0)