From 371354fd5a88910edb7e5771bd3894410805a5e5 Mon Sep 17 00:00:00 2001 From: Dinys Date: Fri, 6 Nov 2020 20:08:40 +1100 Subject: [PATCH 1/3] Add help coins balance for a user, add help coins when task completed --- react-app/src/App.js | 2 +- react-app/src/components/CardAvatar.js | 4 ++-- react-app/src/components/task-grid/TaskGrid.js | 16 +++++++++++++++- react-app/src/domain/User.js | 5 +++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/react-app/src/App.js b/react-app/src/App.js index 892836b..49c8c9d 100644 --- a/react-app/src/App.js +++ b/react-app/src/App.js @@ -18,7 +18,7 @@ function App() { return ( - + {userLoggedIn ? ( diff --git a/react-app/src/components/CardAvatar.js b/react-app/src/components/CardAvatar.js index e98856a..297b869 100644 --- a/react-app/src/components/CardAvatar.js +++ b/react-app/src/components/CardAvatar.js @@ -2,14 +2,14 @@ import React from 'react' import SignOutIcon from '../assets/sign-out.svg' function CardAvatar({ user, onSignOut }) { - const {name, image} = user + const {name, image, coins} = user return (
{`${name}
Hello, {name}!
- +
+
+
+ +
+
+
+ + +
+ +
+
+
+ + ) +} + +export default PasswordAvatar \ No newline at end of file diff --git a/react-app/src/index.css b/react-app/src/index.css index b17fcbc..5d1c869 100644 --- a/react-app/src/index.css +++ b/react-app/src/index.css @@ -233,6 +233,77 @@ body { color: #555555; } +/* Password Avatar */ +.password-avatar-container { + position: relative; + display: flex; + justify-content: center; + align-items: center; +} + +.default-btn { + padding: 0; + border: 0; + background: none; +} + +.back-arrow-btn { + position: absolute; + top: 0; + left: 0; + margin-top: -3.5rem; + margin-left: -1rem; + cursor: pointer; +} + +.password-form { + margin-top: 1rem; +} + +.textbox { + width: 16rem; + height: 2.25rem; + border: 2px solid #555555; +} + +.password-textbox { + padding: 0 1rem; + padding-right: 2rem; + letter-spacing: 0.2em; + font-size: 0.75rem; +} + +.sign-in-container { + display: flex; + align-items: center; + margin-top: 3rem; +} + +.sign-in-container .btn{ + margin-left: 1rem; +} + +.password-textbox-container { + position: relative; +} + +.show-password-btn { + position: absolute; + right: 0; + top: 0; + margin-top: 0.75rem; + margin-right: 0.5rem; + opacity: 0.6; +} + +.show-password-btn:hover { + opacity: 1; +} + +.show-password-btn .visible { + opacity: 1; +} + /* Sidebar */ .sidebar { @@ -274,14 +345,17 @@ body { font-weight: 300; } -.help-point-btn { - margin-top: 0.25rem; - padding: 0.5rem 0.5rem; - color: white; +.btn { + height: 2.25rem; font-size: inherit; - font-weight: 600; background-color: #FF8933; border: none; + color: white; +} + +.help-point-btn { + margin-top: 0.25rem; + font-weight: 600; } .leave-btn { diff --git a/react-app/src/pages/LoginPage.js b/react-app/src/pages/LoginPage.js index fd309d4..9a43cc1 100644 --- a/react-app/src/pages/LoginPage.js +++ b/react-app/src/pages/LoginPage.js @@ -4,11 +4,13 @@ import { createUser, ADMIN_USER } from '../domain/User' import RoundedAvatar from '../components/RoundedAvatar' import LoadingAnimation from '../components/LoadingAnimation' import firebase from 'firebase' +import PasswordAvatar from '../components/PasswordAvatar'; function LoginPage({ logUserIn }) { const history = useHistory() const [users, setUsers] = useState([]) const [isLoading, setIsLoading] = useState(true) + const [adminUser, setAdminUser] = useState(null) useEffect(() => { function fetchUsers() { @@ -29,10 +31,14 @@ function LoginPage({ logUserIn }) { function onAvatarImgClick(user) { if (user.role === ADMIN_USER) { - history.push('/secure-login') + setAdminUser(user) } else { - history.replace('/') + logUser(user) } + } + + function logUser(user) { + history.replace('/') logUserIn(user) } @@ -42,10 +48,14 @@ function LoginPage({ logUserIn }) { {isLoading ? ( ): ( -
- {users && users.map((user) => - ( onAvatarImgClick(user)}/>))} -
+ (adminUser) ? ( + setAdminUser(null)}/> + ) : ( +
+ {users && users.map((user) => + ( onAvatarImgClick(user)}/>))} +
+ ) )}