Skip to content

Commit 0ff3376

Browse files
committed
Fix profile pages
1 parent e4f3fb5 commit 0ff3376

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

deploy/docker/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ services:
155155
image: crapi/crapi-web:${VERSION:-latest}
156156
ports:
157157
- "${LISTEN_IP:-127.0.0.1}:8888:80"
158+
- "${LISTEN_IP:-127.0.0.1}:30080:80"
158159
- "${LISTEN_IP:-127.0.0.1}:8443:443"
160+
- "${LISTEN_IP:-127.0.0.1}:30443:443"
159161
environment:
160162
- COMMUNITY_SERVICE=crapi-community:${COMMUNITY_SERVER_PORT:-8087}
161163
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}

postman_collections/crAPI.postman_environment.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"name": "Crapi",
44
"values": [{
55
"key": "url",
6-
"value": "http://127.0.0.1:8888",
6+
"value": "http://127.0.0.1:30080",
77
"enabled": true
88
},
99
{
1010
"key": "url_mail",
11-
"value": "http://127.0.0.1:8025",
11+
"value": "http://127.0.0.1:30080/mailhog",
1212
"enabled": true
1313
}
1414
],

services/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "crapi-web",
33
"version": "0.1.0",
4-
"proxy": "http://localhost:8888",
4+
"proxy": "http://localhost:30080",
55
"private": true,
66
"dependencies": {
77
"@ant-design/cssinjs": "^1.21.1",

services/web/src/components/navBar/navBar.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
import "./nav.css";
1717

1818
import { Button, Dropdown, Menu, Avatar, Layout, Space } from "antd";
19-
import { LogoutOutlined, DownOutlined } from "@ant-design/icons";
19+
import { LogoutOutlined, EditOutlined, ProfileOutlined, CaretDownOutlined } from "@ant-design/icons";
2020
import React from "react";
21+
import roleTypes from "../../constants/roleTypes";
22+
import type { MenuProps } from 'antd';
2123
import { useNavigate } from "react-router-dom";
2224
import { connect, ConnectedProps } from "react-redux";
2325
import { logOutUserAction } from "../../actions/userActions";
@@ -30,6 +32,7 @@ interface RootState {
3032
accessToken: string;
3133
name: string;
3234
isLoggedIn: boolean;
35+
role: string;
3336
};
3437
profileReducer: {
3538
profilePicData: string;
@@ -48,7 +51,7 @@ interface NavbarProps extends PropsFromRedux {}
4851
* dropdown alos consists the logout button
4952
*/
5053
const Navbar: React.FC<NavbarProps> = (props) => {
51-
const { logOutUser, isLoggedIn, name, profilePicData } = props;
54+
const { logOutUser, isLoggedIn, name, role, profilePicData } = props;
5255
const navigate = useNavigate();
5356

5457
const logout = () => {
@@ -59,39 +62,36 @@ const Navbar: React.FC<NavbarProps> = (props) => {
5962
});
6063
};
6164

62-
const takeMenuAction = (input: { key: string }) => {
63-
if (input.key === "password") navigate(`/reset-password`);
64-
else if (input.key === "profile") navigate(`/my-profile`);
65-
else if (input.key === "logout") logout();
66-
};
67-
68-
const menuSidebar = () => (
69-
<Menu onClick={(key) => takeMenuAction(key)}>
70-
<Menu.Item key="password">Change Password</Menu.Item>
71-
<Menu.Item key="logout">
72-
<LogoutOutlined /> Logout
73-
</Menu.Item>
74-
</Menu>
75-
);
76-
7765
const takeNavigationAction = (input: { key: string }) => {
7866
if (input.key === "dashboard") navigate(`/`);
7967
else if (input.key === "shop") navigate(`/shop`);
8068
else if (input.key === "forum") navigate(`/forum`);
8169
};
8270

71+
type MenuItem = Required<MenuProps>['items'][number];
72+
73+
const menuitems: MenuItem[] = []
74+
menuitems.push({ key: "dashboard", label: "Dashboard" });
75+
if (role !== roleTypes.ROLE_MECHANIC) {
76+
menuitems.push({ key: "shop", label: "Shop" });
77+
menuitems.push({ key: "forum", label: "Community" });
78+
}
79+
8380
const menuNavigation = () => (
8481
<Menu
8582
onClick={(key) => takeNavigationAction(key)}
8683
mode="horizontal"
8784
theme="dark"
88-
>
89-
<Menu.Item key="dashboard">Dashboard</Menu.Item>
90-
<Menu.Item key="shop">Shop</Menu.Item>
91-
<Menu.Item key="forum">Community</Menu.Item>
92-
</Menu>
85+
items={menuitems}
86+
/>
9387
);
9488

89+
const sideMenuItems: MenuProps['items'] = [
90+
{ key: "profile", label: "My Profile", onClick: () => navigate("/my-profile"), icon: <ProfileOutlined /> },
91+
{ key: "password", label: "Change Password", onClick: () => navigate("/reset-password"), icon: <EditOutlined /> },
92+
{ key: "logout", label: "Logout", onClick: logout, icon: <LogoutOutlined /> },
93+
]
94+
9595
return (
9696
<Header>
9797
<Space className="top-nav-left">
@@ -111,9 +111,9 @@ const Navbar: React.FC<NavbarProps> = (props) => {
111111
onClick={() => navigate("/my-profile")}
112112
/>
113113
</div>
114-
<Dropdown overlay={menuSidebar()} placement="bottomRight">
114+
<Dropdown menu={{ items: sideMenuItems }} placement="bottomRight">
115115
<div className="nav-items">
116-
<DownOutlined />
116+
<CaretDownOutlined />
117117
</div>
118118
</Dropdown>
119119
</Space>
@@ -146,6 +146,7 @@ const mapStateToProps = (state: RootState) => ({
146146
name: state.userReducer.name,
147147
isLoggedIn: state.userReducer.isLoggedIn,
148148
profilePicData: state.profileReducer.profilePicData,
149+
role: state.userReducer.role,
149150
});
150151

151152
const mapDispatchToProps = {

0 commit comments

Comments
 (0)