-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve reset password alert (#583)
* chore: improve reset password alert * chore: implement suggestions * fix: implement suggestions
- Loading branch information
1 parent
ee42771
commit 4d8ac1d
Showing
5 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { useEffect } from "react"; | ||
|
||
interface INotificationProps { | ||
title: string; | ||
onClose: () => void; | ||
} | ||
|
||
const Notification: React.FC<INotificationProps> = ({ title, onClose }) => { | ||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
onClose(); | ||
}, 2500); | ||
|
||
return () => clearTimeout(timer); | ||
}, [onClose]); | ||
|
||
return ( | ||
<div className="fixed right-4 top-0 z-50 h-16 w-72"> | ||
<div className="pointer-events-auto min-w-full overflow-hidden rounded-lg bg-quinary shadow-lg ring-1 ring-black ring-opacity-5 "> | ||
<div className="min-w-full p-4 "> | ||
<div className="flex items-start"> | ||
<div className="flex-shrink-0"></div> | ||
<div className="ml-3 w-0 flex-1 pt-0.5"> | ||
<p className="text-md font-medium text-white">{title}</p> | ||
</div> | ||
<div className="ml-4 flex flex-shrink-0"> | ||
<button | ||
onClick={onClose} | ||
className="inline-flex rounded-md bg-quinary text-white hover:text-primary focus:outline-none" | ||
> | ||
<span className="sr-only">Close</span> | ||
<span className="h-5 w-5">X</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Notification; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./Notification"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState } from "react"; | ||
import { resetPassword } from "@lib/api"; | ||
import Notification from "@components/Notification"; | ||
|
||
export default function ResetPassword(user: any) { | ||
const [showNotification, setShowNotification] = useState(false); | ||
|
||
const onResetPassword = (user: any) => { | ||
resetPassword(user.email) | ||
.then((_) => { | ||
setShowNotification(true); | ||
}) | ||
.catch((_) => { | ||
setShowNotification(false); | ||
}); | ||
}; | ||
|
||
const handleNotificationClose = () => { | ||
setShowNotification(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<button | ||
className="inline-block h-auto pl-6 pb-5 text-quinary underline" | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
onResetPassword(user); | ||
}} | ||
> | ||
Reset Password | ||
</button> | ||
{showNotification && ( | ||
<Notification | ||
title="Password reset email sent" | ||
onClose={handleNotificationClose} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.