Skip to content

Commit f544a39

Browse files
authored
Merge pull request #4 from srilekha533/crmUser
initial commit
2 parents 93f99bf + 6eecdb3 commit f544a39

32 files changed

+2237
-13
lines changed

debug.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[0120/154922.057:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)

public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
content="Web site created using create-react-app"
1111
/>
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
1314
<link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500,700" rel="stylesheet">
1415
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
1516
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
1617
<link rel="stylesheet" href="/app/main.css" />
1718
<base href="/">
19+
1820
<!--
1921
manifest.json provides metadata used when your web app is installed on a
2022
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
@@ -33,6 +35,7 @@
3335
<body>
3436
<noscript>You need to enable JavaScript to run this app.</noscript>
3537
<div id="root"></div>
38+
3639
<!--
3740
This HTML file is a template.
3841
If you open it directly in the browser, you will see an empty page.
@@ -43,8 +46,14 @@
4346
To begin the development, run `npm start` or `yarn start`.
4447
To create a production bundle, use `npm run build` or `yarn build`.
4548
-->
49+
4650
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
4751
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
4852
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
53+
<script>
54+
$('.menu .item')
55+
.tab()
56+
;
57+
</script>
4958
</body>
5059
</html>

src/App.js

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,152 @@
11
import React from 'react';
2+
23
import { BrowserRouter as Router, Route } from 'react-router-dom';
4+
5+
import axios from 'axios';
6+
7+
38
import Header from './common/Header';
49
import Login from './auth/Login';
510
import ValidateDomain from './auth/ValidateDomain';
611
import Register from './auth/Register';
712
import ForgotPassword from './auth/ForgotPassword';
13+
14+
15+
import User from './users/User'
16+
import UserCreate from './users/UserCreate'
17+
import UserEdit from './users/UserEdit'
18+
import UserDelete from './users/UserDelete'
19+
import Status from './users/Status'
20+
import ProfileDetails from './profile/ProfileDetails'
21+
import ProfileChangePassword from './profile/ProfileChangePassword';
22+
import ContactList from './settings/contacts/Contacts';
23+
import CreateContact from './settings/contacts/CreateContact'
24+
import CreateEdit from './settings/contacts/EditContact'
25+
import CreateDelete from './settings/contacts/DeleteContact'
26+
import BlockedEmail from './settings/blockedEmail/BlockedEmail'
27+
import CreateBlockedEmail from './settings/blockedEmail/CreateBlockedEmail';
28+
import EditBlockedEmail from './settings/blockedEmail/EditBlockedEmail'
29+
import DeleteBlockedEmail from './settings/blockedEmail/DeleteBlockedEmail'
30+
import BlockDomain from './settings/blockedomain/BlockDomain'
31+
import CreateBlockedDomain from './settings/blockedomain/CreateBlockDomain';
32+
import EditBlockedDomain from './settings/blockedomain/EditBlockedDomain';
33+
import DeleteBlockedDomain from './settings/blockedomain/DeleteBlockedDomain';
34+
35+
36+
37+
38+
39+
840
import PasswordResetMessage from './auth/PasswordResetMessage';
41+
942
import Dashboard from './crm/Dashboard';
1043
import Accounts from './crm/Accounts/Accounts';
1144
import AddAccount from './crm/Accounts/AddAccount';
1245
import EditAccount from './crm/Accounts/EditAccount';
46+
47+
import Contacts from './crm/Contacts/Contacts';
48+
import AddContact from './crm/Contacts/AddContact';
49+
import EditContact from './crm/Contacts/EditContact';
50+
import Leads from './crm/Leads/Leads';
51+
import AddLead from './crm/Leads/AddLead';
52+
import EditLead from './crm/Leads/EditLead';
53+
import { ACCOUNTS, CONTACTS, LEADS } from './common/apiUrls';
54+
import { useState, useEffect } from 'react';
55+
56+
import { render } from 'react-dom';
57+
58+
59+
60+
function App() {
61+
62+
const [contacts, setContacts] = useState([]);
63+
const [leads, setLeads] = useState([]);
64+
const [accounts, setAccounts] = useState([]);
65+
66+
useEffect(() => {
67+
getApiData();
68+
}, []);
69+
70+
const getApiData = () => {
71+
let config = {
72+
headers: {
73+
'Content-Type': 'application/json',
74+
Authorization: `jwt ${localStorage.getItem('Token')}`,
75+
company: `${localStorage.getItem('SubDomain')}`
76+
},
77+
}
78+
axios.all([
79+
axios.get(`${ACCOUNTS}`, config),
80+
axios.get(`${CONTACTS}`, config),
81+
axios.get(`${LEADS}`, config)
82+
]).then(axios.spread( async (res1, res2, res3) => {
83+
await setAccounts(res1.data);
84+
await setContacts(res2.data);
85+
await setLeads(res3.data);
86+
}))
87+
}
88+
89+
90+
return (
91+
<div className="App">
92+
<Router >
93+
<div>
94+
<Route sensitive path={'/'} component={Header} />
95+
<Route sensitive path={'/validate-domain'} component={ValidateDomain} />
96+
<Route sensitive path={'/login'} component={Login} />
97+
<Route sensitive path={'/register'} component={Register} />
98+
<Route sensitive path={'/password-reset'} component={ForgotPassword} />
99+
100+
<Route exact sensitive path={'/'} component={Home} />
101+
<Route exact path={'/user'} component={User} />
102+
<Route exact path={'/users/create'} component={UserCreate} />
103+
<Route exact path={'/users/edit/:id'} component={UserEdit} />
104+
<Route exact path={'/users/delete/:id'} component={UserDelete} />
105+
<Route exact path={'/users/status/:id'} component={Status} />
106+
107+
<Route exact path={'/profile'} component={ProfileDetails} />
108+
<Route exact path={'/profile/change-password'} component={ProfileChangePassword} />
109+
110+
<Route exact path={'/settings/contacts'} component={ContactList} />
111+
<Route exact path={'/settings/contacts/create'} component={CreateContact} />
112+
<Route exact path={'/settings/contacts/edit/:id'} component={CreateEdit} />
113+
<Route exact path={'/settings/contacts/delete/:id'} component={CreateDelete} />
114+
115+
<Route exact path={'/settings/blockdomain'} component={BlockDomain} />
116+
<Route exact path={'/settings/blockedomain/create'} component={CreateBlockedDomain} />
117+
<Route exact path={'/settings/blockdomain/edit/:id'} component={EditBlockedDomain} />
118+
<Route exact path={'/settings/blockedomain/delete/:id'} component={DeleteBlockedDomain} />
119+
120+
121+
<Route exact path={'/settings/blockedemail'} component={BlockedEmail} />
122+
<Route exact path={'/settings/blockedEmail/create'} component={CreateBlockedEmail} />
123+
<Route exact path={'/settings/editblockedEmail/:id'} component={EditBlockedEmail} />
124+
<Route exact path={'/settings/deleteblockedEmail/:id'} component={DeleteBlockedEmail} />
125+
126+
127+
128+
129+
130+
<Route sensitive path={'/dashboard'} component={Dashboard} />
131+
132+
<Route sensitive exact path={'/accounts'}
133+
component={ (routerProps) => <Accounts {...routerProps} accounts={accounts}/>} />
134+
<Route sensitive exact path={'/accounts/create'} component={AddAccount}/>
135+
<Route sensitive exact path={'/accounts/:id/edit'} component={EditAccount}/>
136+
137+
138+
<Route sensitive exact path={'/contacts'}
139+
component={ (routerProps) => <Contacts {...routerProps} contacts={contacts}/>} />
140+
<Route sensitive path={'/contacts/create'} component={AddContact} />
141+
<Route sensitive path={'/contacts/:id/edit'} component={EditContact} />
142+
143+
<Route sensitive exact path={'/leads'}
144+
component={ (routerProps) => <Leads leads={leads}/>} />
145+
<Route sensitive path={'/leads/create'} component={AddLead} />
146+
<Route sensitive path={'/leads/:id/edit'} component={EditLead} />
147+
148+
149+
13150
import ViewAccount from './crm/Accounts/ViewAccount';
14151

15152
function App (props) {
@@ -34,6 +171,7 @@ function App (props) {
34171
<Route sensitive exact path={'/accounts/:id/view'} component={ViewAccount} />
35172
</div>
36173
</Router>
174+
37175
</div>
38176
);
39177
}

src/Home.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export default class Home extends Component {
2424
);
2525
}
2626
}
27+

