Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

chore: improve reset password alert #583

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions components/ResetPassword/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { resetPassword } from "@lib/api";
import Swal from "sweetalert2";

const onResetPassword = (user: any) => {
resetPassword(user.email)
.then((_) =>
Swal.fire({
icon: "success",
title: "Password Reset",
text: "An email has been sent to your account for you to recover your password!",
})
)
.catch((_) => {
Swal.fire({
icon: "error",
title: "Oops...",
text: "Something went wrong!",
});
});
};

export default function ResetPassword(user) {
return (
<button
className="inline-block h-auto pl-6 pb-5 text-quinary underline"
onClick={(e) => {
e.preventDefault();
onResetPassword(user);
}}
>
Reset Password
</button>
);
}
21 changes: 2 additions & 19 deletions layout/Attendee/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Input from "@components/Input";

import Layout from "@components/Layout";
import Heading from "@components/Heading";
import ResetPassword from "@components/ResetPassword";

import { CheckpointTracker, CodeInput } from "./components";
import CVInput from "./components/CVInput";
Expand Down Expand Up @@ -46,16 +47,6 @@ function Profile() {

const levelEntries = [10, 30, 60, 100, 150];

const onResetPassword = () => {
resetPassword(user.email)
.then((_) =>
alert(
"An email has been sent to your account for you to recover your password"
)
)
.catch((_) => alert("An error occured"));
};

const handleSubmitForm = (e: React.FormEvent) => {
e.preventDefault();
const formData = new FormData();
Expand Down Expand Up @@ -152,15 +143,7 @@ function Profile() {
onChange={(e) => setUsername(e.currentTarget.value)}
/>

<button
className="inline-block h-auto pl-6 pb-5 text-quinary underline"
onClick={(e) => {
e.preventDefault();
onResetPassword();
}}
>
Reset Password
</button>
<ResetPassword user={user} />
</Form>
</div>

Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"react-map-gl": "^6.1.17",
"react-p5": "^1.3.21",
"sharp": "^0.30.0",
"sweetalert2": "^11.10.1",
"typewriter-effect": "^2.21.0"
},
"devDependencies": {
Expand Down