Skip to content

Commit

Permalink
Services routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonbelete committed Dec 24, 2020
1 parent 713a0a8 commit db41b41
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 8 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"apexcharts": "^3.23.0",
"ol": "^6.4.3",
"react": "^16.13.1",
"react-async": "^10.0.1",
"react-chat-elements": "^10.13.0",
"react-dom": "^16.13.1",
"react-ionicons-icon": "^0.1.1",
"react-router-dom": "^5.2.0",
"react-router-i18n": "^1.0.0",
"react-scripts": "3.4.1",
"react-table": "^7.6.2",
"socket.io-client": "^2.2.0",
"universal-cookie": "^4.0.4"
},
"devDependencies": {
Expand Down
30 changes: 28 additions & 2 deletions src/I18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,27 @@ const translations = {
'users': 'Users',
'email': 'Email',
'name': 'Name',
'name_en': 'Name/EN',
'name_am': 'Name/AM',
'phone_number': 'Phone Number',
'role': 'Role',
'status': 'Status',
'date': 'Date',
'blocked': 'Blocked',
'active': 'Active',
'account': 'Account',
'identity': 'Identity'
'identity': 'Identity',
'chat': 'Chat',
'customer_support': 'Custommer Support',
'online': 'Online',
'ofline': 'Ofline',
'branches': 'Branches',
'open': 'Open',
'closed': 'Closed',
'company': 'Company',
'branches_list': 'Branches List',
'tracking': 'Tracking',
'vehicle_tracking': 'Vehicle Tracking'
},
am: {
app: appAm,
Expand All @@ -53,14 +66,27 @@ const translations = {
'users': 'ተጠቃሚዎች',
'email': 'ኢሜል',
'name': 'ስም',
'name_en': 'Name/EN',
'name_am': 'Name/AM',
'phone_number': 'ስልክ ቁጥር',
'role': 'ሚና',
'status': 'ሁኔታ',
'date': 'ቀን',
'blocked': 'ታግዷል',
'active': 'ክፈት',
'account': 'መለያ',
'identity': 'መለያ'
'identity': 'መለያ',
'chat': 'ቻት',
'customer_support': 'የደንበኛ ድጋፍ',
'online': 'Online',
'ofline': 'Ofline',
'branches': 'Branches',
'open': 'Open',
'closed': 'Closed',
'company': 'Company',
'branches_list': 'Branches List',
'tracking': 'Tracking',
'vehicle_tracking': 'Vehicle Tracking'
}
}

Expand Down
26 changes: 24 additions & 2 deletions src/pages/home/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
AnalyticsOutline,
Search as SearchIcon,
ChatboxEllipsesOutline,
PeopleOutline
PeopleOutline,
ChatbubblesOutline,
StorefrontOutline,
MapOutline
}from 'react-ionicons-icon';

import Authorization from 'hocs/Authorization';
Expand Down Expand Up @@ -124,10 +127,28 @@ const Index = (props) => {
</RouterNavLink>
<br />
<br />
<RouterNavLink to={'/' + locale + '/home/chat'} activeClassName="active" className={route_location == '/home/reviews' ? "link link--sm theme-royal-blue active" : "link link--sm theme-royal-blue"}>
<span><ChatbubblesOutline size="20px" /></span>
<I18n t="chat" />
</RouterNavLink>
<br />
<br />
<RouterNavLink to={'/' + locale + '/home/reviews'} activeClassName="active" className={route_location == '/home/reviews' ? "link link--sm theme-royal-blue active" : "link link--sm theme-royal-blue"}>
<span><ChatboxEllipsesOutline size="20px" /></span>
<I18n t="reviews" />
</RouterNavLink>
<br />
<br />
<RouterNavLink to={'/' + locale + '/home/branches'} activeClassName="active" className={route_location == '/home/branches' ? "link link--sm theme-royal-blue active" : "link link--sm theme-royal-blue"}>
<span><StorefrontOutline size="20px" /></span>
<I18n t="branches" />
</RouterNavLink>
<br />
<br />
<RouterNavLink to={'/' + locale + '/home/tracking'} activeClassName="active" className={route_location == '/home/tracking' ? "link link--sm theme-royal-blue active" : "link link--sm theme-royal-blue"}>
<span><MapOutline size="20px" /></span>
<I18n t="tracking" />
</RouterNavLink>
</>
}
]
Expand Down Expand Up @@ -155,4 +176,5 @@ const Index = (props) => {
}


export default Authorization(Index);
//export default Authorization(Index);
export default Index;
141 changes: 141 additions & 0 deletions src/pages/home/Tracking/View.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import React, { useEffect, useState, useMemo } from 'react';
import HomeLayout from 'pages/home/Index';
import {
PanelContainer,
PanelContainerHeader,
PanelContainerBody,
PanelContainerFooter,
PanelContainerView
} from '@bit/guya-ltd.gcss.templates.panel';
import {
Search as SearchIcon,
SettingsOutline,
CreateOutline
} from 'react-ionicons-icon';
import Tip from '@bit/guya-ltd.gcss.atoms.tip';
import Search from '@bit/guya-ltd.gcss.atoms.search';
import Typography from '@bit/guya-ltd.gcss.atoms.typography';
import { useFetch, useAsync } from 'react-async';
import { Link as RouterLink } from "react-router-dom";
import I18n from 'I18n';
import TableContainer from 'pages/TableContainer';

