0% found this document useful (0 votes)
35 views80 pages

Monika Final

Uploaded by

starxorg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views80 pages

Monika Final

Uploaded by

starxorg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Cover Page

An

Industrial Project Report


On

University Management System using React JS,Node Js and Postgre Sql


Submitted to the Rajasthan Technical University, Kota

In

Partial fulfilment of the requirement of the degree of

Master of Computer Applications

Supervisor Submitted By

Dr. Ravi.S.Sharma Monika Ashok Jat

Mentor Enrolment no: 22C2PGXXF30PG661

SS Jain Subodh PG College, Jaipur


Affiliated to

Rajasthan Technical University,


Kota (Rajasthan) – 324010

July, 2024
SS Jain Subodh PG College
Computer Science Department

Certificate
Date: 31/07/2024

This is to certify that the Industrial Project(MCA – 451) work entitled “University Management
System using React JS, Node JS and Postgre SQL” submitted by Monika Ashok Jat( 22CPGXX661) in
the Department of Computer Science and Application of SS Jain Subodh PG College has been
examined and evaluated.

The project work has been prepared as per the regulation of Rajasthan Technical University Kota and
qualifies to be accepted in partial fulfilment of the requirement for the degree of MCA(Master of
Computer Application_

Monika Ashok Jat Supervisor/Guide

Dr. Ravi.S.Sharma

External Examiner

Head of Institution/Principal
Candidate Declaration

I hereby declare that the work, which is being presented in the MCA-451, Industrial Project, entitled
“University Management System using React JS, Node Js and Postgre Sql” in partial fulfilment for
the award of Degree of “Master of Computer Application” in Department of Computer Applications
submitted to the SS Jain Subodh PG College, Rajasthan Technical University is a record of my own
work carried under the Guidance of Shri/Dr. Ravi.S.Sharma , Department of Computer Application SS
Jain Subodh PG College.

I have not submitted the matter present in this Project Report any where for the award of any other
Degree.

Monika Ashok Jat

Enrolment No.: 22C2PGXXF30P661

SS Jain Subodh PG College, Jaipur

Dr.Ravi.S.Sharma
Ref No. REG145 Date: 13 November 2023

Certificate

This is to certify that Monika Ashok Jat(22CPGXX661) is/was undertraining from 7th August 2023 to
13th November 2023 under my supervision in partial fulfilment of the requirement for the award of
the Degree of Master of Computer Applications.

During this period he/she has worked on “University Management System” using React Js, Node Js
and Postgre Sql as a Web developer.

Training/Incharge/Project Leader/HR
Subject: Relieving/Experience Letter

Date: November 15 ,2023

Dear Monika,

Designation : Associate Full Stack MEARN Developer


Employee ID : REG145
Period : 07th August 2023 to 13th November 2023

With reference to your resignation dated 1st November, 2023 resigning from the services of the
company. This is confirmed that the management has accepted the request and you will be
relieved from the services of the company at the closing hours on 13th November 2023.

We take this opportunity to thank you for your contribution to the company and wish you
success in your future endeavors.

Best Wishes from


REGex Software Services & Team

Mr. Sushil Kumar


HR Head, REGex Software

www.regexsoftware.com | [email protected]
ABSTRACT
N-Grade deals with the maintenance of university, department, faculty, student information

within the university. N-Grade is an automation system, which is used to store the

department, faculty, student, courses and information of a university.

Starting from registration of a new student in the university, it maintains all the details

regarding the attendance and marks of the students. The project deals with retrieval of

information through an INTRANET based campus wide portal. It collects related information

from all the departments of an organization and maintains files, which are used to generate

reports in various forms to measure individual and overall performance of the students.

Development process of the system starts with System analysis. System analysis involves

creating a formal model of the problem to be solved by understanding requirements.


PURPOSE OF THE SYSTEM

The aim of the project is to develop a university management system that is able to deliver access

to NSU students authorized anytime, anyplace on any device. N-Grade deals with the

maintenance of university, department, faculty, student information within the university.

This project of N-Grade involved the automation of student information that can be

implemented in different department managements.

The uniqueness is being web based and for general-purpose. Being web based means this

system available everywhere through internet. Being general-purpose means system can be

used for all type of documents. The project deals with retrieval of information through an

INTRANET based campus wide portal. It collects related information from all the

departments of an organization and maintains files, which are used to generate reports in

various forms to measure individual and overall performance of the students.

The principle of the system is :

 Keep it simple

 Extensibility
 Use-at-will architecture

 Showcase of current trend in web development


 Portability (develop once, run on all platform)
 Open Source (to suite the nature of this project)
EXISTING SYSTEM

The system starts with registration of new staff and students. When the subjects are to be

allocated to the faculty, the Head of the Department should enter everything in the Excel

sheets. Then the staff enters corresponding subject’s attendance and marks of a student then

those must also be entered in the Excel sheets and validations are to be done by the user

itself. So there will be a lot of work to be done and must be more conscious during the

entrance of details. So, more risk is involved.


PROBLEMS IN THE EXISTING SYSTEM:

Storing and accessing the data in the form of Excel sheets and account books is a tedious

work. It requires a lot of laborious work. It may often yield undesired results. Maintaining

these records as piles may turn out to be a costlier task than any other of the universities and

institutions.

Risks involved in existing system:

Present System is time-consuming and also results in lack of getting inefficient results.
Some of the risks involved in the present system are:
 During the entrance of marks and attendance, if any mistake is done at a point,
then this becomes cumulative and leads to adverse consequences.
 If there is any need to retrieve results it may seem to be difficult to search.
PROPOSED SYSTEM

N-Grade makes management to get the most updated information always by avoiding
manual accounting process. This system has the following functional divisions.

 University Administrator

 Department Administrator

 User (Students / Faculties)

University Administrator has the functionality of registering new faculties and courses.

Department Administrator has the rights of creating department, allocating courses to

departments, creating faculties, students and allocating subjects to faculties, and

modifications in the data entered by the user can also be done by the department

administrator.

User of this may be faculty or students. Faculty has the facility of entering the marks, class

related announcement and attendance of the students. Students can check their marks and

attendance but there is no chance of modifications.

Reports must be generated for the existing data i.e. for attendance and marks of the students,

which are used to assess the performance of the students. These reports should be viewed by

the in charge and user.


INTRODUCTION
After analyzing the requirements of the task to be performed, the next step is to analyze the

problem and understand its context. The first activity in the phase is studying the existing

system and other is to understand the requirements and domain of the new system. Both the

activities are equally important, but the first activity serves as a basis of giving the functional

specifications and then successful design of the proposed system. Understanding the

properties and requirements of a new system is more difficult and requires creative thinking

and understanding of existing running system is also difficult, improper understanding of

present system can lead diversion from solution.

Proposed Modules:

 Student Office Information System:

 Student Registration
 Student Fee Control
 Student Information Entering and Updating
 Student Status

 Course Registration
 Student Success
 Reports and Official Inquiry

 Faculty Information System:

 Main Page
 Entering Exam Results
 Course Registration
 Student Related Information
 Student Success
 Communication Facilities
 Weekly Class Schedule
 Exam Schedule
 Student Evaluation
 Library Electronic Catalog

 Student Information System:

 Course Registration
 Weekly Class Schedule
 Exam Schedule
 Exams Results
 Attendance
 Messages from Faculty
 Online Publication Databases
 Library Electronic Catalog
ANALYSIS MODEL
The model that is basically being followed is the WATER FALL MODEL, which states

that the phases are organized in a linear order. First of all the requirement analysis and project

planning begins. The design starts after the requirement analysis is complete and the coding

begins after the design is complete. Once the programming is completed, the testing is done.

In this model the sequence of activities performed in a software development project are: -

 Requirement Analysis

 Project Planning

 System design

 Detail design

 Coding

 Unit testing

 System integration & testing

Here the linear ordering of these activities is critical. End of the phase and the output

of one phase is the input of other phase. The output of each phase is to be consistent with the

overall requirement of the system. Some of the qualities of spiral model are also incorporated

like after the people concerned with the project review completion of each of the phase the

work done.

WATER FALL MODEL was being chosen because all requirements were known beforehand

and the objective of our software development is the computerization/automation of an

already existing manual working system.


Changed
Requirements
Communicated
Requirements

Requirements
Specification
Requirements
Engineering

Design
Specification
Design

Executable
Software
Programming Modules Maintenance

Integrated
Software
Integration Product

Delivered
Software
Delivery Product

Figure: Water Fall Model


S/w and H/w requirements

1.Environment:
 Servers:
 Operating System Server: - Microsoft Windows
 Data Base Server: Postgres Sql
 Clients : Mozilla Firefox, Google Chrome
 Tools : Vs code and Postgres Shell
 User Interface: React js with redux
 Code Behind : Node js and express js

2. Requirements:

 Hardware requirements:

Number Description
1 PC with GB hard-disk
and MB RAM

 Software requirements:

Number Description
1 Windows

2.

3.

4. Mozilla Firefox, Google Chrome


INPUT AND OUTPUTS:
The major inputs and outputs and major functions of the system are follows:

Inputs:
 University Administrator enter his user id and password for login to authenticate in this
system
 University Administrator creates the faculties and coursed
While registration Courses can able to provide their information like
1. Department id
2. Course name
3. Information of course
4. Password for the id
 Administrator can create the various course details in this website.
 Registered courses and faculties need to submit their log in information for change their
password.
 For searching course details guest need to choose the courses or search course option
for user interface.
 For upload their details a faculty must login to their profile
 For display they have to view the reports.

Outputs:
 Administrator can have his own home page. Courses and faculty and student have their
own home page after completion of the authentication process.
 Admin get all courses and faculty and course details.
 The registered user’s data can be stored in centralized database through the system user
interface.
 Various types of information can be displayed to the users like course offered, courses
faculty and course sections etc
 After successful submission of log in information users can got their new password.
 Profile can be update by the users individually.
PROCESS MODEL USED WITH JUSTIFICATION
ACCESS CONTROL FOR DATA WHICH REQUIRE USER AUTHENTICAION
The following commands specify access control identifiers and they are typically used to
authorize and authenticate the user (command codes are shown in parentheses)

USER NAME (USER)


The user identification is that which is required by the server for access to its file system. This
command will normally be the first command transmitted by the user after the control
connections are made (some servers may require this).

PASSWORD (PASS)
This command must be immediately preceded by the user name command, and, for some sites,
completes the user's identification for access control. Since password information is quite
sensitive, it is desirable in general to "mask" it or suppress type out.

Input Design:
Input design is a part of overall system design. The main objective during the input
design is as given below:

 To produce a cost-effective method of input.


 To achieve the highest possible level of accuracy.
 To ensure that the input is acceptable and understood by the user.

Input Types:

It is necessary to determine the various types of inputs. Inputs can be categorized as follows:
 External inputs, which are prime inputs for the system.
 Internal inputs, which are user communications with the system.
 Operational, which are computer department’s communications to the system?
 Interactive, which are inputs entered during a dialogue.

Input Media:
At this stage choice has to be made about the input media. To conclude about the input
media consideration has to be given to;
 Type of input
 Flexibility of format
 Speed
 Accuracy
 Verification methods
 Rejection rates
 Ease of correction
 Storage and handling requirements
 Security
 Easy to use
 Portability

Keeping in view the above description of the input types and input media, it can be said
that most of the inputs are of the form of internal and interactive. As
Input data is to be the directly keyed in by the user, the keyboard can be considered to be the
most suitable input device

Error Avoidance:
At this stage care is to be taken to ensure that input data remains accurate form the stage
at which it is recorded up to the stage in which the data is accepted by the system. This can be
achieved only by means of careful control each time the data is handled.
Error Detection:
Even though every effort is make to avoid the occurrence of errors, still a small
proportion of errors is always likely to occur, these types of errors can be discovered by using
validations to check the input data.
Data Validation:
Procedures are designed to detect errors in data at a lower level of detail. Data
validations have been included in the system in almost every area where there is a possibility
for the user to commit errors. The system will not accept invalid data. Whenever an invalid
data is keyed in, the system immediately prompts the user and the user has to again key in the
data and the system will accept the data only if the data is correct. Validations have been
included where necessary.
The system is designed to be a user friendly one. In other words the system has been
designed to communicate effectively with the user. The system has been designed with popup
menus.

User Interface Design:


It is essential to consult the system users and discuss their needs while designing the
user interface:

User Interface Systems can be broadly classified as:


1. User initiated interface - The user is in charge, controlling the progress of the user/computer
dialogue. In the computer-initiated interface, the computer selects the next stage in the
interaction.
2. Computer initiated interfaces - In the computer initiated interfaces the computer guides the
progress of the user/computer dialogue. Information is displayed and the user response of
the computer takes action or displays further information.

User-Initiated Interfaces:
User initiated interfaces fall into two approximate classes:
1. Command driven interfaces: In this type of interface the user inputs commands or queries
which are interpreted by the computer.
2. Forms oriented interface: The user calls up an image of the form to his/her screen and fills
in the form. The forms oriented interface is chosen because it is the best choice.
3. Computer-Initiated Interfaces:
The following computer – initiated interfaces were used:
1. The menu system for the user is presented with a list of alternatives and the user chooses
one; of alternatives.
2. Questions – answer type dialog system where the computer asks question and takes action
based on the basis of the users reply.
Right from the start the system is going to be menu driven, the opening menu displays the
available options. Choosing one option gives another popup menu with more options. In this
way every option leads the users to data entry form where the user can key in the data.

Error Message Design:


The design of error messages is an important part of the user interface design. As user
is bound to commit some errors or other while designing a system the system should be
designed to be helpful by providing the user with information regarding the error he/she has
committed.

This application must be able to produce output at different modules for


different inputs.

Performance Requirements:

Performance is measured in terms of the output provided by the application.

Requirement specification plays an important part in the analysis of a system. Only

when the requirement specifications are properly given, it is possible to design a system, which
will fit into required environment. It rests largely in the part of the users of the existing system

to give the requirement specifications because they are the people who finally use the system.

This is because the requirements have to be known during the initial stages so that the system

can be designed according to those requirements. It is very difficult to change the system once

it has been designed and on the other hand designing a system, which does not cater to the

requirements of the user, is of no use.

The requirement specification for any system can be broadly stated as given below:

 The system should be able to interface with the existing system

 The system should be accurate

 The system should be better than the existing system

The existing system is completely dependent on the user to perform all the duties.

Number of Modules
A module is a bounded contiguous group of statements having a single name and that can be
treated as a unit. In other words, a single block in a pile of blocks.

Guidelines for Modularity

 Make sure modules perform a single task, have a single entry point, and have a single
exit point.
 Isolate input-output (I-O) routines into a small number of standard modules that can be
shared system-wide.
 Isolate system-dependent functions (e.g., getting date or time) in the application to ease
possible future conversions to other computer platforms or to accommodate future operating
system revisions.
A module is a bounded contiguous group of statements having a single name and that can be
treated as a unit. In other words, a single block in a pile of blocks.
The system after careful analysis has been identified to be presented with the following
modules:

N-Grade makes management to get the most updated information always by avoiding
manual accounting process. This system has the following functional divisions.

 University Administrator
 Department Administrator
 User (Students / Faculties)
 Reports
 Authentication

University Administrator has the functionality of registering new faculties and courses.

Department Administrator has the rights of creating department, allocating courses to

departments, creating faculties, students and allocating subjects to faculties, and

modifications in the data entered by the user can also be done by the college

administrator.

User of this may be faculty or students. Faculty has the facility of entering the marks and

attendance of the students. Students can check their marks and attendance but there is no

chance of modifications.
Reports must be generated for the existing data i.e. for attendance and marks of the

students, which are used to assess the performance of the students. These reports should

be viewed by the in charge and user.

Authentication: this module contains all the information about the authenticated user.

. User without his username and password can’t enter into the login if he is only the

authenticated user then he can enter to his login.


App.js

import Navbar from ’./GlobalComponent/Navbar’;


import Sidebar from ’./GlobalComponent/Sidebar’;

function App({ Propscomponent }) {


return (
<div className=’main’>
<div>
<Sidebar />
<div className="content">
<Navbar />
<Propscomponent />
</div>
</div>
</div>
);
}

export default App;

index.js

import React from ’react’;


import ReactDOM from ’react-dom/client’;
import reportWebVitals from ’./ReportWebVitals’;
import "bootstrap/dist/css/bootstrap.css"
import "bootstrap/dist/js/bootstrap.bundle"
import App from ’./App’;
import GlobalStyle from ’./GlobalStyleComponent/GlobalStyle’;
import { RouterProvider, createBrowserRouter } from ’react-router-dom’;
import Dashboard from ’./GlobalComponent/Dashboard’;
import AdmissionQuery from ’./AdministrationComponent/Admin Section/AdmissionQuery’;
import VisitorBook from ’./AdministrationComponent/Admin Section/VisitorBook’;
import Complaint from ’./AdministrationComponent/Admin Section/Complaint’;
import PostalReceive from ’./AdministrationComponent/Admin Section/PostalReceive’;
import PostalDispatch from ’./AdministrationComponent/Admin Section/PostalDispatch’;
import PhoneCallLog from ’./AdministrationComponent/Admin Section/PhoneCallLog’;
import AdminSetup from ’./AdministrationComponent/Admin Section/AdminSetup’;
import IdCardList from ’./AdministrationComponent/Admin Section/IdCardList’;
import StudentCertificate from ’./AdministrationComponent/Admin Section/StudentCertificate’;
import GenerateCertificate from ’./AdministrationComponent/Admin Section/GenerateCertificate’;
import GenerateIDCard from ’./AdministrationComponent/Admin Section/GenerateIDCard’;
import StudentCategory from ’./StudentComponent/StudentInfo/StudentCategory’;
import StudentAdmission from ’./StudentComponent/StudentInfo/StudentAdmission’;
import StudentList from ’./StudentComponent/StudentInfo/StudentList’;
import StudentDetails from ’./StudentComponent/StudentInfo/StudentDetails’;
import ImportStudent from ’./StudentComponent/StudentInfo/ImportStudent’;
const root = ReactDOM.createRoot(document.getElementById(’root’));

let allRoutes = createBrowserRouter([


{
path: ’/’,
element: <App Propscomponent={Dashboard} />
},
{
path: ’/Admission-query’,
element: <App Propscomponent={AdmissionQuery} />
},
{
path: ’/visitor’,
element: <App Propscomponent={VisitorBook} />
},
{
path: ’/complaint’,
element: <App Propscomponent={Complaint} />
},
{
path: ’/postal-receive’,
element: <App Propscomponent={PostalReceive} />
},
{
path: ’/postal-dispatch’,
element: <App Propscomponent={PostalDispatch} />
},
{
path: ’/phone-call’,
element: <App Propscomponent={PhoneCallLog} />
},
{
path: ’/setup-admin’,
element: <App Propscomponent={AdminSetup} />
},
{
path: ’/student-id-card’,
element: <App Propscomponent={IdCardList} />
},
{
path: ’/student-certificate’,
element: <App Propscomponent={StudentCertificate} />
},
{
path: ’/generate-certificate’,
element: <App Propscomponent={GenerateCertificate} />
},
{
path: ’/generate-id-card’,
element: <App Propscomponent={GenerateIDCard} />
},
{
path: ’/student-category’,
element: <App Propscomponent={StudentCategory} />
},
{
path: ’/student-admission/:studentId’,
element: <App Propscomponent={StudentAdmission} />
},
{
path: ’/student-list’,
element: <App Propscomponent={StudentList} />
},
{
path: ’/student-details/:studentId’,
element: <App Propscomponent={StudentDetails} />
},
{
path: ’/import-student’,
element: <App Propscomponent={ImportStudent} />
}
])
root.render(
<React.StrictMode>
<GlobalStyle />
<RouterProvider router={allRoutes} />
</React.StrictMode>
);

reportWebVitals();
import React, { useEffect, useState } from 'react'
import Footer from '../../GlobalComponent/Footer'
import { Link } from 'react-router-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faColumns, faFileArrowDown, faFileExcel, faFilePdf, faFileText, faPlus,
faPrint, faSearch } from '@fortawesome/free-solid-svg-icons'
import DropdownComponent from '../../GlobalComponent/DropdownComponent'
import InputComponent from '../../GlobalComponent/InputComponent'
import axios from 'axios';

