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              26x   26x 26x 26x 18x 4x     26x 26x   26x                          
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 timeOfDay = getPartOfDayGreeting();
    const greeting = (!currentUser || !currentUser.loggedIn) ? timeOfDay : timeOfDay + ", " + currentUser.root.user.githubLogin;
 
    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}
                </h1>
                <h2 data-testid="info" style={{ fontSize: "12px", borderRadius: "7px", backgroundColor: "white", opacity: ".9" }} className="text-center border-0 my-3">
                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>
    );
}