-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from ChangePlusPlusVandy/feature/simple-settin…
…gs-page feature/simple-settings-with-profile-and-sign-out
- Loading branch information
Showing
6 changed files
with
107 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { signOut } from 'next-auth/react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { QueriedUserData } from 'bookem-shared/src/types/database'; | ||
import UserProfile from './UserProfile'; | ||
import { DashboardContainer } from '@/styles/volunteerDashboard.styles'; | ||
import { CenteringContainer } from '@/styles/settings.style'; | ||
import { Button } from 'antd'; | ||
import { LogoutOutlined } from '@ant-design/icons'; | ||
|
||
export default function SettingsDashboard() { | ||
const [userData, setUserData] = useState<QueriedUserData | null>(null); | ||
|
||
useEffect(() => { | ||
// fetch user data | ||
const fetchUserData = async () => { | ||
const res = await fetch('/api/users'); | ||
const data = await res.json(); | ||
setUserData(data); | ||
|
||
console.log(data); | ||
}; | ||
fetchUserData(); | ||
}, []); | ||
|
||
if (!userData) return <div>Loading...</div>; | ||
|
||
return ( | ||
<DashboardContainer> | ||
<CenteringContainer> | ||
<UserProfile user={userData} /> | ||
|
||
<Button | ||
style={{ | ||
marginTop: '20px', | ||
// make it larger | ||
height: '50px', | ||
width: '200px', | ||
fontSize: '20px', | ||
}} | ||
type="primary" | ||
danger | ||
onClick={() => signOut()}> | ||
<LogoutOutlined /> | ||
Sign Out | ||
</Button> | ||
</CenteringContainer> | ||
</DashboardContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { QueriedUserData } from 'bookem-shared/src/types/database'; | ||
import { Card } from 'antd'; | ||
|
||
const renderBackgroundCheckStatus = (backgroundCheck: any) => { | ||
if (backgroundCheck) { | ||
if (backgroundCheck.passed) { | ||
return ( | ||
<> | ||
<p>Background check status: Passed</p> | ||
<p> | ||
Background check expiration date: | ||
{new Date(backgroundCheck.expirationDate).toLocaleDateString()} | ||
</p> | ||
</> | ||
); | ||
} else { | ||
return <p>Background check status: Not pased</p>; | ||
} | ||
} else { | ||
return <p>Background check status: Not available</p>; | ||
} | ||
}; | ||
|
||
export default function UserProfile({ user }: { user: QueriedUserData }) { | ||
const { backgroundCheck } = user; | ||
|
||
return ( | ||
<Card | ||
title="Your Profile" | ||
bordered | ||
style={{ | ||
// make the border more obvious using box-shadow | ||
boxShadow: '0px 0px 10px 0px rgba(0,0,0,0.1)', | ||
}}> | ||
<p>Name: {user.name}</p> | ||
<p>Email: {user.email}</p> | ||
<p>Phone: {user.phone}</p> | ||
{renderBackgroundCheckStatus(backgroundCheck)} | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import styled from 'styled-components'; | ||
|
||
// a container for centering the content | ||
export const CenteringContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
`; |