1
1
import React from 'react' ;
2
+
2
3
import { BrowserRouter as Router , Route } from 'react-router-dom' ;
4
+
5
+ import axios from 'axios' ;
6
+
7
+
3
8
import Header from './common/Header' ;
4
9
import Login from './auth/Login' ;
5
10
import ValidateDomain from './auth/ValidateDomain' ;
6
11
import Register from './auth/Register' ;
7
12
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
+
8
40
import PasswordResetMessage from './auth/PasswordResetMessage' ;
41
+
9
42
import Dashboard from './crm/Dashboard' ;
10
43
import Accounts from './crm/Accounts/Accounts' ;
11
44
import AddAccount from './crm/Accounts/AddAccount' ;
12
45
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
+
13
150
import ViewAccount from './crm/Accounts/ViewAccount';
14
151
15
152
function App (props) {
@@ -34,6 +171,7 @@ function App (props) {
34
171
< Route sensitive exact path = { '/accounts/:id/view' } component = { ViewAccount } />
35
172
</ div >
36
173
</ Router >
174
+
37
175
</ div >
38
176
) ;
39
177
}
0 commit comments