All files / pages HomePage.js

100% Statements 11/11
100% Branches 8/8
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34          24x   24x 24x 24x 20x 12x     24x       24x   24x                          
import React from "react";
import { useCurrentUser } from "main/utils/currentUser";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
 
export default function HomePage() {
    const { data: currentUser } = useCurrentUser();
 
    const getPartOfDayGreeting = () => {
        const hour = new Date().getHours();
        if (hour < 12) return "Good morning";
        if (hour < 18) return "Good afternoon";
        return "Good evening";
    };
 
    const greeting = getPartOfDayGreeting();
 
 
    // Determine the username to display based on currentUser status
    const username = currentUser && currentUser.loggedIn ? currentUser.root.user.githubLogin: "Please Sign in to Proceed";
 
    return (
        <div data-testid={"HomePage-main-div"}>
            <BasicLayout>
                <h1 data-testid="homePage-title" style={{ fontSize: "75px", borderRadius: "7px", backgroundColor: "white", opacity: ".9" }} className="text-center border-0 my-3">
                    {greeting}, {username}
                </h1>
                <h2 data-testid="homePage-info">
                    This app is intended as a replacement for the <a href="https://ucsb-cs-github-linker.herokuapp.com">ucsb-cs-github-linker</a> app used in many courses at UCSB, as well as some courses at other universities.
                </h2>
            </BasicLayout>
        </div>
    );
}