source: frontend/src/pages/LandingPage/components/Hero.jsx@ 3ebe47c

Last change on this file since 3ebe47c was 3ebe47c, checked in by Andrej <asumanovski@…>, 5 months ago

Made authentication on frontend and backend

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import React, { useEffect, useState } from "react";
2import { Link } from "react-router-dom";
3
4const Hero = () => {
5 const [isAuthed, setIsAuthed] = useState(() =>
6 Boolean(localStorage.getItem("authToken")),
7 );
8
9 useEffect(() => {
10 const onStorage = (e) => {
11 if (e.key === "authToken") {
12 setIsAuthed(Boolean(e.newValue));
13 }
14 };
15 window.addEventListener("storage", onStorage);
16 return () => window.removeEventListener("storage", onStorage);
17 }, []);
18
19 return (
20 <div
21 className="hero min-h-screen"
22 style={{
23 backgroundImage:
24 "url(https://images.unsplash.com/photo-1551288049-bebda4e38f71?auto=format&fit=crop&w=1920&q=80)",
25 }}
26 >
27 <div className="hero-overlay"></div>
28 <div className="hero-content text-neutral-content text-center">
29 <div className="max-w-md">
30 <h1 className="mb-5 text-5xl font-bold">
31 Trekr — track progress, every day
32 </h1>
33 <p className="mb-5">
34 One self-improvement hub: workouts, weight & nutrition, finances &
35 budgeting, investing, and daily discipline tasks. Set goals, log
36 consistently, and see your progress in one place.
37 </p>
38 <Link
39 className="btn btn-primary"
40 to={isAuthed ? "/dashboard" : "/register"}
41 >
42 {isAuthed ? "Go to dashboard" : "Get started"}
43 </Link>
44 </div>
45 </div>
46 </div>
47 );
48};
49
50export default Hero;
Note: See TracBrowser for help on using the repository browser.