const StudentList = () => {


const [data, setData] = useState('');
const [Students, setStudents] = useState([]);
const [filteredStudents, setFilteredStudents] = useState([]);
const [searchTerm, setSearchTerm] = useState('');

useEffect(() => {
const fetchData = async () => {
try {

const response = await


axios.get('http://localhost:8080/student/all');
const jsonData = response.data;
setStudents(jsonData);
setFilteredStudents(jsonData);
} catch (error) {
console.error('Error fetching data:', error);
}
};
fetchData();
}, []);

useEffect(() => {
const filteredData = Students.filter(student =>
student.firstName.toLowerCase().includes(searchTerm.toLowerCase())
);
setFilteredStudents(filteredData);
}, [searchTerm, Students]);

const handleInputChange = (e) => {


setSearchTerm(e.target.value);
};

console.log(Students);
return (
<div className='container'>
<div className=' white-box p-2 ps-3 px-md-3'>
<div className='col d-lg-flex align-items-center justify-
content-between '>
<h3 className='mb-0 ps-0 fw-semibold py-1'>Manage
Student</h3>
<div className='d-flex'>
<Link>
<p className='text-black-50 small me-2'>Dashboard
</p>
</Link>
<p className='text-black-50 small'>|</p>
<Link>
<p className='text-black-50 small mx-2'>Admin
Section</p>
</Link>
<p className='text-black-50 small'>|</p>
<Link>
<p className='text-black-50 small ms-2'>Student
List</p>
</Link>
</div>
</div>
</div>
<div className='row'>
<div className='d-flex align-items-center justify-content-
between'>
<h3>Select Criteria</h3>
<Link to={'/student-admission/id'} className='me-md-3
rounded-5 px-4 fw-semibold small p-1 bg-white a-btn'>
<span><FontAwesomeIcon icon={faPlus} /></span>
<span className='ms-2'>ADD STUDENT</span>
</Link>
</div>
</div>
<div className='white-box py-5'>
<form>
<div className='row'>
<div className='col-lg-4 col-12 my-2 '>
<DropdownComponent optionList={['2024[Jan-Dec]']}
label='ACADEMIC YEAR'
required={true}
/>
</div>
<div className='col-lg-4 my-2 col-12 '>
<DropdownComponent
optionList={['Select Class']}
label='Class'
required={false}
/>
</div>
<div className='col-lg-4 my-2 col-12 '>
<DropdownComponent
optionList={['Select Section']}
label='SECTION'
required={false}
/>

</div>
<div className='col-lg-4 my-2 col-12 '>
<InputComponent
label="SEARCH BY NAME"
type="text"
required={true}
placeholder="Search By Name"
setState={setData}
/>

</div>
<div className='col-lg-4 col-12 my-2'>
<InputComponent
label="SEARCH BY ROLL"
type="text"
required={true}
placeholder="Roll"
setState={setData}
/>
</div>
<div className='col-12 text-end mt-5 '> <a href=''
className='rounded-5 px-4 fw-semibold small p-2 bg-white a-btn'>
<span><FontAwesomeIcon icon={faSearch}
className='' /></span>
<span className='ms-2 text-uppercase '>search</span>
</a></div>
</div>
</form>
</div>

<div className='row'>
<div className='d-sm-flex align-items-center justify-content-
between'>
<h3>Student List</h3>
<div className='border mx-5 mx-sm-0 border-secondary border-
top-0 d-flex align-items-center pb-2 border-start-0 border-end-0'>
<FontAwesomeIcon icon={faSearch} className=' small' />
<input type='text' value={searchTerm}
onChange={handleInputChange} placeholder='Quick Search' className='border-0 bg-
transparent ms-2' />
</div>
<div className='d-none d-xl-block ' >
<ul className='d-flex icon-list rounded-5 px-4 py-0'>
<li ><Link><FontAwesomeIcon icon={faFileArrowDown}
className='text-black-50 p-2 small' /></Link></li>
<li ><Link><FontAwesomeIcon icon={faFileExcel}
className='text-black-50 p-2 small' /></Link></li>
<li ><Link><FontAwesomeIcon icon={faFileText}
className='text-black-50 p-2 small' /></Link></li>
<li ><Link><FontAwesomeIcon icon={faFilePdf}
className='text-black-50 p-2 small' /></Link></li>
<li ><Link><FontAwesomeIcon icon={faPrint}
className='text-black-50 p-2 small' /></Link></li>
<li className='border-0'><Link><FontAwesomeIcon
icon={faColumns} className='text-black-50 p-2 small ' /></Link></li>
</ul>
</div>
</div>
</div>
<div className='white-box '>
<div className='table-responsive'>
<table className='table '>
<thead>
<tr className='table-th border-bottom'>
<th>Admission no</th>
<th>name</th>
<th>Father Name</th>
<th className=' d-none d-md-table-cell'>Date Of
Birth</th>
<th className='d-none d-lg-table-
cell'>Class(Section)</th>
<th className='d-none
d-lg-table-cell'>Gender</th>
<th className='d-none d-xl-table-cell'>Type</th>
<th className='d-none
d-xl-table-cell'>Phone</th>
</tr>
</thead>
<tbody>
{Students && Students.length === 0 ? (
<tr className='table-td'>
<td colSpan="8"><p className='my-3'>No Data
Available In Table</p></td>
</tr>
) : (
filteredStudents && filteredStudents.map((Sdata,
index) => (
<tr className='table-td py-3' key={index}>
<td>{Sdata.admissionNumber }</td>
<td><Link to={`/student-details/$
{Sdata.studentId}`}>{Sdata.firstName} {Sdata.lastName}</Link></td>
<td>{Sdata.fatherName}</td>
<td className='d-none d-md-table-
cell'>{Sdata.dob}</td>
<td className='d-none d-lg-table-
cell'>{Sdata.class}({Sdata.section})</td>
<td className='d-none d-lg-table-
cell'>{Sdata.gender}</td>
<td className='d-none d-xl-table-
cell'>{Sdata.type}</td>
<td className='d-none d-xl-table-
cell'>{Sdata.phone}</td>
</tr>
))
)}
</tbody>
</table>
</div>
</div>
<div aria-label="Page navigation example">
<ul class="pagination justify-content-center ">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true"><p>&laquo;</p></span>
</a>
</li>
<li class="page-item"><a class="page-link"
href="#"><p>1</p></a></li>
<li class="page-item"><a class="page-link"
href="#"><p>2</p></a></li>
<li class="page-item"><a class="page-link"
href="#"><p>3</p></a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true"><p>&raquo;</p></span>
</a>
</li>
</ul>
</div>
<Footer />
</div>
)
}

