Skip to content

Commit

Permalink
fix conf
Browse files Browse the repository at this point in the history
Relates #55
  • Loading branch information
Osama-you committed Feb 17, 2021
2 parents 8975b80 + 1a443df commit 2eda156
Show file tree
Hide file tree
Showing 64 changed files with 4,120 additions and 24,713 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false,
"files.eol": "\n",
"cSpell.words": ["Rawdaty"],
"cSpell.words": [
"Rawdaty",
"antd",
"boomify"
],
"prettier.singleQuote": true
}
1 change: 1 addition & 0 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
],
"react/jsx-props-no-spreading": [0],
"no-underscore-dangle": 0,
// configure the prettier plugin
"prettier/prettier": [
"error",
Expand Down
26,705 changes: 2,378 additions & 24,327 deletions client/package-lock.json

Large diffs are not rendered by default.

128 changes: 118 additions & 10 deletions client/src/App/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,123 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import KindergartenForm from '../Components/KindergartenForm';
import React, { useState, useEffect } from 'react';
import {
BrowserRouter as Router,
Route,
Switch,
Redirect,
} from 'react-router-dom';
import axios from 'axios';
import { notification } from 'antd';

import NavBar from '../Components/Layout/Navbar';
import Footer from '../Components/Layout/Footer';
import SideBar from '../Components/Layout/SideBar';
import Home from '../Pages/HomePage';
import LoginPage from '../Pages/LoginPage';
import AuthContext from '../Context/AuthContext';
import LogoutContext from '../Context/LogoutContext';
import About from '../Pages/ِAboutPage';

import './style.css';

const App = () => (
<Router>
<KindergartenForm
dorpListOptions={[{ value: 'غزة', id: 1, disabled: false }]}
/>
</Router>
);
const App = () => {
const [userData, setUserData] = useState({});
const [isOK, setIsOk] = useState(false);
const [role, setRole] = useState(null);
const checkAuth = async () => {
try {
const {
data: { data },
} = await axios.get('/api/v1/getAuthUser');
setUserData(data);
setRole(data.is_admin === 'true' ? 'admin' : 'user');
setIsOk(true);
} catch (error) {
setRole(null);
setUserData({});
}
};

useEffect(() => {
const source = axios.CancelToken.source();
checkAuth();
return () => {
source.cancel('clean up axios');
};
}, [role]);

const logout = async () => {
try {
const source = axios.CancelToken.source();
await axios.get('/api/v1/logout');
setRole(null);
setUserData({});
return () => {
source.cancel('clean up axios');
};
} catch (err) {
return notification.open({
message: 'حدث خطأ في السيرفر, يرجى المحاولة لاحقا',
});
}
};

return (
<Router>
<Switch>
<AuthContext.Provider value={{ role, userData, checkAuth }}>
<LogoutContext.Provider value={{ logout }}>
<Route exact path={['/', '/about', '/kindergarten/:id', '/search']}>
<NavBar />
</Route>

<Route exact path="/">
<Home />
</Route>

<Route path="/about">
<About />
</Route>

<Route exact path="/kindergarten/:id" />

<Route exact path="/login">
{!role ? <LoginPage /> : <Redirect to="/" />}
</Route>

<Route exact path="/signup" />

<Route exact path={['/', '/about', '/kindergarten/:id', '/search']}>
<Footer />
</Route>

{isOK && role === 'admin' && (
<Route path="/dashboard">
<div
style={{
display: 'flex',
flexDirection: 'row',
width: '100vw',
}}
>
<SideBar />
<div
style={{
width: '100vw',
}}
>
<NavBar />
<Route exact path="/dashboard/all" />
<Route exact path="/dashboard/add" />
<Route exact path="/dashboard/notification" />
</div>
</div>
</Route>
)}
</LogoutContext.Provider>
</AuthContext.Provider>
</Switch>
</Router>
);
};

export default App;
2 changes: 1 addition & 1 deletion client/src/App/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:root {
--main-color: #739c98;
--main-white: #ffffff;
--main-red:#DA3743;
--main-red: #da3743;
--main-gray: #c4c4c4;
--main-color-font: #707472;
--input-border: 1.6px solid var(--main-gray);
Expand Down
2 changes: 1 addition & 1 deletion client/src/Components/Common/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const CardComponent = ({
const history = useHistory();

const handleClick = () => {
history.push(`/profile/${id}`);
history.push(`/kindergarten/${id}`);
};

return (
Expand Down
20 changes: 10 additions & 10 deletions client/src/Components/Common/Card/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.location-price{
.location-price {
display: flex;
justify-content: space-between;
color: var(--main-color-font);
margin-top: 10px;
}

.bold-style{
.bold-style {
font-weight: bold;
}

.card-title{
.card-title {
font-weight: bold;
font-size: 20px;
color: var(--main-color-font);
Expand All @@ -19,23 +19,23 @@
.location-price h3 {
display: inline;
margin: 0;
color: var(--main-color-font) ;
color: var(--main-color-font);
font-weight: bold;
}

.reviewers{
.reviewers {
display: inline;
padding: 10px;
color: var(--main-color-font) ;
color: var(--main-color-font);
}

.card{
.card {
width: 300px;
border-radius: var(--border-radius) !important;
box-shadow: var(--card-shadow) ;
box-shadow: var(--card-shadow);
}

.card-cover{
.card-cover {
height: 250px;
border-radius: var(--border-radius);
margin: 15px;
Expand All @@ -44,6 +44,6 @@
background-size: cover;
}

.card .ant-card-body{
.card .ant-card-body {
padding-top: 10px !important;
}
7 changes: 6 additions & 1 deletion client/src/Components/Common/MainButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const MainButton = ({
size,
id,
className,
htmlType,
...otherStyleProps
}) => (
<Button
Expand All @@ -19,12 +20,14 @@ const MainButton = ({
onClick={onClick}
style={!isDelete ? { ...otherStyleProps } : null}
danger={isDelete}
htmlType={htmlType}
>
{children}
</Button>
);

MainButton.defaultProps = {
onClick: () => {},
children: 'إرسال',
backgroundColor: 'var(--main-color)',
border: 'var(--button-border)',
Expand All @@ -33,10 +36,11 @@ MainButton.defaultProps = {
size: 'large',
id: '',
className: '',
htmlType: '',
};

MainButton.propTypes = {
onClick: PropTypes.func.isRequired,
onClick: PropTypes.func,
children: PropTypes.string,
isDelete: PropTypes.bool,
backgroundColor: PropTypes.string,
Expand All @@ -45,6 +49,7 @@ MainButton.propTypes = {
size: PropTypes.string,
id: PropTypes.string,
className: PropTypes.string,
htmlType: PropTypes.string,
};

export default MainButton;
5 changes: 5 additions & 0 deletions client/src/Components/Common/MainInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ const MainInput = ({
/>
);
break;
case 'password':
input = (
<Input.Password id="password" style={style} {...otherInputProps} />
);
break;
default:
input = <></>;
}
Expand Down
34 changes: 23 additions & 11 deletions client/src/Components/Common/MainInput/style.css
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
.input,
.slider{
.slider {
display: flex;
}
.input{

.input {
flex-direction: column;
}

.slider{
.slider {
flex-direction: row;
}

.input .input-label{
.input .input-label {
font-weight: bold;
font-size: 15px;
margin-bottom: 5px;
}

.input textarea.ant-input{
.input textarea.ant-input {
height: 70px;
min-height: 70px;
max-height: 70px;
}

.input .slider-label{
.input .slider-label {
font-style: normal;
font-weight: bold;
font-size: 17px;
Expand All @@ -34,14 +34,14 @@

.input .ant-input,
.input .ant-picker,
.input .ant-input-affix-wrapper{
.input .ant-input-affix-wrapper {
border: var(--input-border);
border-radius: var(--border-radius);
width: 300px;
height: 40px;
}

.input .ant-input-affix-wrapper{
.input .ant-input-affix-wrapper {
display: flex;
flex-direction: row-reverse;
}
Expand All @@ -60,13 +60,25 @@
}

.search-input {
box-shadow:var(--input-shadow) ;
box-shadow: var(--input-shadow);
}

.search-input .ant-input {
height: 100%;
}

.input{
.input {
font-size: 21px;
}

.input .ant-input-password {
flex-direction: row;
border-width: 2.95px;
}
.input .ant-input-password .ant-input {
width: 100%;
height: 100%;
}
.ant-input-suffix svg {
font-size: 22px;
}
2 changes: 1 addition & 1 deletion client/src/Components/Common/NavTap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReactComponent as About } from '../../../assets/icons/about.svg';
import { ReactComponent as Search } from '../../../assets/icons/search.svg';

const NavTap = () => (
<Menu mode="horizontal" defaultSelectedKeys={['1']}>
<Menu id="nav-tap" mode="horizontal" defaultSelectedKeys={['1']}>
<Menu.Item key="1" icon={<Home className="icon" />}>
<NavLink exact to="/" className="tap">
الرئيسية
Expand Down
Loading

0 comments on commit 2eda156

Please sign in to comment.