Skip to content
Open
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions client/src/pages/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const SignUpNew = () => {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword,setConfirmPassword]=useState("")
const [avatar, setAvatar] = useState(null);
const [avatarError, setAvatarError] = useState(null);

Expand Down Expand Up @@ -75,6 +76,7 @@ const SignUpNew = () => {
formData.append("name", name);
formData.append("email", email);
formData.append("password", password);
formData.append("confirmPassword", confirmPassword);
formData.append("avatar", avatar);
formData.append("role", "general");
formData.append("isConsentGiven", isConsentGiven.toString());
Expand Down Expand Up @@ -261,6 +263,36 @@ const SignUpNew = () => {
autoComplete="off"
/>
</div>

<div className="relative mt-4 flex items-center">
<span className="absolute">
<svg
xmlns="http://www.w3.org/2000/svg"
className="mx-3 h-6 w-6 text-gray-300"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"
/>
</svg>
</span>
<input
id="confirmPassword"
name="confirmPassword"
type="password"
value={confirmPassword}
onChange={(e)=>setConfirmPassword(e.target.value)}
className="block w-full rounded-lg border bg-white px-10 py-3 text-gray-700 focus:border-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-40"
placeholder="Confirm Password"
required
autoComplete="off"
/>
</div>
<div className="mt-6">
<button
disabled={loading}
Expand Down
7 changes: 7 additions & 0 deletions client/src/redux/actions/authActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export const signUpAction =
async (dispatch) => {
try {
localStorage.removeItem("profile");
if(formData.get('password')!==formData.get('confirmPassword')){
dispatch({
type: types.SIGNUP_FAIL,
payload: ["Confirm Password Doesn't Match"]
})
return;
}
const response = await api.signUp(formData);
const { error } = response;
if (error) {
Expand Down