export default StudentList


import { faCheck, faPlus } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React, { useEffect, useState } from 'react'
import { Link, useParams } from 'react-router-dom'
import Footer from '../../GlobalComponent/Footer'
import DropdownComponent from '../../GlobalComponent/DropdownComponent'
import InputComponent from '../../GlobalComponent/InputComponent'
import axios from 'axios';

const initialData = {
collegeId: null,
courseId: null,
academicYear: "",
class: "",
section: "",
admissionNumber: null,
firstName: "",
lastName: "",
gender: "",
dob: "",
bloodGroup: "",
religion: "",
caste: "",
emailAddress: "",
phone: null,
admissionDate: "",
category: "",
group: "",
height: null,
weight: null,
fatherName: "",
fatherOccupation: "",
fatherNumber: null,
motherName: "",
motherOccupation: "",
motherNumber: null,
guardianName: "",
guardianOccupation: "",
guardianNumber: null,
guardianEmail: "",
guardianAddress: "",
currentAddress: "",
permanentAddress: "",
routeList: "",
vehicleNumber: "",
dormitory: "",
roomNumber: "",
nationalIdCard: "",
birthCertificateNumber: "",
bankAccountNumber: null,
bankName: "",
previousSchoolDetails: "",
additionalNotes: "",
ifscCode: "",
studentPhoto:null,
fatherPhoto:null,
motherPhoto:null,
guardianPhoto:null,
documentsIstPhoto: null,
documentsSecondPhoto: null,
documentsThirdPhoto: null,
documentsFourthPhoto:null
}
const StudentAdmission = () => {
let id = useParams();
const [studentData, setStudentData] = useState(initialData);
const [DropdownList, setDropdownList] = useState(null);
const [file, setFile] = useState('');

useEffect(() => {
const fetchData = async () => {
try {
const response = await
axios.get('http://localhost:8080/setting/all?settingstype=student');
if (id.studentId === 'id') {
const admissionNumber = await
axios.get('http://localhost:8080/student/admissionNumber');
setStudentData(initialData)
setStudentData(studentData => ({
...studentData,
'admissionNumber': admissionNumber.data
}));

} else {
const singleStudent = await
axios.get(`http://localhost:8080/student?studentId=${id.studentId}`);
setStudentData(singleStudent.data);
}
setDropdownList(response.data.data);
} catch (error) {
console.error('Error fetching data:', error);
}
};
fetchData();

}, [id.studentId]);

function selectDropdownList(selected){
if (DropdownList && DropdownList.length > 0) {
const setting = DropdownList.find(item => item.settingKey ===
selected);
if (setting) {
return setting.settingValue;
} else {
return [];
}
}
}
const handleSubmit = async (e) => {
e.preventDefault();
try {

let form = new FormData();

for (const key in studentData) {

form.append(key, studentData[key]);
}
// for (const [key, value] of form.entries()) {
// console.log(`${key}: ${value}`);
// }
console.log('ssssssa', form);

if (id.studentId === 'id') {


const response = await
axios.post('https://localhost:8080/student/', form );
console.log('Data posted successfully:', response.data);
alert('Data Submit successfully')
setStudentData(initialData);
} else {
const response = await
axios.patch(`http://localhost:8080/student/${id.studentId}`);
console.log('Data Updated successfully:', response.data);
alert('Data Updated successfully')
setStudentData(initialData);
}

} catch (error) {
console.error('Error sending form data:', error);
// alert('Error Submit data:')
}

};

console.log(id.studentId);

return (
<div className='container'>
<div className=' white-box p-2 ps-3 px-md-3'>
<div className='col d-lg-flex align-items-center justify-
content-between '>
{id.studentId != 'id' ? <h3 className='mb-0 ps-0 fw-semibold
py-1 '>Modify Student</h3> : <h3 className='mb-0 ps-0 fw-semibold py-1'>Student
Admission</h3>}

<div className='d-flex'>
<Link>
<p className='text-black-50 small me-2'>Dashboard
</p>
</Link>
<p className='text-black-50 small'>|</p>
<Link>
<p className='text-black-50 small mx-2'>Admin
Section</p>
</Link>
<p className='text-black-50 small'>|</p>
<Link>
{id.studentId != 'id' ? <p className='text-black-50
small ms-2'>Modify Student</p> : <p className='text-black-50 small ms-2'>Student
Admission</p>}

</Link>
</div>
</div>
</div>
<div className='row'>
<div className='d-flex align-items-center justify-content-
between'>
<h3>Add Student</h3>
<Link to={'/import-student'} className='me-md-5 rounded-5
px-4 fw-semibold small p-1 bg-white a-btn'>
<span><FontAwesomeIcon icon={faPlus} /></span>
<span className='ms-2 small fw-bold'>IMPORT
STUDENT</span>
</Link>
</div>
</div>
<div className='white-box'>
<div className='col-12'>
<h4 className='small border-bottom pb-1 ps-1'>PERSONAL
INFO</h4>
</div>

<form onSubmit={handleSubmit}>
<div className='row'>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'academicYear'}
setState={setStudentData}
optionList={['2024[Jan-Dec]', '2023-2024',
'2024-2025']}
label='ACADEMIC YEAR '
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'collegeId'}
setState={setStudentData}
optionList={['Select Collage','1','2']}
label='Collage'
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'courseId'}
setState={setStudentData}
optionList={['Select Course','1','2','3']}
label='Course'
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'class'}
setState={setStudentData}
optionList={selectDropdownList('class')}
label='CLASS'
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'section'}
setState={setStudentData}
optionList={selectDropdownList('section')}
label='Section'
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="ADMISSION NUMBER"
type="text"
required={true}
inputName='admissionNumber'
prevData={studentData}
placeholder=""
setState={setStudentData}
isDisabled={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="Roll"
type="text"
required={true}
inputName='rollNumber'
prevData={studentData}
placeholder=""
setState={setStudentData}
isDisabled={true}
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="First Name"
type="text"
required={true}
inputName='firstName'
prevData={studentData}
placeholder=""
setState={setStudentData}
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="LAST NAME "
type="text"
required={true}
inputName='lastName'
prevData={studentData}
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'gender'}
setState={setStudentData}
optionList={['Male','Female','Other']}
label='GENDER'
required={true}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="DATE OF BIRTH"
type="date"
required={false}
prevData={studentData}
inputName='dob'
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'bloodGroup'}
setState={setStudentData}
optionList={selectDropdownList('bloodGroup')}
label='BLOOD GROUP'
required={false}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'religion'}
setState={setStudentData}
optionList={selectDropdownList('religion')}
label='RELIGION'
required={false}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="CASTE "
type="text"
required={false}
inputName='caste'
prevData={studentData}
placeholder=""
setState={setStudentData}
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="EMAIL ADDRESS "
type="email"
required={false}
prevData={studentData}
inputName='emailAddress'
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="PHONE NUMBER"
type="number"
prevData={studentData}
inputName='phone'
required={true}
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="ADMISSION DATE"
type="date"
required={false}
prevData={studentData}
inputName='admissionDate'
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'category'}
setState={setStudentData}
optionList={selectDropdownList('category')}
label='CATEGORY'
required={false}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'group'}
setState={setStudentData}
optionList={selectDropdownList('group')}
label='GROUP'
required={false}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="HEIGHT (IN)"
type="text"
inputName='height'
prevData={studentData}
required={false}
placeholder=""
setState={setStudentData}
bootstrapClass=''
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="WEIGHT (KG)"
type="text"
inputName='weight'
prevData={studentData}
required={false}
placeholder=""
setState={setStudentData}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="Image"
type="file"
required={false}
inputName='studentPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass="custom-file-input"
/>
</div>
<div className='col-12 my-3'>
<h4 className='small border-bottom pb-1 ps-
1'>PARENTS & GUARDIAN INFO</h4>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="FATHER NAME"
type="text"
required={false}
prevData={studentData}
inputName='fatherName'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="OCCUPATION"
type="text"
required={false}
prevData={studentData}
inputName='fatherOccupation'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="FATHER PHONE"
type="text"
required={false}
prevData={studentData}
inputName='fatherNumber'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="FATHERS PHOTO"
type="file"
required={false}
inputName='fatherPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass="custom-file-input"
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="Mother NAME"
type="text"
required={false}
prevData={studentData}
inputName='motherName'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="OCCUPATION"
type="text"
required={false}
prevData={studentData}
inputName='motherOccupation'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="Mother PHONE"
type="text"
required={false}
prevData={studentData}
inputName='motherNumber'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="Mother PHOTO"
type="file"
required={false}
inputName='motherPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass="custom-file-input"
/>
</div>
<div className='my-2 col-12 d-flex align-items-center
justify-content'>
<h4 className='small'>RELATION WITH GUARDIAN</h4>
<div className='d-flex align-items-center mx-sm-3
mx-1'><input type='radio' name='relation' /><p className='ms-2'> Father
</p></div>
<div className='d-flex align-items-center mx-sm-3
mx-1'><input type='radio' name='relation' /> <p
className='ms-2'>Mother</p></div>
<div className='d-flex align-items-center mx-sm-3
mx-1 '><input type='radio' name='relation' /> <p
className='ms-2'>Other</p></div>
</div>

