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
40 changes: 5 additions & 35 deletions src/app/HomeClient/HomeClient.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import { cn } from "@/lib/utils"
import { Eye, EyeOff } from "lucide-react"
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import {
Alert,
AlertTitle,
AlertDescription,
} from '@/components/ui/alert';
import { useNotification } from "@/hooks/use-notification";
import {
Card,
CardHeader,
Expand All @@ -48,10 +44,9 @@ export default function HomeClient() {
const router = useRouter();
const searchParams = useSearchParams();

const { error, success } = useNotification();
const [values, setValues] = useState({ username: '', password: '' });
const [loading, setLoading] = useState(false);
const [showError, setShowError] = useState(false);
const [errorMessage, setErrorMessage] = useState(null);

const { username, password } = values;

Expand All @@ -66,19 +61,18 @@ export default function HomeClient() {
await fetchToken(values);
await getUserSelf();
await fetchAllGroups();
success("Logged in successfully!");
router.push(routes.browse);
} catch (err) {
setLoading(false);
setErrorMessage(err.message);
setShowError(true);
error(err.message);
}
};

useEffect(() => {
const message = searchParams.get('message');
if (message) {
setErrorMessage(message);
setShowError(true);
error(message);
router.replace(window.location.pathname);
}
}, [searchParams, router]);
Expand Down Expand Up @@ -136,30 +130,6 @@ export default function HomeClient() {
</CardHeader>

<CardContent className="p-0 pt-2 space-y-6">
{showError && (
<div className="mb-4">
<Alert
variant="destructive"
className="flex items-start gap-3 bg-[#FFEBEE] rounded-[4px] border-0"
>
<img
src="/assets/icons/Alert/ErrorFilled.svg"
alt="Error"
width={24}
height={24}
className="mt-1"
/>
<div>
<AlertTitle className="text-base font-semibold text-[#A41411]">
An error occurred
</AlertTitle>
<AlertDescription className="text-sm text-[#A41411]">
{errorMessage}
</AlertDescription>
</div>
</Alert>
</div>
)}
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label htmlFor="username" className="block text-base font-normal text-[#101010] mb-1">
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { GlobalProvider } from "@/context";

import Header from "@/components/Header/Header";
import Footer from "@/components/Footer/Footer";
import { Toaster } from "@/components/ui/sonner";

// Global CSS
import "react-virtualized-tree/lib/main.css";
Expand All @@ -44,6 +45,7 @@ export default function RootLayout({ children }) {
<Header />
<main className="flex-grow px-page">{children}</main>
<Footer />
<Toaster />
</GlobalProvider>
</body>
</html>
Expand Down
Loading