Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(116):user-dashboard-password-settings (completed password update… #350

Merged
merged 1 commit into from
Jul 22, 2024
Merged
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
36 changes: 24 additions & 12 deletions app/components/dashboard/PasswordUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ const PasswordUpdate = () => {
handlePasswordValidation(actualValue[value_]);
}
};
const isFormValid = () => {
return (
actualValue.currentPassword.length >= 5 &&
validation.hasUppercase &&
validation.hasNumber &&
validation.hasMinLength &&
actualValue.newPassword === actualValue.confirmPassword
);
};
const handleClick = () => {
setActualValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
setDisplayValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
};
useEffect(() => {
const inputs = document.querySelectorAll<HTMLInputElement>(".psw-input");
for (const element of inputs) {
Expand Down Expand Up @@ -263,6 +284,7 @@ const PasswordUpdate = () => {
<Button
type="submit"
variant="outline"
onClick={handleClick}
size="default"
className="h-12 w-24 rounded-lg bg-transparent text-base font-bold text-black"
>
Expand All @@ -271,20 +293,10 @@ const PasswordUpdate = () => {
<AlertDialogTrigger asChild>
<Button
type="submit"
onClick={() => {
setActualValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
setDisplayValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
}}
onClick={handleClick}
variant="default"
size="default"
disabled={!isFormValid()}
className="h-12 w-44 rounded-lg bg-[rgba(249,115,22,1)] text-base font-bold text-white"
>
Update Password
Expand Down
6 changes: 5 additions & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Outlet,
Scripts,
ScrollRestoration,
useLocation,
} from "@remix-run/react";
import type { ReactNode } from "react";

Expand All @@ -19,6 +20,9 @@ export const links: LinksFunction = () => [
];

export function Layout({ children }: { children: ReactNode }) {
const location = useLocation();
const pagesWithNoFooter = ["/dashboard/password-settings"];
const showFooter = !pagesWithNoFooter.includes(location.pathname);
return (
<html lang="en">
<head>
Expand All @@ -32,7 +36,7 @@ export function Layout({ children }: { children: ReactNode }) {
<main>
<Header />
{children}
<FooterLight />
{showFooter && <FooterLight />}
</main>
<ScrollRestoration />
<Scripts />
Expand Down
2 changes: 0 additions & 2 deletions app/routes/dashboard.password-settings/route.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import PasswordUpdate from "~/components/dashboard/PasswordUpdate";
import { AdminSideNavBar } from "~/components/SuperAdminSideBar/SuperAdminSideNavBar";
import Header from "~/components/ui/header";

const DaashboardPasswordSettings = () => {
return (
<>
<Header />
<div className="flex">
<AdminSideNavBar />
<PasswordUpdate />
Expand Down