<div className='col-xl-3 col-lg-6 my-2 col-12'>


<InputComponent
label="GUARDIANS NAME"
type="text"
required={false}
prevData={studentData}
inputName='guardianName'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="RELATION WITH GUARDIAN"
type="text"
required={false}
prevData={file}
inputName='d'
placeholder=""
setState={setFile}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="GUARDIANS EMAIL"
type="email"
required={true}
prevData={studentData}
inputName='guardianEmail'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="GUARDIAN PHOTO"
type="file"
required={false}
inputName='guardianPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass=" custom-file-input"
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="GUARDIANS PHONE"
type="text"
required={false}
prevData={studentData}
inputName='guardianNumber'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="GUARDIAN OCCUPATION"
type="text"
required={false}
prevData={studentData}
inputName='guardianOccupation'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="GUARDIAN ADDRESS"
type="text"
required={false}
prevData={studentData}
inputName='guardianAddress'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-12 my-3'>
<h4 className='small border-bottom pb-1 ps-
1'>STUDENT ADDRESS INFO</h4>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="CURRENT ADDRESS"
type="text"
required={false}
prevData={studentData}
inputName='currentAddress'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="PERMANENT ADDRESS"
type="text"
required={false}
prevData={studentData}
inputName='permanentAddress'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-12 my-3'>
<h4 className='small border-bottom pb-1 ps-
1'>TRANSPORT</h4>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'routeList'}
setState={setStudentData}
optionList={selectDropdownList('routeList')}
label='Route List'
required={false}
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'vehicleNumber'}
setState={setStudentData}
optionList={selectDropdownList('vehicleNumber')}
label='Vehicle Number'
required={false}
/>
</div>
<div className='col-12 my-3'>
<h4 className='small border-bottom pb-1 ps-1'>OTHER
INFO</h4>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'dormitory'}
setState={setStudentData}
optionList={selectDropdownList('dormitory')}
label='Dormitory'
required={false}
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<DropdownComponent
prevData={studentData}
dropdownName={'roomNumber'}
setState={setStudentData}
optionList={selectDropdownList('roomNumber')}
label='Room Number'
required={false}
/>

