All files / pages ProfilePage.js

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7

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                  1x   11x 11x   11x 3x       8x                     8x                                      
import React from "react";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import ReactJson from "react-json-view";
import UsersTable from "main/components/Users/UsersTable";
import UserEmailsTable from "main/components/Users/UserEmailsTable";
import { useUsers } from "main/utils/users";
import { useCurrentUser } from "main/utils/currentUser";
import { timestampToDate } from "main/utils/dateUtils";
 
const ProfilePage = () => {
 
    const { data: currUser} = useUsers();
    const { data: currentUser } = useCurrentUser();
 
    if (!currentUser.loggedIn) {
        return (
            <p>Not logged in.</p>
        )
    }
    const displayUser = {
        ...currentUser,
        root: {
          ...currentUser.root,
          user: {
            ...currentUser.root.user,
            lastOnline: timestampToDate(currUser.lastOnline)
          }
        }
      };
 
    return (
        <BasicLayout>
            <h1 className={"mb-3"}>
                User Profile for {currentUser.root.user.githubLogin}
            </h1>
            <UsersTable users={[displayUser.root.user]}/>
            <h2 className={"mt-3 mb-3"}>
                Emails
            </h2>
            <UserEmailsTable emails={currentUser.root.user.emails} />
            <h2 className={"mt-3 mb-3"}>
                Debugging Information
            </h2>
            <ReactJson src={currentUser} />
        </BasicLayout>
    );
};
 
export default ProfilePage;