diff --git a/backend/seeder.js b/backend/seeder.js index a637554..c0899e7 100644 --- a/backend/seeder.js +++ b/backend/seeder.js @@ -20,7 +20,6 @@ const importData = async () => { const createdUsers = await Admin.insertMany(users) console.log('inserted users') const adminUser = createdUsers[0]._id - //the following code will insert admin user in each of the student data const sampleStudents = students.map((student) => { return { ...student, user: adminUser } @@ -29,8 +28,6 @@ const importData = async () => { await Dashboard.insertMany(items) await Student.insertMany(sampleStudents) - //among all the inserted students by the above code of line - //we will select the first console.log('Data imported.') process.exit() @@ -40,25 +37,12 @@ const importData = async () => { } } -//following is for deleting the data from the database of mongodb const exportData = async () => { try { await Student.deleteMany() await Dashboard.deleteMany() await Admin.deleteMany() - // const createdUsers = await Admin.insertMany(users) - // const adminUser = createdUsers[0]._id - // //the following code will insert admin user in each of the student data - - // const sampleStudents = students.map((student) => { - // return { ...student, user: adminUser } - // }) - // await Student.insertMany(sampleStudents) - - // //among all the inserted students by the above code of line - // //we will select the first - - // await Dashboard.insertMany(items) + console.log('Data destroyed.') process.exit() } catch (error) { @@ -66,10 +50,7 @@ const exportData = async () => { process.exit(1) } } -//following line of code looks into the command -//passed into the terminal -//if the two index is '-d', then the destroy function is called -//otherwise import function is called. + if (process.argv[2] === '-d') { destroyData() } else { diff --git a/frontend/public/images/notFound.webp b/frontend/public/images/notFound.webp new file mode 100644 index 0000000..173d7a3 Binary files /dev/null and b/frontend/public/images/notFound.webp differ diff --git a/frontend/src/App.js b/frontend/src/App.js index 00d914b..80153a3 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -23,9 +23,12 @@ import AllTeachers from './screens/AllTeachers' import AllStaffs from './screens/AllStaffs' import StaffRegister from './screens/StaffRegister' import IncomeScreen from './screens/IncomeScreen' +import NotFound from './screens/NotFound' + import ExpenseScreen from './screens/ExpenseScreen' import underConstruction from './components/underConstruction' import { studentAttendances } from './actions/studentActions' +import PrivateRoute from '../src/utils/PrivateRoute' // import ExpenseScreen from './screens/ExpenseScreen' const App = () => { @@ -33,83 +36,96 @@ const App = () => {
- + - - - - + + + - {/* */} - - - - - - + + - - - - - - - + + + - - - - - + + +
diff --git a/frontend/src/index.css b/frontend/src/index.css index 23fe7ac..321e345 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -17,3 +17,20 @@ display: block; } */ /* // style={{ marginTop: '10px', maxWidth: '30%', display: 'block' }} */ + + .notFound{ + + height: 100vh; + /* border: 1px solid red; */ + overflow: hidden; + width: 100%; + + + } + .notFound img{ + /* border: 1px solid red; */ + height: 100vh; + margin: auto; + display: block; + + } \ No newline at end of file diff --git a/frontend/src/screens/Landing.js b/frontend/src/screens/Landing.js index 1994a79..ba5dc41 100644 --- a/frontend/src/screens/Landing.js +++ b/frontend/src/screens/Landing.js @@ -16,11 +16,7 @@ const Landing = ({ history }) => { const closeSidebar = () => { setsidebarOpen(false) } - useEffect(() => { - if (!userCred) { - history.push('/login') - } - }, [userCred, history]) + return (
diff --git a/frontend/src/screens/NotFound.js b/frontend/src/screens/NotFound.js new file mode 100644 index 0000000..ab5b971 --- /dev/null +++ b/frontend/src/screens/NotFound.js @@ -0,0 +1,10 @@ +import React from 'react' +const NotFound = () => { + return ( +
+ +
+ ) +} + +export default NotFound diff --git a/frontend/src/utils/PrivateRoute.js b/frontend/src/utils/PrivateRoute.js new file mode 100644 index 0000000..7e0d716 --- /dev/null +++ b/frontend/src/utils/PrivateRoute.js @@ -0,0 +1,16 @@ +import React from 'react' +import { Route, Redirect } from 'react-router-dom' + +const PrivateRoute = ({ component: Component, ...rest }) => { + const isLoggedIn = localStorage.getItem('userCred') + return ( + + isLoggedIn ? : + } + /> + ) +} + +export default PrivateRoute