</div>
<div className='col-12 my-3'>
<h4 className='small border-bottom pb-1 ps-
1'>DOCUMENT INFO</h4>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="NATIONAL ID CARD"
type="text"
required={false}
prevData={studentData}
inputName='nationalIdCard'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="Birth Certificate Number"
type="text"
required={false}
prevData={studentData}
inputName='birthCertificateNumber'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="BANK ACCOUNT NUMBER"
type="text"
required={false}
prevData={studentData}
inputName='bankAccountNumber'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="BANK NAME"
type="text"
required={false}
prevData={studentData}
inputName='bankName'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-4 col-lg-6 my-2 col-12'>
<InputComponent
label="PREVIOUS SCHOOL DETAILS"
type="text"
required={false}
prevData={studentData}
inputName='previousSchoolDetails'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-4 col-lg-6 my-2 col-12'>
<InputComponent
label="ADDITIONAL NOTES"
type="text"
required={false}
prevData={studentData}
inputName='additionalNotes'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-4 col-lg-6 my-2 col-12'>
<InputComponent
label="IFSC CODE"
type="text"
required={false}
prevData={studentData}
inputName='ifscCode'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="DOCUMENT 01 TITLE"
type="text"
required={false}
prevData={studentData}
inputName='documentsIst'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>

</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>

<InputComponent
label="DOCUMENT 02 TITLE"
type="text"
required={false}
prevData={studentData}
inputName='documentsSecond'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="DOCUMENT 03 TITLE"
type="text"
required={false}
prevData={studentData}
inputName='documentsThird'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12'>
<InputComponent
label="DOCUMENT 04 TITLE"
type="text"
required={false}
prevData={studentData}
inputName='documentsFourth'
placeholder=""
setState={setStudentData}
bootstrapClass=""
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="01"
type="file"
required={false}
inputName='documentsIstPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass=" custom-file-input"
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="01"
type="file"
required={false}
inputName='documentsSecondPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass=" custom-file-input"
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="01"
type="file"
required={false}
inputName='documentsThirdPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass=" custom-file-input"
/>
</div>
<div className='col-xl-3 col-lg-6 my-2 col-12 pe-0
position-relative'>
<InputComponent
label="01"
type="file"
required={false}
inputName='documentsFourthPhoto'
prevData={studentData}
placeholder=""
setState={setStudentData}
bootstrapClass=" custom-file-input"
/>
</div>
</div>
<div className='d-flex justify-content-center my-4'>
<button type='submit' className='rounded-3 px-4 fw-
semibold small p-2 bg-white a-btn'>
<span><FontAwesomeIcon icon={faCheck}
className='' /></span>
{id.studentId != 'id' ? <span className='ms-2 text-
uppercase '>Update Student</span> : <span className='ms-2 text-uppercase '>Save
Student</span>}
</button>
</div>
</form>
</div>

<Footer />
</div>
)
}

export default StudentAdmission


import { faPlus } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React, { useState } from 'react'
import CustomCalendar from './CustomCalendar';
import Footer from './Footer';

const Dashboard = () => {

const [date, setDate] = useState(new Date());

const onChange = date => {


setDate(date);

};
return (
<>
<div className='container'>
<h3>Welcome - Aayojaan School | Super admin</h3>
<div className='row'>
<div className='col-lg-3 col-md-6 col-sm-6 '>
<a href='' className='d-block text-decoration-none '>
<div className='white-box-hover white-box d-flex
justify-content-between'>
<div className=''>
<h3 className='p-0 m-0 fw-
semibold'>Student</h3>
<p>Total Students</p>
</div>
<h4 className='text-warning'>2</h4>
</div>
</a>
</div>
<div className='col-lg-3 col-md-6 col-sm-6 '>
<a href='' className='d-block text-decoration-none '>
<div className='white-box white-box-hover d-flex
justify-content-between'>
<div className=''>
<h3 className='p-0 m-0 fw-
semibold'>Teachers</h3>
<p>Total Teachers</p>
</div>
<h4 className='text-warning'>0</h4>
</div>
</a>
</div>
<div className='col-lg-3 col-md-6 col-sm-6 '>
<a href='' className='d-block text-decoration-none '>
<div className='white-box white-box-hover d-flex
justify-content-between'>
<div className=''>
<h3 className='p-0 m-0 fw-
semibold'>Parents</h3>
<p>Total Parents</p>
</div>
<h4 className='text-warning'>2</h4>
</div>
</a>
</div>
<div className='col-lg-3 col-md-6 col-sm-6 '>
<a href='' className='d-block text-decoration-none '>
<div className='white-box white-box-hover d-flex
justify-content-between'>
<div className=''>
<h3 className='p-0 m-0 fw-
semibold'>Staffs</h3>
<p>Total Staffs</p>
</div>
<h4 className='text-warning'>0</h4>
</div>
</a>
</div>

</div>
<h3>Income and Expenses for Jun 2023</h3>
<div className='white-box'>
<div className='row '>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 0</h1>
<p>Total Income</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 0</h1>
<p>Total Expenses</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 0</h1>
<p>Total Profit</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 0</h1>
<p>Total Revenue</p>
</div>
</div>
<div className='row px-md-5'>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
</div>
</div>
</div>
<h3>Income and Expenses for 2023</h3>
<div className='white-box'>
<div className='row '>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 1,000</h1>
<p>Total Income</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 0</h1>
<p>Total Expenses</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 1,000</h1>
<p>Total Profit</p>
</div>
</div>
<div className='col-lg-2 col-md-6 col-6 mx-auto'>
<div className='text-center'>
<h1>(₹) 1,000</h1>
<p>Total Revenue</p>
</div>
</div>
<div className='row px-md-5'>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
<div className='col-12 my-3'><hr /></div>
</div>
</div>
</div>

<div className='row'>
<div className='d-flex align-items-center justify-content-
between'>
<h3>Notice Board</h3>
<a href='' className='me-md-5 rounded-5 px-4 fw-semibold
small p-1 bg-white a-btn'>
<span><FontAwesomeIcon icon={faPlus} /></span>
<span className='ms-2'>ADD</span>
</a>
</div>
<div className='col-lg-12'>
<div className='white-box'>
<table className='w-100'>
<thead>
<tr className="table-th">
<th>Date</th>
<th>Title</th>
<th className='d-flex justify-content-
around'>Actions</th>
</tr>
</thead>
<tbody>

</tbody>
</table>
</div>
</div>
</div>
<div className='row'>
<div className='col-lg-8 col-12'>
<h3>Calendar</h3>
<div className="white-box">
<div className="card-body p-sm-2">
<CustomCalendar
onChange={onChange}
value={date}
className="custom-calendar"
/>
</div>
</div>
</div>
<div className='col-lg-4 col-12 '>
<div className='d-flex justify-content-between align-
items-baseline'>
<h3>To Do List</h3>
<a href='' className='me-md-5 rounded-5 px-4 fw-
semibold small p-1 bg-white a-btn'>
<span><FontAwesomeIcon icon={faPlus} /></span>
<span className='ms-2'>ADD</span>
</a>
</div>
<div className='col-12'>
<div className='white-box py-4 mt-2'>
<div className='d-flex justify-content-between'>
<a href='' className=' rounded-5 fw-semibold
small p-2 py-1 a-btn'>
<span className='fw-semibold text-
uppercase '>Incomplete</span>
</a>
<a href='' className=' rounded-5 fw-semibold
small p-2 py-1 bg-gradient a-btn'>
<span className='fw-semibold text-
uppercase text-primary-emphasis'>completed</span>
</a>
</div>
<p className='text-black-50 small my-3'>No Do
Lists Assigned Yet</p>
</div>
</div>
</div>
</div>
<Footer />
</div>
</>
)
}

export default Dashboard


Student

import {addStudent ,getAllStudents


,getSingleStudentDetail,importStudentData,updateStudentDetails,deleteStudentDetail,getEmptyEnrollNu
mber } from "../controllers/studentController.js"

// router
import {Router} from ’express’
const router = Router();

router.post(’/’, addStudent);

router.get(’/all’, getAllStudents);

router.get(’/’, getSingleStudentDetail);

router.post(’/import’, importStudentData);

router.patch(’/:studentId’, updateStudentDetails);

router.delete(’/:studentId’, deleteStudentDetail);

router.get(’/emptyEnrollNumber’, getEmptyEnrollNumber);

export default router;

Controller For Request or Response

import { checkEmail, checkEnroll } from ’../repository/studentRepository.js’;