src/api/apiurl.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import axios from 'axios';
2+
3+
4+
export default axios.create({
5+
baseURL: 'https://bottlecrm.com/api',
6+
headers: {
7+
'Content-Type': 'application/json',
8+
Authorization: `jwt ${localStorage.getItem('Token')}`,
9+
company: `${localStorage.getItem('SubDomain')}`,
10+
11+
}
12+
})

src/auth/Register.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,45 @@ const Register = (props) => {
2020
const onRegister = (e) => {
2121
e.preventDefault();
2222

23+
onRegister(){
24+
if(this.state.subDomain !== '') {
25+
if(this.state.username !== '') {
26+
if(this.state.email !== '') {
27+
if(this.state.password !== '') {
28+
29+
30+
31+
fetch(`${DOMAIN}register/`,
32+
33+
34+
{ method: 'POST',
35+
headers:
36+
{
37+
'Content-Type': 'application/json',
38+
'company': localStorage.getItem('SubDomain')
39+
},
40+
body: JSON.stringify({
41+
sub_domain: this.state.subDomain,
42+
username: this.state.username,
43+
email: this.state.email,
44+
password: this.state.password
45+
})
46+
}
47+
)
48+
.then((response) => response.json())
49+
.then(response => {
50+
if(response.status === 'failure') {
51+
this.setState({ errors: response })
52+
} else {
53+
this.props.history.push('/validate-domain')
54+
}
55+
})
56+
} else {
57+
this.setState({ errors: {password: 'please enter password'} })
58+
}
59+
} else {
60+
this.setState({ errors: {email: 'please enter email'} })
61+
2362
const validationResults = Validations(registrationDetails);
2463
setErrors(validationResults);
2564

@@ -29,6 +68,7 @@ const Register = (props) => {
2968
if (validationResults[i].length > 0) {
3069
isValidationsPassed = false;
3170
break;
71+
3272
}
3373
}
3474

src/auth/ValidateDomain.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { Component } from 'react';
2+
23
import { AUTHENTICATION } from '../common/apiUrls';
34

5+
46
export default class ValidateDomain extends Component {
57
constructor () {
68
super();
@@ -10,6 +12,7 @@ export default class ValidateDomain extends Component {
1012
};
1113
}
1214

15+
1316
onClick () {
1417
if (this.state.domain.trim()) {
1518
fetch(`${AUTHENTICATION}validate-subdomain/`, {
@@ -30,6 +33,7 @@ export default class ValidateDomain extends Component {
3033
});
3134
} else {
3235
this.setState({ errors: { message: 'Please mention a sub_domain' } });
36+
3337
}
3438
}
3539

src/common/Header.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
3+
import User from '../users/User'
34

45
function Header() {
56
// const [currentPage, setCurrentPage] = useState(window.location.pathname);
@@ -70,26 +71,32 @@ function Header() {
7071
<Link className={`text-capitalize ${(currentPage === '/teams') ? 'nav-link active' : 'nav-link'}`} id="teams" to={'/teams'}>Teams</Link>
7172
</li>
7273
</ul>
73-
<ul className="navbar-nav navbar-right my-2 my-lg-0 cursor-pointer settings__ul">
74-
<a href="/#" className="dropdown-toggle" type="button" data-toggle="dropdown">
75-
<img src="https://bottlecrm.s3.amazonaws.com/images/user.png" alt="Micro profile pic"/>
76-
<b className="caret"></b>
77-
</a>
78-
<div className="dropdown-menu dropdown-menu-right rounded-0 mr-2" aria-labelledby="navbarDropdown">
79-
<a href="/#" className="dropdown-item text-secondary py-2 pl-2">Users</a>
80-
<a href="/#" className="dropdown-item text-secondary py-2 pl-2">Settings</a>
81-
<a href="/#" className="dropdown-item text-secondary py-2 pl-2">Change Password</a>
82-
<a href="/#" className="dropdown-item text-secondary py-2 pl-2">Profile</a>
83-
<a href="/app" onClick={() => {
84-
localStorage.clear();
85-
const redirectUrl = `//bottlecrm.com/validate-domain`;
74+
75+
<ul className="navbar-nav navbar-right my-2 my-lg-0">
76+
<li className="nav-item dropdown">
77+
<a onClick={() => setUserMenu(!userMenu)} className="dropdown-toggle abcd nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
78+
<img src="https://bottlecrm.s3.amazonaws.com/images/user.png" alt="Micro profile pic" />
79+
<b className="caret"></b>
80+
</a>
81+
<div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown" style={{ display: userMenu ? 'block' : 'none' }}>
82+
<Link to='/user' className="dropdown-item">Users</Link>
83+
<Link to='/settings/contacts' className="dropdown-item">Settings</Link>
84+
<a className="dropdown-item">Change Password</a>
85+
<Link to='profile' className="dropdown-item">Profile</Link>
86+
<a onClick={() => {
87+
localStorage.clear()
88+
const redirectUrl = `//localhost:3000/validate-domain`
89+
8690
window.location.href = redirectUrl;
8791
}}
8892
className="dropdown-item text-secondary py-2 pl-2"
8993
>
9094
Logout
9195
</a>
9296
</div>
97+
98+
</li>
99+
93100
</ul>
94101

95102
</div>

src/common/apiUrls.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export const DASHBOARD = 'https://bottlecrm.com/api/dashboard/';
33
export const ACCOUNTS = 'https://bottlecrm.com/api/accounts/';
44
export const CONTACTS = 'https://bottlecrm.com/api/contacts/';
55
export const LEADS = 'https://bottlecrm.com/api/leads/';
6+
67
export const TEAMS = 'https://bottlecrm.com/api/teams/';

src/crm/Dashboard.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default class Dashboard extends Component {
1111
};
1212
}
1313

14+
1415
componentDidMount () {
1516
if (localStorage.getItem('Token')) {
1617
fetch(`${DASHBOARD}`, {
@@ -29,6 +30,7 @@ export default class Dashboard extends Component {
2930
const redirectUrl = `//bottlecrm.com/validate-domain`;
3031
window.location.href = redirectUrl;
3132
}
33+
3234
}
3335

3436
render() {

0 commit comments

Comments
 (0)