const { REACT_APP_API_GATEWAY } = process.env;
const USERS_URL = REACT_APP_API_GATEWAY + '/api/v1/users';


const List = (props) => {
/* Localization */
const locale = props.match.params.locale == null ? 'en' : props.match.params.locale;

const [page, setPage] = useState(1);

const headers = { Accept: 'application/json' }

const { data, error, isPending, run } = useFetch(USERS_URL + '?limit=10&page=' + page, { headers })

/*useEffect(() => {
run()
})*/

const columns = useMemo(
() => [
{
Header: <I18n t="date" />,
accessor: 'created_at'
},
{
Header: <I18n t="email" />,
accessor: 'email'
},
{
Header: <I18n t="name" />,
accessor: 'name'
},
{
Header: <I18n t="phone_number" />,
accessor: 'pnum'
},
{
Header: <I18n t="role" />,
accessor: 'role.name'
},
{
Header: <I18n t="status" />,
accessor: 'credential.blocked',
Cell: ({ cell }) => {
const { value } = cell;
if(value)
return <Tip theme="red" variant="red"><I18n t="blocked" /></Tip>
else
return <Tip theme="royal-blue" variant="green"><I18n t="active" /></Tip>
}
},
{
Header: <SettingsOutline size="20px" />,
accessor: 'id',
Cell: ({ cell }) => {
const { value } = cell;
return <RouterLink to={'/' + locale + '/home/users/' + value} ><CreateOutline size="20px" /></RouterLink>
}
}
]
)

const pageOne = event => {
event.preventDefault();
setPage(1);
run();
}

const pageBack = event => {
event.preventDefault();
if(page >= 2) {
setPage(page - 1);
run();
}
}

const nextPage = event => {
event.preventDefault();
setPage(page + 1);
run()
}

const onRowClick = (state, rowInfo, column, instance) => {
return {
onClick: e => {
console.log('A Td Element was clicked!')
console.log('it produced this event:', e)
console.log('It was in this column:', column)
console.log('It was in this row:', rowInfo)
console.log('It was in this table instance:', instance)
}
}
}

return (
<HomeLayout locale={locale} route_location='/home/users'>
<PanelContainer>
<PanelContainerView>
<div className="row">
{/* Top Header */}
<div className="row col-xs-12">
{/* Top Header Left */}
<div className="col-xs-8">
<Typography size='h3'><I18n t="vehicle_tracking" /></Typography>
</div>
{/* End of Top Header Left */}
</div>
{/* End of Top Header */}
<br /><br /><br /><br />
{/* Row Two */}
dsf
</div>
</PanelContainerView>
</PanelContainer>
</HomeLayout>
)
}

export default List;
6 changes: 6 additions & 0 deletions src/routes/ServiceRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import HomeDashboard from 'pages/home/Dashboard';
import HomeUsersList from 'pages/home/Users/List';
import HomeUserView from 'pages/home/Users/View';
import HomeReviewView from 'pages/home/Review/View';
import ChatView from 'pages/home/Chat/View';
import BranchesList from 'pages/home/Branches/List';
import TrackingView from 'pages/home/Tracking/View';

// Match locales with regular expression containing each locale separated by `|`
const base = '/:locale(en|am)?';
Expand All @@ -27,9 +30,12 @@ const ServiceRoute = () => (
<Route path="/:locale(en|am)?/login" component={LoginPage} />
<Route path="/:locale(en|am)?/forget" component={ForgetPage} />
<Route exact path='/:locale(en|am)?/home/dashboards' component={HomeDashboard} />
<Route exact path='/:locale(en|am)?/home/chat' component={ChatView} />
<Route exact path='/:locale(en|am)?/home/users' component={HomeUsersList} />
<Route exact path='/:locale(en|am)?/home/users/:id' component={HomeUserView} />
<Route exact path='/:locale(en|am)?/home/reviews' component={HomeReviewView} />
<Route exact path='/:locale(en|am)?/home/branches' component={BranchesList} />
<Route exact path='/:locale(en|am)?/home/tracking' component={TrackingView} />
<Route path="/:locale(en|am)?/error" component={Error500Page} />
<Route path="*" component={Error404Page} />
</Switch>
Expand Down
3 changes: 3 additions & 0 deletions src/server/Socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//import io from "socket.io-client";

//export const socket = io.connect('http://127.0.0.1:3000', { query: 'name=admin0&type=support'});
Loading

0 comments on commit db41b41

Please sign in to comment.