import * as studentService from ’../services/studentService.js’

// 1. create student
export const addStudent = async (req,res) => {
const file = req.files;
let {universityId,campusId,instituteId,affiliatedUniversityId,courseLevelId,courseId,email,enrollNumber}
= req.body
const checkExistingEmail = await checkEmail(email)
const checkExistingEnroll = await checkEnroll(enrollNumber)
try {
if (!(universityId && campusId && instituteId && affiliatedUniversityId && courseLevelId &&
courseId)){
res.status(400).send("universityId,campusId,instituteId,affiliatedUniversityId,courseLevelId and
courseId is required");
}
if(email){
if(checkExistingEmail){
if (email.toLowerCase() === checkExistingEmail.dataValues.email.toLowerCase()){
res.status(400).send("Email is already existing");
}
}
}else{
res.status(400).send("email is required");
}
if(enrollNumber){
if(checkExistingEnroll){
if (enrollNumber.toLowerCase() ===
checkExistingEnroll.dataValues.enroll_number.toLowerCase()){
res.status(400).send("Enroll is already existing");
}
}
}
const info = req.body
const result = await studentService.addStudent(info,file);
res.status(200).send(result);
} catch (error) {
console.error("Error in add Student:", error);
res.status(500).send("Internal Server Error");
}
};

// 2. get all student


export const getAllStudents = async (req,res) => {
let {search} = req.query
search = search || ’all’
try {
const result = await studentService.getAllStudents(search);
res.status(200).send(result);
} catch (error) {
console.error("Error in getting all student details:", error);
res.status(500).send("Internal Server Error");
}
};

// 3. get single student details


export const getSingleStudentDetail = async (req,res) => {
const studentId = req.query.studentId;
try {
if (!studentId){
res.status(400).send("studentId is required");
}
const result = await studentService.getSingleStudentDetail(studentId);
res.status(200).send(result);
} catch (error) {
console.error(‘Error in getting ${studentId} details , single student details:‘, error);
res.status(500).send("Internal Server Error");
}
};

// import student data

export const importStudentData = async (req,res) => {


const files = req.files.student.name;
const file = req.files;
const fileType = files.split(’.’).pop();
try {
await studentService.importStudentData(fileType,file);
// await importService.importFile(fileType,file);
res.status(200).send({ message: ’Data imported successfully’ });
} catch (error) {
res.status(500).send({ error: error.message });
}
};

// update student
export const updateStudentDetails = async (req,res) => {
const {studentId,universityId,campusId,instituteId,affiliatedUniversityId,courseLevelId,courseId} =
req.body;
const info = req.body;
const file = req.files;
try {
if (!(studentId && universityId && campusId && instituteId && affiliatedUniversityId && courseLevelId
&& courseId )){
res.status(400).send("student
Id,universityId,campusId,instituteId,affiliatedUniversityId,courseLevelId and courseId is required");
}
const result = await studentService.updateStudentDetails(studentId, info,file);
res.status(200).send(result);
} catch (error) {
console.error(‘Error in updating student Id ${studentId} and ${campusId}:‘, error);
res.status(500).send("Internal Server Error");
}
};

export const deleteStudentDetail = async (req,res) => {


const {studentId} = req.params;
try {
if (!studentId){
res.status(400).send("student Id is required");
}else{
const result = await studentService.deleteStudentDetail(studentId);
res.status(200).send(result);
}
} catch (error) {
console.error(‘Error in deleting student Id ${studentId}:‘, error);
res.status(500).send("Internal Server Error");
}
};

export const getEmptyEnrollNumber = async (req,res) => {


const studentId = req.query.studentId;
try {
const result = await studentService.getEmptyEnrollNumber(studentId);
res.status(200).send(result);
} catch (error) {
console.error(‘Error in getting EMpty Enroll Number:‘, error);
res.status(500).send("Internal Server Error");
}
};

Services FIle For logic

import { getCourseCode,getInstituteCode } from ’../repository/collegeRepository.js’;


import * as studentRepository from ’../repository/studentRepository.js’;
import * as fileHandler from ’../utility/fileHandler.js’;
import moment from ’moment’;
import { uploadFile } from ’../utility/awsServices.js’;
import sequelize from ’../database/sequelizeConfig.js’;
import { getSettingValue } from ’../repository/settingRepository.js’;

export async function addStudent(info, files) {


const transaction = await sequelize.transaction();
try {
// Upload files and update info object
const uploadPromises = Object.keys(files).map(async key => {
const file = files[key];
const s3Response = await uploadFile(file);
info[key] = s3Response.Location;
});

await Promise.all(uploadPromises);

// Documents status
const settingKey = ’studentDocument’;
const getstudentDocuments = await getSettingValue(settingKey);
const studentRequiredDocuments = getstudentDocuments.dataValues.setting_value;
let allFilesUploaded = true;
for (let i = 0; i < studentRequiredDocuments.length; i++) {
const key = studentRequiredDocuments[i];
if (!info[key]) {
allFilesUploaded = false;
break;
}
}

if (allFilesUploaded) {
info.documentStatus = ’Complete Documents’;
}

info.scholarNumber = await generateScholarNumber(info.courseId,info.instituteId);


info.email = info.email.toLowerCase();
const newStudent = await studentRepository.addStudent(info, { transaction });
await transaction.commit();
return newStudent;
} catch (error) {
await transaction.rollback();
console.error(’Error adding student:’, error);
throw error;
}
}

async function generateScholarNumber(courseId,instituteId) {


const getCourseCodeDetail = await getCourseCode(courseId);
const getInstitueCodeDetail = await getInstituteCode(instituteId);
const courseCode = getCourseCodeDetail.get(’course_code’);
const institueCode = getInstitueCodeDetail.get(’institute_code’);
const getPreviousScholarNumber = await studentRepository.getPreviousScholarNumber(institueCode);
const previousScholarNumber = getPreviousScholarNumber ?
getPreviousScholarNumber.get(’scholar_number’) : null;
let scholarNumber;
if (previousScholarNumber) {
const scholarNumberParts = previousScholarNumber.split(’/’);
const scholarNumberPrefix = scholarNumberParts.slice(0, 3).join(’/’);
const scholarNumberSuffix = parseInt(scholarNumberParts[3]) + 1;
scholarNumber = ‘${scholarNumberPrefix}/${scholarNumberSuffix.toString().padStart(6, ’0’)}‘;
} else {
const yearLastTwoDigits = moment().format(’YY’);
scholarNumber = ‘${institueCode}/${courseCode}/${yearLastTwoDigits}/100001‘;
}
return scholarNumber;
};

export async function getAllStudents(search){


return await studentRepository.getAllStudents(search)
};

export async function getSingleStudentDetail(studentId){


return await studentRepository.getSingleStudentDetail(studentId)
};

export async function importStudentData(fileType,file){


try {
let data;
if (fileType === ’csv’) {
data = await fileHandler.readCSV(file);
} else if (fileType === ’xlsx’ || fileType === ’xls’) {
data = await fileHandler.readExcel(file);
} else {
throw new Error(’Unsupported file type’);
}
await addAdmissionNoForBulkImport(data)
} catch (error) {
throw new Error(’Error importing file data: ’ + error.message);
}
};

export async function addAdmissionNoForBulkImport(data) {


try {
const results = [];
for (const bulk of data) {
const scholarNumber = await generateScholarNumber(bulk.courseId,bulk.instituteId);
const studentData = { ...bulk,scholarNumber};
const result = await studentRepository.addStudent(studentData);
results.push(result);
}
return results;
} catch (error) {
console.error("Error in Adding AdmissionNumber in bulk Import:", error.message);
throw error;
}
};

export async function updateStudentDetails(StudentId, info, files) {


const transaction = await sequelize.transaction();
const settingKey = ’studentDocument’;
const getstudentDocuments = await getSettingValue(settingKey);
console.log(‘>>>>>>>>getstudentDocuments>>>>>>..‘,getstudentDocuments);
const studentRequiredDocuments = getstudentDocuments.dataValues.setting_value;
try {
if (files && typeof files === ’object’) {
// Upload files and update info object
const uploadPromises = Object.keys(files).map(async key => {
const file = files[key];
if (file) {
const s3Response = await uploadFile(file);
info[key] = s3Response.Location;
}
});
await Promise.all(uploadPromises);
}

//update documents status


let allFilesUploaded = true;
for (let i = 0; i < studentRequiredDocuments.length; i++) {
const key = studentRequiredDocuments[i];
if (!info[key]) {
allFilesUploaded = false;
break;
}
}

if (allFilesUploaded) {
info.documentStatus = ’Complete Documents’;
}

const result = await studentRepository.updateStudentDetails(StudentId, info, { transaction });


await transaction.commit();
return result;
} catch (error) {
await transaction.rollback();
console.error(’Error updating student:’, error);
throw error;
}
};

export async function deleteStudentDetail(studentId) {


try {
const result = await studentRepository.deleteStudentDetail(studentId);
if (result) {
return { message: ’Student deleted successfully’ };
} else {
return { message: ’No student found with the given ID’ };
}
} catch (error) {
console.error(’Error deleting student:’, error);
return { message: ’An error occurred while trying to delete the student’, error: error.message };
}
};

export async function getEmptyEnrollNumber(){


return await studentRepository.getEmptyEnrollNumber()
};

Repository File For Database

import * as model from ’../models/index.js’


import { Op } from ’sequelize’;

export async function addStudent(data) {


try {
const result = await model.studentModel.create(data);
return result;
} catch (error) {
console.error("Error in add Student:", error);
throw error;
}
};

export async function getAllStudents(firstName) {


let result;
try {
if (firstName !== ’all’) {
result = await model.studentModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt"] },
include: [
{
model: model.campusModel,
as: "campus",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","campusId","campusCode"] },
},
{
model: model.instituteModel,
as: "institute",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","instituteId","campusId","instituteCode"] },
},
{
model: model.affiliatedIniversityModel,
as: "affiliatedUniversity",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","affiliatedUniversityId","instituteId","affiliatedUniversityCode"] },
},
{
model: model.courseLevelModel,
as: "courseLevel",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt", "collegeId",
"universityId","courseLevelId","affiliatedUniversityId","courseLevelCode"] },
},
{
model: model.courseModel,
as: "course",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","courseId","course_levelId","courseCode"] },
},
{
model: model.specializationModel,
as: "specialization",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","specializationId","course_Id","specializationCode"] },
}
],
where: {
first_name: {
[Op.like]: ‘%${firstName}%‘
},
},
});
} else {
result = await model.studentModel.findAll({
include: [
{
model: model.campusModel,
as: "campus",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","campusId","campusCode"] },
},
{
model: model.instituteModel,
as: "institute",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","instituteId","campusId","instituteCode"] },
},
{
model: model.affiliatedIniversityModel,
as: "affiliatedUniversity",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","affiliatedUniversityId","instituteId","affiliatedUniversityCode"] },
},
{
model: model.courseLevelModel,
as: "courseLevel",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt", "collegeId",
"universityId","courseLevelId","affiliatedUniversityId","courseLevelCode"] },
},
{
model: model.courseModel,
as: "course",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","courseId","course_levelId","courseCode"] },
},
{
model: model.specializationModel,
as: "specialization",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","specializationId","course_Id","specializationCode"] },
}
],
});
};
return result;
} catch (error) {
console.error(‘Error in getting student name${firstName}:‘, error);
throw error;
};
};

