Added password changing confirmation
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { apiCall, validatePassword as validatePassword } from "@/lib";
|
import { apiCall, validatePassword as validatePassword } from "@/lib";
|
||||||
import {
|
import {
|
||||||
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
CardBody,
|
CardBody,
|
||||||
@@ -14,6 +15,8 @@ import { FormEvent, useState } from "react";
|
|||||||
|
|
||||||
export default function Account() {
|
export default function Account() {
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
|
const [showSuccess, setShowSuccess] = useState(false);
|
||||||
|
|
||||||
const errors = validatePassword(password);
|
const errors = validatePassword(password);
|
||||||
|
|
||||||
async function changePassword(e: FormEvent<HTMLFormElement>) {
|
async function changePassword(e: FormEvent<HTMLFormElement>) {
|
||||||
@@ -23,6 +26,7 @@ export default function Account() {
|
|||||||
|
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
setPassword("");
|
setPassword("");
|
||||||
|
setShowSuccess(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +46,10 @@ export default function Account() {
|
|||||||
changePassword(e);
|
changePassword(e);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CardBody>
|
<CardBody className="flex flex-col gap-2">
|
||||||
<Input
|
<Input
|
||||||
isRequired
|
isRequired
|
||||||
label="Password"
|
label="New password"
|
||||||
name="password"
|
name="password"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
value={password}
|
value={password}
|
||||||
@@ -59,6 +63,16 @@ export default function Account() {
|
|||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<Alert
|
||||||
|
hideIconWrapper
|
||||||
|
isVisible={showSuccess}
|
||||||
|
onClose={() => setShowSuccess(false)}
|
||||||
|
title="Success"
|
||||||
|
color="success"
|
||||||
|
variant="faded"
|
||||||
|
>
|
||||||
|
Password changed successfully
|
||||||
|
</Alert>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user