Skip to content

Commit ead8179

Browse files
committed
Resolve merge conflicts and remove secret file
1 parent 1064cbb commit ead8179

22 files changed

+1317
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "CoreUI React Admin",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
4+
"features": {},
5+
"postCreateCommand": "npm install",
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"esbenp.prettier-vscode",
10+
"dbaeumer.vscode-eslint"
11+
]
12+
}
13+
},
14+
"workspaceFolder": "/workspace",
15+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
16+
"remoteUser": "node"
17+
}

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// No API keys needed for OpenStreetMap integration

coreui-free-react-admin-template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 1064cbb56dd3777e2e911e82a81c1644a6cb9539

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
"author": "The CoreUI Team (https://github.com/orgs/coreui/people)",
1515
"scripts": {
1616
"build": "vite build",
17+
"dev": "vite",
1718
"lint": "eslint",
1819
"serve": "vite preview",
19-
"start": "vite"
20+
"start": "react-scripts start"
2021
},
2122
"dependencies": {
2223
"@coreui/chartjs": "^4.1.0",
@@ -27,12 +28,19 @@
2728
"@coreui/react-chartjs": "^3.0.0",
2829
"@coreui/utils": "^2.0.2",
2930
"@popperjs/core": "^2.11.8",
31+
"@react-google-maps/api": "^2.20.6",
3032
"chart.js": "^4.4.7",
3133
"classnames": "^2.5.1",
3234
"core-js": "^3.40.0",
35+
"googleapis": "^148.0.0",
36+
"leaflet": "^1.9.4",
37+
"openrouteservice-js": "^0.4.1",
38+
"papaparse": "^5.5.2",
3339
"prop-types": "^15.8.1",
3440
"react": "^19.0.0",
3541
"react-dom": "^19.0.0",
42+
"react-leaflet": "^5.0.0",
43+
"react-leaflet-cluster": "^2.1.0",
3644
"react-redux": "^9.2.0",
3745
"react-router-dom": "^7.1.5",
3846
"redux": "5.0.1",

src/App.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
import React, { Suspense, useEffect } from 'react'
2+
<<<<<<< HEAD
23
import { HashRouter, Route, Routes } from 'react-router-dom'
34
import { useSelector } from 'react-redux'
5+
=======
6+
import { HashRouter, Route, Routes, Navigate } from 'react-router-dom'
7+
import { useSelector } from 'react-redux'
8+
import { AuthProvider } from './context/AuthContext'
9+
import { useAuth } from './context/AuthContext'
10+
>>>>>>> 33b7218 (Initial commit)
411

512
import { CSpinner, useColorModes } from '@coreui/react'
613
import './scss/style.scss'
714

15+
<<<<<<< HEAD
16+
=======
17+
const PrivateRoute = ({ children }) => {
18+
const { user } = useAuth();
19+
return user ? children : <Navigate to="/login" />;
20+
};
21+
22+
>>>>>>> 33b7218 (Initial commit)
823
// We use those styles to show code examples, you should remove them in your application.
924
import './scss/examples.scss'
1025

@@ -17,7 +32,11 @@ const Register = React.lazy(() => import('./views/pages/register/Register'))
1732
const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
1833
const Page500 = React.lazy(() => import('./views/pages/page500/Page500'))
1934

35+
<<<<<<< HEAD
2036
const App = () => {
37+
=======
38+
const AppContent = () => {
39+
>>>>>>> 33b7218 (Initial commit)
2140
const { isColorModeSet, setColorMode } = useColorModes('coreui-free-react-admin-template-theme')
2241
const storedTheme = useSelector((state) => state.theme)
2342

@@ -43,17 +62,45 @@ const App = () => {
4362
<CSpinner color="primary" variant="grow" />
4463
</div>
4564
}
65+
<<<<<<< HEAD
4666
>
4767
<Routes>
4868
<Route exact path="/login" name="Login Page" element={<Login />} />
4969
<Route exact path="/register" name="Register Page" element={<Register />} />
5070
<Route exact path="/404" name="Page 404" element={<Page404 />} />
5171
<Route exact path="/500" name="Page 500" element={<Page500 />} />
5272
<Route path="*" name="Home" element={<DefaultLayout />} />
73+
=======
74+
> <Routes>
75+
<Route exact path="/login" name="Login Page" element={<Login />} />
76+
<Route exact path="/register" name="Register Page" element={<Register />} />
77+
<Route exact path="/404" name="Page 404" element={<Page404 />} />
78+
<Route exact path="/500" name="Page 500" element={<Page500 />} />
79+
<Route
80+
path="*"
81+
name="Home"
82+
element={
83+
<PrivateRoute>
84+
<DefaultLayout />
85+
</PrivateRoute>
86+
}
87+
/>
88+
>>>>>>> 33b7218 (Initial commit)
5389
</Routes>
5490
</Suspense>
5591
</HashRouter>
5692
)
5793
}
5894

95+
<<<<<<< HEAD
96+
=======
97+
const App = () => {
98+
return (
99+
<AuthProvider>
100+
<AppContent />
101+
</AuthProvider>
102+
);
103+
};
104+
105+
>>>>>>> 33b7218 (Initial commit)
59106
export default App

src/_nav.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {
1010
cilExternalLink,
1111
cilNotes,
1212
cilPencil,
13+
<<<<<<< HEAD
14+
=======
15+
cilPeople,
16+
>>>>>>> 33b7218 (Initial commit)
1317
cilPuzzle,
1418
cilSpeedometer,
1519
cilStar,
@@ -28,6 +32,15 @@ const _nav = [
2832
},
2933
},
3034
{
35+
<<<<<<< HEAD
36+
=======
37+
component: CNavItem,
38+
name: 'Users',
39+
to: '/users',
40+
icon: <CIcon icon={cilPeople} customClassName="nav-icon" />,
41+
},
42+
{
43+
>>>>>>> 33b7218 (Initial commit)
3144
component: CNavTitle,
3245
name: 'Theme',
3346
},

src/components/ErrorBoundary.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react'
2+
import {
3+
CAlert,
4+
CCard,
5+
CCardBody,
6+
CCardHeader,
7+
} from '@coreui/react'
8+
9+
class ErrorBoundary extends React.Component {
10+
constructor(props) {
11+
super(props)
12+
this.state = { hasError: false, error: null, errorInfo: null }
13+
}
14+
15+
static getDerivedStateFromError(error) {
16+
return { hasError: true }
17+
}
18+
19+
componentDidCatch(error, errorInfo) {
20+
console.error('Error caught by ErrorBoundary:', error, errorInfo)
21+
this.setState({
22+
error: error,
23+
errorInfo: errorInfo
24+
})
25+
}
26+
27+
render() {
28+
if (this.state.hasError) {
29+
return (
30+
<CCard className="mb-4">
31+
<CCardHeader>
32+
<h4>Something went wrong</h4>
33+
</CCardHeader>
34+
<CCardBody>
35+
<CAlert color="danger">
36+
<h4 className="alert-heading">Error Details</h4>
37+
<p>{this.state.error && this.state.error.toString()}</p>
38+
<hr />
39+
<p className="mb-0">
40+
Please try refreshing the page. If the problem persists, contact support.
41+
</p>
42+
</CAlert>
43+
{process.env.NODE_ENV === 'development' && (
44+
<details style={{ whiteSpace: 'pre-wrap' }}>
45+
{this.state.errorInfo && this.state.errorInfo.componentStack}
46+
</details>
47+
)}
48+
</CCardBody>
49+
</CCard>
50+
)
51+
}
52+
53+
return this.props.children
54+
}
55+
}
56+
57+
export default ErrorBoundary

src/components/header/AppHeaderDropdown.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import React from 'react'
2+
<<<<<<< HEAD
3+
=======
4+
import { useNavigate } from 'react-router-dom'
5+
>>>>>>> 33b7218 (Initial commit)
26
import {
37
CAvatar,
48
CBadge,
@@ -9,6 +13,10 @@ import {
913
CDropdownMenu,
1014
CDropdownToggle,
1115
} from '@coreui/react'
16+
<<<<<<< HEAD
17+
=======
18+
import { useAuth } from '../../context/AuthContext'
19+
>>>>>>> 33b7218 (Initial commit)
1220
import {
1321
cilBell,
1422
cilCreditCard,
@@ -25,6 +33,17 @@ import CIcon from '@coreui/icons-react'
2533
import avatar8 from './../../assets/images/avatars/8.jpg'
2634

2735
const AppHeaderDropdown = () => {
36+
<<<<<<< HEAD
37+
=======
38+
const { user, logout } = useAuth();
39+
const navigate = useNavigate();
40+
41+
const handleLogout = () => {
42+
logout();
43+
navigate('/login');
44+
};
45+
46+
>>>>>>> 33b7218 (Initial commit)
2847
return (
2948
<CDropdown variant="nav-item">
3049
<CDropdownToggle placement="bottom-end" className="py-0 pe-0" caret={false}>
@@ -46,6 +65,7 @@ const AppHeaderDropdown = () => {
4665
42
4766
</CBadge>
4867
</CDropdownItem>
68+
<<<<<<< HEAD
4969
<CDropdownItem href="#">
5070
<CIcon icon={cilTask} className="me-2" />
5171
Tasks
@@ -59,6 +79,16 @@ const AppHeaderDropdown = () => {
5979
<CBadge color="warning" className="ms-2">
6080
42
6181
</CBadge>
82+
=======
83+
<CDropdownItem>
84+
<CIcon icon={cilUser} className="me-2" />
85+
{user?.username || 'User'}
86+
</CDropdownItem>
87+
<CDropdownDivider />
88+
<CDropdownItem onClick={handleLogout}>
89+
<CIcon icon={cilLockLocked} className="me-2" />
90+
Logout
91+
>>>>>>> 33b7218 (Initial commit)
6292
</CDropdownItem>
6393
<CDropdownHeader className="bg-body-secondary fw-semibold my-2">Settings</CDropdownHeader>
6494
<CDropdownItem href="#">

src/context/AuthContext.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React, { createContext, useContext, useState, useEffect } from 'react';
2+
3+
const AuthContext = createContext(null);
4+
5+
const ADMIN_USER = {
6+
username: 'Admin',
7+
password: 'admin123',
8+
role: 'admin'
9+
};
10+
11+
export const AuthProvider = ({ children }) => {
12+
const [user, setUser] = useState(null);
13+
14+
useEffect(() => {
15+
// Check if user is stored in localStorage on load
16+
const storedUser = localStorage.getItem('user');
17+
if (storedUser) {
18+
setUser(JSON.parse(storedUser));
19+
}
20+
}, []);
21+
22+
const login = (username, password) => {
23+
// For now, we'll just check against the hardcoded admin user
24+
if (username === ADMIN_USER.username && password === ADMIN_USER.password) {
25+
const userData = { username, role: ADMIN_USER.role };
26+
setUser(userData);
27+
localStorage.setItem('user', JSON.stringify(userData));
28+
return true;
29+
}
30+
return false;
31+
};
32+
33+
const logout = () => {
34+
setUser(null);
35+
localStorage.removeItem('user');
36+
};
37+
38+
return (
39+
<AuthContext.Provider value={{ user, login, logout }}>
40+
{children}
41+
</AuthContext.Provider>
42+
);
43+
};
44+
45+
export const useAuth = () => {
46+
const context = useContext(AuthContext);
47+
if (!context) {
48+
throw new Error('useAuth must be used within an AuthProvider');
49+
}
50+
return context;
51+
};

src/layout/DefaultLayout.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
<<<<<<< HEAD
12
import React from 'react'
23
import { AppContent, AppSidebar, AppFooter, AppHeader } from '../components/index'
34

45
const DefaultLayout = () => {
6+
=======
7+
import React, { useEffect } from 'react'
8+
import { useNavigate } from 'react-router-dom'
9+
import { AppContent, AppSidebar, AppFooter, AppHeader } from '../components/index'
10+
import { useAuth } from '../context/AuthContext'
11+
12+
const DefaultLayout = () => {
13+
const { user } = useAuth()
14+
const navigate = useNavigate()
15+
16+
useEffect(() => {
17+
if (!user) {
18+
navigate('/login')
19+
}
20+
}, [user, navigate])
21+
>>>>>>> 33b7218 (Initial commit)
522
return (
623
<div>
724
<AppSidebar />

0 commit comments

Comments
 (0)