export async function getSingleStudentDetail(studentId) {


try {
const result = await model.studentModel.findOne({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt"] },
include: [
{
model: model.campusModel,
as: "campus",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","campusId","campusCode"] },
},
{
model: model.instituteModel,
as: "institute",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","instituteId","campusId","instituteCode"] },
},
{
model: model.affiliatedIniversityModel,
as: "affiliatedUniversity",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","affiliatedUniversityId","instituteId","affiliatedUniversityCode"] },
},
{
model: model.courseLevelModel,
as: "courseLevel",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt", "collegeId",
"universityId","courseLevelId","affiliatedUniversityId","courseLevelCode"] },
},
{
model: model.courseModel,
as: "course",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","courseId","course_levelId","courseCode"] },
},
{
model: model.specializationModel,
as: "specialization",
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt",
"universityId","specializationId","course_Id","specializationCode"] },
}
],
where: {
student_id: studentId
},
});
return result;
} catch (error) {
console.error(‘Error in ${studentId}:‘, error);
throw error;
};
};

export async function getPreviousScholarNumber(instituteCode) {


try {
const attribute = ["scholar_number"];
const result = await model.studentModel.findOne({
attributes: attribute,
where: {
scholar_number: {
[Op.regexp]: ‘^${instituteCode}(/|$)‘
}
},
order: [[’scholar_number’, ’DESC’]]
});
return result;
} catch (error) {
console.error(‘Error in getPreviousScholarNumber for institue Code ${institueCode}:‘, error);
throw error;
}
};

export async function updateStudentDetails(studentId, data) {


try {
const result = await model.studentModel.update(data, {
where: {
studentId: studentId
}
});
return result;
} catch (error) {
console.error(‘Error updating student details ${studentId} :‘, error);
throw error;
}
};

export async function checkEmail(email) {


try {
const attribute = ["email"];
const result = await model.studentModel.findOne({
attributes: attribute,
where: {
email: email
}
});
return result;
} catch (error) {
console.error(‘Error in check Email for ${email}:‘, error);
throw error;
}
};

export async function checkEnroll(enrollNumber) {


try {
const attribute = ["enroll_number"];
const result = await model.studentModel.findOne({
attributes: attribute,
where: {
enrollNumber: enrollNumber
}
});
return result;
} catch (error) {
console.error(‘Error in check Email for ${email}:‘, error);
throw error;
}
};

export async function getEmptyEnrollNumber() {


try {
// const attributes = ["first_name","father_name"];
const result = await model.studentModel.findAll({
// attributes: attributes,
where: {
enrollNumber: {
[Op.or]: [null, ’’]
}
}
});
return result;
} catch (error) {
console.error(’Error in checkEnroll Empty:’, error);
throw error;
}
};

export async function deleteStudentDetail (studentId) {


try {
const result = await model.studentModel.destroy({
where: { studentId },
individualHooks: true
});
return { message: ’Student deleted successfully’ };
} catch (error) {
console.error(’Error during soft delete:’, error);
throw new Error(’Unable to soft delete account’);
}
};

Image Upload To AWS

export const uploadFile = async (file) => {


const date = moment().format(’YYYYMMDD_HHmmss’);
const params = {
Bucket: process.env.AWS_BUCKET_NAME,
Key: ’university/’ + ’dev/’ + date + file.name,
Body: file.data
// ACL: ’public-read’
};
return new Promise(async (resolve, reject) => {
s3.upload(params, async (error, data) => {
if (error) {
console.log(‘In Error while uploading ${error}‘);
reject(error);
}
resolve(data);
});
})
};

Excel/CSV File Bulk Import Data

import csv from ’csv-parser’;


import fs from ’fs’;
import xlsx from ’xlsx’;

export const readCSV = (file) => {


return new Promise((resolve, reject) => {
const results = [];
const filePath = file.tempFilePath || file.student.data;
console.log(‘>>>>>>>>>>>>>>>file.student.data‘,file.student.data);
if (!fs.existsSync(filePath)) {
return reject(new Error(’CSV file not found’));
}

fs.createReadStream(filePath)
.pipe(csv())
.on(’data’, (data) => results.push(data))
.on(’end’, () => resolve(results))
.on(’error’, (error) => reject(new Error(’Error reading CSV file: ’ + error.message)));
});
};

export const readExcel = (file) => {


return new Promise((resolve, reject) => {
try {
const workbook = xlsx.read(file.student.data);
const sheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[sheetName];
const data = xlsx.utils.sheet_to_json(worksheet);
resolve(data);
} catch (error) {
reject(error);
}
});
};
DashBoard

import {Router} from ’express’;


const router = Router();
import
{getAllCollegesAndCourses,addCampus,addInstitute,addAffiliatedUniversity,addCourseLevel,addCourse,
addSpecialization} from ’../controllers/mainController.js’;

router.get(’/all’, getAllCollegesAndCourses);

router.post(’/campus’, addCampus);

router.post(’/institute’, addInstitute);

router.post(’/affiliatedUniversity’, addAffiliatedUniversity);

router.post(’/affiliatedUniversity’, addAffiliatedUniversity);

router.post(’/courseLevel’, addCourseLevel);

router.post(’/course’, addCourse);

router.post(’/specialization’, addSpecialization);

export default router;

import * as mainServices from ’../services/mainServices.js’;

export const getAllCollegesAndCourses = async (req,res) => {


try {
const universityId = req.query.universityId;
if(!universityId){
res.status(400).send(’University Id is required’)
}
const result = await mainServices.getAllCollegesAndCourses(universityId);
res.status(200).send(result);
} catch (error) {
console.error("Error in getting all course:", error);
res.status(500).send("Internal Server Error");
}
};

