Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added wrapper #21

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions database/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const Certificate = sequelize.define('certificates', {
course_name: {
type: DataTypes.STRING,
allowNull: true
},
no_copies : {
type: DataTypes.INTEGER,
allowNull: true
}
}, {
freezeTableName: true
Expand Down
Binary file added public/public/bonafide-new.pdf
Binary file not shown.
105 changes: 105 additions & 0 deletions public/src/404/404.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#notfound {
position: relative;
height: 100vh;
}

#notfound .notfound {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

.notfound {
max-width: 460px;
width: 100%;
text-align: center;
line-height: 1.4;
}

.notfound .notfound-404 {
position: relative;
width: 180px;
height: 180px;
margin: 0px auto 50px;
}

.notfound .notfound-404 > div:first-child {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: #ffa200;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
border: 5px dashed #000;
border-radius: 5px;
}

.notfound .notfound-404 > div:first-child:before {
content: "";
position: absolute;
left: -5px;
right: -5px;
bottom: -5px;
top: -5px;
-webkit-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, 0.1) inset;
border-radius: 5px;
}

.notfound .notfound-404 h1 {
font-family: "Cabin", sans-serif;
color: #000;
font-weight: 700;
margin: 0;
font-size: 90px;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
left: 50%;
text-align: center;
height: 40px;
line-height: 40px;
}

.notfound h2 {
font-family: "Cabin", sans-serif;
font-size: 33px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 7px;
}

.notfound p {
font-family: "Cabin", sans-serif;
font-size: 16px;
color: #000;
font-weight: 400;
}

.notfound a {
font-family: "Cabin", sans-serif;
display: inline-block;
padding: 10px 25px;
background-color: #8f8f8f;
border: none;
border-radius: 40px;
color: #fff;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
text-decoration: none;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}

.notfound a:hover {
background-color: #2c2c2c;
}
23 changes: 23 additions & 0 deletions public/src/404/404.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import "./404.css";

function NotFound() {
return (
<div id="notfound">
<div className="notfound">
<div className="notfound-404">
<div></div>
<h1>404</h1>
</div>
<h2>Page not found</h2>
<p>
The page you are looking for might have been removed, had its name
changed or is temporarily unavailable.
</p>
<a href="/">home page</a>
</div>
</div>
);
}

export default NotFound;
38 changes: 23 additions & 15 deletions public/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,43 @@ import Login from "./login/login";
import Footer from "./footer/footer";
import Student from "./student/student";
import Admin from "./admin/admin.jsx";
import NotFound from "./404/404";
import { Switch, Route, BrowserRouter as Router } from "react-router-dom";
import { Redirect } from "react-router-dom/cjs/react-router-dom.min";

