-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/246/create signup login pages #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
26af502
refactor/246: update error handling so that errors no longer show in …
shribakb1 01d0173
feat/246: change user model
shribakb1 a06dc5d
feat/246: add user profile icon
shribakb1 e87bd71
feat/246: add SignUp and Login pages
shribakb1 ffb4426
feat/246: change api port for Auth microservice
shribakb1 740e3a0
feat/246: protect Admin rout, and configure local storage for storing…
shribakb1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
src/app/layout/header/ProfileCircle/ProfileCircle.component.tsx
This file contains hidden or 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,50 @@ | ||
| import './ProfileCircle.styles.scss'; | ||
|
|
||
| import { LogoutOutlined, UserOutlined } from '@ant-design/icons'; | ||
| import { Dropdown } from 'antd'; | ||
| import type { MenuProps } from 'antd'; | ||
| import { observer } from 'mobx-react-lite'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import FRONTEND_ROUTES from '@constants/frontend-routes.constants'; | ||
| import useMobx from '@stores/root-store'; | ||
|
|
||
| const ProfileCircle = () => { | ||
| const navigate = useNavigate(); | ||
| const { userLoginStore } = useMobx(); | ||
|
|
||
| const handleLogout = async () => { | ||
| await userLoginStore.logout(); | ||
| navigate(FRONTEND_ROUTES.BASE); | ||
| }; | ||
|
|
||
| const menuItems: MenuProps['items'] = [ | ||
| { | ||
| key: 'logout', | ||
| icon: <LogoutOutlined />, | ||
| label: 'Вийти', | ||
| onClick: handleLogout, | ||
| }, | ||
| ]; | ||
|
|
||
| if (!userLoginStore.isUserLoggedIn) { | ||
| return ( | ||
| <button | ||
| type="button" | ||
| className="loginButton" | ||
| onClick={() => navigate(FRONTEND_ROUTES.OTHER_PAGES.LOGIN)} | ||
| > | ||
| Вхід | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Dropdown menu={{ items: menuItems }} trigger={['click']} placement="bottomRight"> | ||
| <div className="profileCircle"> | ||
| <UserOutlined className="profileIcon" /> | ||
| </div> | ||
| </Dropdown> | ||
| ); | ||
| }; | ||
|
|
||
| export default observer(ProfileCircle); |
65 changes: 65 additions & 0 deletions
65
src/app/layout/header/ProfileCircle/ProfileCircle.styles.scss
This file contains hidden or 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,65 @@ | ||
| @use "sass:color"; | ||
| @use "@sass/mixins/_utils.mixins.scss" as mut; | ||
|
|
||
| .loginButton { | ||
| width: 77px; | ||
| height: 39px; | ||
| padding: 9px 20px; | ||
| border-radius: 10px; | ||
| border: 2px solid #DB3424; | ||
| background-color: transparent; | ||
| color: #DB3424; | ||
| font-size: 16px; | ||
| font-weight: 500; | ||
| cursor: pointer; | ||
| margin-right: 12px; | ||
| flex-shrink: 0; | ||
|
|
||
| &:hover { | ||
| background-color: #DB3424; | ||
| color: white; | ||
| } | ||
| } | ||
|
|
||
| .profileCircle { | ||
| @include mut.sized(40px, 40px); | ||
| @include mut.flex-centered(); | ||
| @include mut.full-rounded(50%); | ||
|
|
||
| background-color: #F0F3F9; | ||
| margin-right: 30px; | ||
| cursor: pointer; | ||
| flex-shrink: 0; | ||
|
|
||
| .profileIcon { | ||
| font-size: 20px; | ||
| color: #8C8C8C; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| margin-left: 6px; | ||
| } | ||
|
|
||
| &:hover { | ||
| background-color: color.adjust(#F0F3F9, $lightness: -5%); | ||
| } | ||
| } | ||
|
|
||
| @media screen and (max-width: 1024px) { | ||
| .loginButton { | ||
| width: 65px; | ||
| height: 34px; | ||
| padding: 7px 14px; | ||
| font-size: 14px; | ||
| margin-right: 8px; | ||
| } | ||
|
|
||
| .profileCircle { | ||
| @include mut.sized(36px, 36px); | ||
| margin-right: px; | ||
|
|
||
| .profileIcon { | ||
| font-size: 18px; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,23 @@ | ||
| import { observer } from 'mobx-react-lite'; | ||
| import { Navigate, useLocation } from 'react-router-dom'; | ||
|
|
||
| import FRONTEND_ROUTES from '@/app/common/constants/frontend-routes.constants'; | ||
| import useMobx from '@/app/stores/root-store'; | ||
|
|
||
| interface ProtectedRouteProps { | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => { | ||
| const { userLoginStore } = useMobx(); | ||
| const location = useLocation(); | ||
|
|
||
| if (!userLoginStore.isUserLoggedIn) { | ||
| // Redirect to login page, saving the attempted URL | ||
| return <Navigate to={FRONTEND_ROUTES.OTHER_PAGES.LOGIN} state={{ from: location }} replace />; | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| }; | ||
|
|
||
| export default observer(ProtectedRoute); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.