export const addCampus = async (req,res) => {


try {
const {universityId} = req.body;
const data = req.body
if(!universityId){
res.status(400).send(’University Id is required’)
}
const result = await mainServices.addCampus(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Campus:", error);
res.status(500).send("Internal Server Error");
}
};

export const addInstitute = async (req,res) => {


try {
const {universityId,campusId} = req.body;
const data = req.body
if(!(universityId && campusId)){
res.status(400).send(’University Id and Campus Id is required’)
}
const result = await mainServices.addInstitute(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Institute:", error);
res.status(500).send("Internal Server Error");
}
};

export const addAffiliatedUniversity = async (req,res) => {


try {
const {universityId,instituteId} = req.body;
const data = req.body
if(!(universityId && instituteId)){
res.status(400).send(’University Id and institute Id is required’)
}
const result = await mainServices.addAffiliatedUniversity(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Affiliated University:", error);
res.status(500).send("Internal Server Error");
}
};

export const addCourseLevel = async (req,res) => {


try {
const {universityId,affiliatedUniversityId} = req.body;
const data = req.body
if(!(universityId && affiliatedUniversityId)){
res.status(400).send(’University Id and affiliated UniversityId is required’)
}
const result = await mainServices.addCourseLevel(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Course Level:", error);
res.status(500).send("Internal Server Error");
}
};

export const addCourse = async (req,res) => {


try {
const {universityId,course_levelId} = req.body;
const data = req.body
if(!(universityId && course_levelId)){
res.status(400).send(’University Id and course_level Id is required’)
}
const result = await mainServices.addCourse(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Course:", error);
res.status(500).send("Internal Server Error");
}
};

export const addSpecialization = async (req,res) => {


try {
const {universityId,course_Id} = req.body;
const data = req.body
if(!(universityId && course_Id)){
res.status(400).send(’University Id and course Id is required’)
}
const result = await mainServices.addSpecialization(data);
res.status(200).send(result);
} catch (error) {
console.error("Error in Add Course:", error);
res.status(500).send("Internal Server Error");
}
};

import * as mainRepository from ’../repository/mainRepository.js’;

export async function getAllCollegesAndCourses(universityId) {


try {
const [ allUniversity, allCampus, allInstitute, allAffiliatedIniversity, allCourseLevel,
allCourse,allSpecialization ]=
await Promise.all([
mainRepository.getAllUniversity(universityId),
mainRepository.getAllCampus(universityId),
mainRepository.getAllInstitute(universityId),
mainRepository.getAllAffiliatedUniversity(universityId),
mainRepository.getAllCourseLevel(universityId),
mainRepository.getAllCourse(universityId),
mainRepository.getAllSpecialization(universityId)
]);

return {
allUniversity,
allCampus,
allInstitute,
allAffiliatedIniversity,
allCourseLevel,
allCourse,
allSpecialization
};
} catch (error) {
console.error(’Error fetching all Course details:’, error);
throw error;
}
};
export async function addCampus(data) {
const { universityId, campuses } = data;
try {
const createdCampuses = [];
for (const campus of campuses) {
const campusData = { ...campus, universityId };
const createdCampus = await mainRepository.addCampus(campusData);
createdCampuses.push(createdCampus);
}
return createdCampuses;
} catch (error) {
console.error(’Add Campus Error in Service:’, error);
throw error;
}
};

export async function addInstitute(data) {


const results = [];
try {
const { campusId, universityId, institutes } = data;
for (const institute of institutes) {
const result = await mainRepository.addInstitute({
...institute,
campusId,
universityId
});
results.push(result);
}
return results;
} catch (error) {
console.error(’Error adding institutes:’, error);
return { message: ’Error adding institutes’, error };
}
}

export async function addAffiliatedUniversity(data) {


const results = [];
try {
const { instituteId, universityId, affiliatedUniversities } = data;

for (const affiliatedUniversity of affiliatedUniversities) {


const result = await mainRepository.addAffiliatedUniversity({
...affiliatedUniversity,
instituteId,
universityId
});
results.push(result);
}
return results;
} catch (error) {
console.error(’Error adding affiliated universities:’, error);
return { message: ’Error adding affiliated universities’, error };
}
}
export async function addCourseLevel(data) {
const results = [];
try {
const { affiliatedUniversityId, universityId, courseLevels } = data;

for (const courseLevel of courseLevels) {


const result = await mainRepository.addCourseLevel({
...courseLevel,
affiliatedUniversityId,
universityId
});
results.push(result);
}
return results;
} catch (error) {
console.error(’Error adding course levels:’, error);
return { message: ’Error adding course levels’, error };
}
}

export async function addCourse(data) {


const results = [];
try {
const { course_levelId, universityId, courses } = data;

for (const course of courses) {


const result = await mainRepository.addCourse({
...course,
course_levelId,
universityId
});
results.push(result);
}
return results;
} catch (error) {
console.error(’Error adding courses:’, error);
return { message: ’Error adding courses’, error };
}
};

export async function addSpecialization(data) {


const results = [];
try {
const { course_Id, universityId, specializations } = data;

for (const specialization of specializations) {


const result = await mainRepository.addSpecialization({
...specialization,
course_Id,
universityId
});
results.push(result);
}
return results;
} catch (error) {
console.error(’Error adding specializations:’, error);
return { message: ’Error adding specializations’, error };
}
};

import * as model from ’../models/index.js’;

export async function getAllUniversity(universityId) {


try {
const result = await model.universityModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all university details:", error);
throw error;
}
};

export async function getAllCampus(universityId) {


try {
const result = await model.campusModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all Campus details:", error);
throw error;
}
};

export async function getAllInstitute(universityId) {


try {
const result = await model.instituteModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all institute details:", error);
throw error;
}
};
export async function getAllAffiliatedUniversity(universityId) {
try {
const result = await model.affiliatedIniversityModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all Affiliated University details:", error);
throw error;
}
};

export async function getAllCourseLevel(universityId) {


try {
const result = await model.courseLevelModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all Course Level details:", error);
throw error;
}
};

export async function getAllCourse(universityId) {


try {
const result = await model.courseModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all course details:", error);
throw error;
}
};

export async function getAllSpecialization(universityId) {


try {
const result = await model.specializationModel.findAll({
attributes: { exclude: ["createdAt", "updatedAt", "deletedAt","universityId"] },
where: {
university_id: universityId
},
});
return result;
} catch (error) {
console.error("Error in get all Specialization details:", error);
throw error;
}
};

// for Add

export async function addCampus(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.campusModel.create(data);
return result;
} catch (error) {
console.error("Error in Add campus:", error);
throw error;
}
};

export async function addInstitute(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.instituteModel.create(data);
return result;
} catch (error) {
console.error("Error in Add Institute:", error);
throw error;
}
};

export async function addAffiliatedUniversity(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.affiliatedIniversityModel.create(data);
return result;
} catch (error) {
console.error("Error in add Affiliated Universit:", error);
throw error;
}
};

export async function addCourseLevel(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.courseLevelModel.create(data);
return result;
} catch (error) {
console.error("Error in add Course Level:", error);
throw error;
}
};

export async function addCourse(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.courseModel.create(data);
return result;
} catch (error) {
console.error("Error in add Course :", error);
throw error;
}
};

export async function addSpecialization(data) {


console.log(‘>>>>>>>>>data>>>>>>‘,data);
try {
const result = await model.specializationModel.create(data);
return result;
} catch (error) {
console.error("Error in add specialization :", error);
throw error;
}
};
Student Model
import sequelize from "../database/sequelizeConfig.js";
import { DataTypes } from ’sequelize’;
import university from ’./universityModel.js’;
import campus from ’./campusModel.js’;
import institute from ’./instituteModel.js’;
import affiliatedUniversity from ’./affiliatedUniversityModel.js’;
import courseLevel from ’./courseLevelModel.js’;
import course from ’./courseModel.js’;
import specialization from "./specializationModel.js";

export default sequelize.define(


’students’,
{
studentId: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
field: ’student_id’
},
universityId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’university_id’,
references: {
model: university,
key: ’university_id’
}
},
campusId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’campus_id’,
references: {
model: campus,
key: ’campus_id’
}
},
instituteId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’institute_id’,
references: {
model: institute,
key: ’institute_id’
}
},
affiliatedUniversityId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’affiliated_university_id’,
references: {
model: affiliatedUniversity,
key: ’affiliated_university_id’
}
},
courseLevelId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’course_level_id’,
references: {
model: courseLevel,
key: ’course_level_id’
}
},
courseId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’course_id’,
references: {
model: course,
key: ’course_id’
}
},
specializationId: {
type: DataTypes.INTEGER,
allowNull: true,
field: ’specialization_id’,
references: {
model: specialization,
key: ’specialization_id’
}
},
formSession:{
type: DataTypes.ENUM(...formSession),
allowNull: true,
field:’form_session’,
},
firstName:{
type:DataTypes.STRING,
allowNull: false,
field:’first_name’
},
middleName:{
type: DataTypes.STRING,
allowNull: true,
field:’middle_name’,
},
lastName:{
type: DataTypes.STRING,
allowNull:true,
field:’last_name’
},
bloodGroup:{
type:DataTypes.ENUM(...bloodGroup),
allowNull: true,
field:’blood_group’
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’created_at’
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’updated_at’
},
deletedAt: {
type: DataTypes.DATE,
allowNull: true,
field: ’deleted_at’
},
},
{
tableName: ’students’,
timestamps: true,
paranoid: true
}
);
University Model

import sequelize from "../database/sequelizeConfig.js";


import { DataTypes } from ’sequelize’;

export default sequelize.define(


’university’,
{
universityId: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
field: ’university_id’
},
universityName: {
type: DataTypes.STRING,
allowNull: false,
field: ’university_name’
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’created_at’
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’updated_at’
},
deletedAt: {
type: DataTypes.DATE,
allowNull: true,
field: ’deleted_at’
},
},
{
tableName: ’university’,
timestamps: true,
paranoid: true
}
);

Campus Model

import sequelize from "../database/sequelizeConfig.js";


import { DataTypes } from ’sequelize’;
import university from "./universityModel.js";

export default sequelize.define(


’campus’,
{
campusId: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
field: ’campus_id’
},
universityId: {
type: DataTypes.INTEGER,
allowNull: false,
field: ’university_id’,
references: {
model: university,
key: ’university_id’
}
},
campusName: {
type: DataTypes.STRING,
allowNull: false,
field: ’campus_name’
},
campusCode:{
type: DataTypes.STRING,
allowNull: false,
field: ’campus_code’,
},
latitude: {
type: DataTypes.FLOAT,
allowNull: true,
},
longitude:{
type: DataTypes.FLOAT,
allowNull: true,
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’created_at’
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal(’CURRENT_TIMESTAMP’),
field: ’updated_at’
},
deletedAt: {
type: DataTypes.DATE,
allowNull: true,
field: ’deleted_at’
},
},
{
tableName: ’campus’,
timestamps: true,
paranoid: true
}
);

You might also like