const PrivateRoutes = () => {
let token = JSON.parse(localStorage.getItem("bonafideNITT2020user"));
return token ? (
isNaN(token.user) ? (
<Route component={Admin} path="/admin" exact />
) : (
<Route component={Student} path="/student" exact />
)
) : (
<Redirect to="/" />
);
const MainRoutes = () => {
if (
window.location.pathname === "/student" ||
window.location.pathname === "/admin"
) {
let token = JSON.parse(localStorage.getItem("bonafideNITT2020user"));
if (token) {
if (isNaN(token.user)) {
if (window.location.pathname === "/student")
return <Redirect to="/admin" />;
return <Route component={Admin} path="/admin" exact />;
} else {
if (window.location.pathname === "/admin")
return <Redirect to="/student" />;
return <Route component={Student} path="/student" exact />;
}
}
return <Redirect to="/" />;
}
return <Route component={NotFound} />;
};

function App() {
return (
<div className="App">
<Router>
<Switch>
<Route exact strict path="/">
<Route exact path="/">
<div className="row justify-content-center">
<Login />
</div>
</Route>
{/* //<PrivateRoute component={Student} path="/student" exact />
//<PrivateRoute component={Admin} path="/admin" exact /> */}
<PrivateRoutes />
<MainRoutes />
</Switch>
</Router>
<div className="row">
Expand Down
81 changes: 59 additions & 22 deletions public/src/admin/admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,44 +121,67 @@ function Admin() {
return buttons;
}
const exportToExcel = (certreq) => {

var excelData = [];
let index = 0;
certreq.certificates.map((cert) => {
if(certreq.certificate_type === "Bonafide") {
certreq.certificates.map((cert) => {
let temp = {};
index = index + 1;
if (document.getElementById(cert.id).checked === true) {
temp["S.No"] = index;
temp["Document Type"] = certreq.certificate_type;
temp["Roll number"] = cert["applier_roll"];
temp["Address"] = cert["address"];
temp["Email"] = cert["email"];
temp["Purpose"] = cert["purpose"];
temp["Contact"] = cert["contact"];
temp["Course Code"] = cert["course_code"];
temp["Course Name"] = cert["course_name"];
temp["Status"] = cert["status"];
temp["Postal Status"] = cert["postal_status"];
temp["Email Status"] = cert["email_status"];
temp["Receipt"] = cert["receipt"];
temp["Approved"] = cert["approved"];
excelData.push(temp);
}
excelData.map(obj=>{
for (var propName in obj) {
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
return obj;
});
return 0;
});
if (excelData.length) {
const xls = new xlsExport(excelData, "Info");
xls.exportToXLS(`${certreq.certificate_type}_Request_List.xls`);
} else if(certreq.certificate_type === "Transcript") {
certreq.certificates.map((cert) => {
let temp = {};
index = index + 1;
if (document.getElementById(cert.id).checked === true) {
temp["S.No"] = index;
temp["Document Type"] = certreq.certificate_type;
temp["Roll number"] = cert["applier_roll"];
temp["Address"] = cert["address"];
temp["Email"] = cert["email"];
temp["Purpose"] = cert["purpose"];
temp["Contact"] = cert["contact"];
temp["Receipt"] = cert["receipt"];
temp["Number of copies"] = cert["no_copies"];
temp["Status"] = cert["status"];
temp["Postal Status"] = cert["postal_status"];
temp["Email Status"] = cert["email_status"];
temp["Approved"] = cert["approved"];
excelData.push(temp);
}
};
});
} else {
certreq.certificates.map((cert) => {
let temp = {};
index = index + 1;
if (document.getElementById(cert.id).checked === true) {
temp["S.No"] = index;
temp["Document Type"] = certreq.certificate_type;
temp["Roll number"] = cert["applier_roll"];
temp["Purpose"] = cert["purpose"];
temp["Contact"] = cert["contact"];
temp["Course Code"] = cert["course_code"];
temp["Course Name"] = cert["course_name"];
temp["Status"] = cert["status"];
temp["Approved"] = cert["approved"];
excelData.push(temp);
}
});
}
if (excelData.length) {
const xls = new xlsExport(excelData, "Info");
xls.exportToXLS(`${certreq.certificate_type}_Request_List.xls`);
}
}

return (
<>
Expand Down Expand Up @@ -278,6 +301,11 @@ function Admin() {
) : (
<></>
)}
{cert.certificate_type ===
"Transcript"
? <th>Number of copies</th>
: <></>
}
<th>Purpose</th>
<th>Contact</th>
<th scope="col">Decision</th>
Expand Down Expand Up @@ -316,6 +344,7 @@ function Admin() {
certType={
cert.certificate_type
}
ext={data.certificate_extension}
/>
</td>
<td>
Expand All @@ -325,6 +354,7 @@ function Admin() {
certType={
cert.certificate_type
}
ext={data.id_extension}
/>
</td>
{cert.certificate_type ===
Expand Down Expand Up @@ -362,6 +392,10 @@ function Admin() {
) : (
<></>
)}
{cert.certificate_type === "Transcript"
? <td>{data.no_copies}</td>
: <></>
}
<td>
{data.purpose
? data.purpose
Expand Down Expand Up @@ -443,6 +477,7 @@ function Admin() {
)}
{ cert.certificate_type === "Transcript"
? <>
<th scopr="col">Number of copies</th>
<th scope="col">Email Address</th>
<th scope="col">Postal Address</th>
</>
Expand Down Expand Up @@ -508,6 +543,7 @@ function Admin() {
)}
{cert.certificate_type === "Transcript"
? <>
<td>{data.no_copies}</td>
<td>
{data.email
? data.email
Expand Down Expand Up @@ -535,6 +571,7 @@ function Admin() {
certType={
cert.certificate_type
}
ext={data.certificate_extension}
/>
</td>
{cert.certificate_type ===
Expand Down
Loading