All files / pages HomePage.js

100% Statements 12/12
100% Branches 6/6
100% Functions 2/2
100% Lines 10/10

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56        1x                                         26x   26x 26x 26x 16x 4x     26x 26x   26x                                    
import React from "react";
import { useCurrentUser } from "main/utils/currentUser"; 
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
 
const styles = {
    greeting: {
        fontSize: "75px",
        borderRadius: "7px",
        backgroundColor: "white",
        opacity: ".9",
        padding: "10px",
        textAlign: "center",
        margin: "3rem 0",
    },
    infoSection: {
        padding: "20px",
        borderRadius: "7px",
        margin: "20px 0",
    },
    main: {
        padding: "15px",
    }
};
 
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();
    const username = currentUser.loggedIn ? currentUser.root.user.githubLogin : "Please Sign In First to Proceed";
 
    return (
        <BasicLayout>
            <div data-testid="homePage-main-div" style={styles.main}>
                <h1 
                    data-testid="homePage-title" 
                    style={styles.greeting}
                >
                    {greeting}, {username}
                </h1>
                
                <h2 data-testid="homePage-info" style={styles.infoSection}>
                    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>
                
            </div>
        </BasicLayout>
    );
}