Skip to content

Commit

Permalink
Merge pull request #120 from rishuriya/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
anshuman-8 authored Dec 31, 2022
2 parents 4862181 + 634e956 commit 6463f85
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 39 deletions.
2 changes: 1 addition & 1 deletion components/admin/ApprovedInternshipList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const tableColumns = [
},
{
Header: "Duration",
accessor: "internship_start_date",
accessor: d => `${toDDmmm(d.internship_start_date)} ${toDDmmm(d.internship_end_date)}`,
Filter: ColumnFilter,
Cell: ({ row: { original } }) => (
<div>
Expand Down
5 changes: 3 additions & 2 deletions components/admin/CompletionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const tableColumns = [
},
{
Header: "Duration",
accessor: "internship_start_date",
// accessor: "internship_start_date",
Filter: ColumnFilter,
accessor: d => `${toDDmmm(d.internship_start_date)} ${toDDmmm(d.internship_end_date)}`,
Cell: ({ row: { original } }) => (
<div>
<p>
Expand All @@ -42,7 +43,7 @@ const tableColumns = [
Filter: ColumnFilter,
},
{
Header: "Branch/Course",
Header: "Branch",
accessor: "status",
Filter: ColumnFilter,
}
Expand Down
5 changes: 4 additions & 1 deletion components/admin/SchoolAddPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export default function DetailModal({ closeModal,setUpdateTable,updateTable }) {

{/* Course Addition dropdown */}
<div className="flex flex-row">
<label></label>
<div className="relative">
<select
required
Expand Down Expand Up @@ -274,8 +275,9 @@ export default function DetailModal({ closeModal,setUpdateTable,updateTable }) {
<input onChange={(e) => setBranch(e.target.value)} required className="appearance-none block w-full bg-gray-100 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white" name="branch_name" id="grid-branch-name" type="text" placeholder="Branch Name" />
</div>

<div className="">
{/* <label className="">Total number for semesters</label> */}
<div className="relative w-1/2">

<select
required className="block appearance-none w-full bg-gray-100 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none
focus:bg-white focus:border-gray-500" name="sem" id="grid-sem"
Expand All @@ -301,6 +303,7 @@ export default function DetailModal({ closeModal,setUpdateTable,updateTable }) {
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
<svg className="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" /></svg>
</div>
</div>
</div>
</div>
</div>
Expand Down
18 changes: 11 additions & 7 deletions components/admin/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export default function Settings() {
}).then(async (res) => {
const resData = await res.json();
if (resData.success) {
setData(resData.branch);
const dat=resData.branch;
if(dat){
dat.sort((a, b) => (a.school_name < b.school_name ? -1 : 1));
}
setData(dat);
setLoading(false);
}
else {
Expand Down Expand Up @@ -108,22 +112,22 @@ export default function Settings() {
<SchoolAddPopup closeModal={setOpenModal} setUpdateTable={setPageUpdate} updateTable={pageUpdate}/>
)}

{(!empty && loading === false) ? <div className="table max-w-5xl md:max-w-7xl mx-auto border-2 rounded-xl py-2 my-3 bg-gray-50">

<table {...getTableProps()}>
<div className="flex flex-row justify-between">
{(!empty && loading === false) ?
<div className="table max-w-5xl md:max-w-7xl mx-auto border-2 rounded-xl py-2 my-3 bg-gray-50">
<div className="flex flex-row justify-between mx-5">
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} />
<div
className="flex flex-row justify-start items-center w-28 md:w-40 border-2 border-primary rounded-lg py-1 px-2 hover:bg-slate-100 hover:cursor-pointer"
onClick={() => courseAddition()}
>
onClick={() => courseAddition()}>
<GrAddCircle
size={26}
className="p-2 h-10 w-10 ml-2 cursor-pointer rounded-lg "
/>
<span>Add Course</span>
</div>
</div>
<table {...getTableProps()}>

<thead>
{headerGroups.map((headerGroup, i) => (

Expand Down
3 changes: 1 addition & 2 deletions components/admin/TableDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { CSVLink } from "react-csv";

import GlobalFilter from "./GlobalFilter";
import { ColumnFilter } from "./ColumnFilter";
import { MdRowing } from "react-icons/md";

const tableColumns = [
{
Expand All @@ -24,7 +23,7 @@ const tableColumns = [
},
{
Header: "Duration",
accessor: "internship_start_date",
accessor: d => `${toDDmmm(d.internship_start_date)} ${toDDmmm(d.internship_end_date)}`,
Filter: ColumnFilter,
Cell: ({ row: { original } }) => (
<div>
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
},
"dependencies": {
"@headlessui/react": "^1.7.3",
"@heroicons/react": "^2.0.13",
"@reduxjs/toolkit": "^1.8.6",
"axios": "^1.1.3",
"bcrypt": "^5.1.0",
"bcryptjs": "^2.4.3",
"dotenv": "^16.0.3",
Expand Down
46 changes: 28 additions & 18 deletions pages/admin/company-letter.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import Link from 'next/link';
import cookie from 'js-cookie';
import Image from "next/image";
import { useState } from 'react';
import { useEffect } from 'react';
import React, { useRef } from 'react';
import { useRouter } from "next/router";
import { getUser } from '../../utils/getUser'
import ReactToPrint from "react-to-print";
import Image from "next/image";
import Header from '../../public/img/head.png'
import { ImSpinner2 } from "react-icons/im";
import { getUser } from '../../utils/getUser'
import Header from '../../public/img/head.png'
import Footer from '../../public/img/Footer.png'

const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter(prop, ref) {
const [username, setUserName] = useState([]);
const [role, setRole] = useState();
const router = useRouter()
const [isDataRecieved, setIsDataRecieved] = useState(false);
const [data, setData] = useState(false);
const [internshipdata, setInternshipData] = useState([]);

let user = router.query.user;
let internship_id = router.query.id;
const userid = cookie.get("token");
let user_name
let internship_data
const [isDataRecieved, setIsDataRecieved] = useState(false);
const [data, setData] = useState(false);

const [internshipdata, setInternshipData] = useState([]);

useEffect(() => {
try {
Expand All @@ -48,6 +49,7 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
setRole(response.user["role"]);

});

if (username["_id"]) {
const bodyObject = {
user: username["_id"],
Expand All @@ -70,9 +72,6 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
});

}



} catch (err) {
console.log(err);
}
Expand All @@ -83,8 +82,10 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter

if (isDataRecieved && data) {
let member = internshipdata["member"] == null ? null : JSON.parse(internshipdata["member"]);
console.log("member", internshipdata);

return (
<div className="mx-auto max-w-4xl text-[16px] font-sans relative bg-white" ref={ref} style={{width: 780.7007874, height:1050.519685}}>
<div className="mx-auto max-w-4xl text-[15px] font-sans relative bg-white" ref={ref} style={{width: 780.7007874, height:1050.519685}}>
<div className="mt-0 mb-0 text-center">
{role!="Admin" ?(<>
<Image src={Header} />
Expand All @@ -100,12 +101,21 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
<div className='px-4 sm:px-8 mt-10 mb-5' >
<div className="text-sm text-right mx-8 mb-5">{new Date().toLocaleDateString()}</div>
<div className='my-5'>
<p>{internshipdata["company_person_name"]}</p>
<p>{internshipdata["company_name"]}</p>
{/* <p>Designation</p> */}
<p>{internshipdata["company_location"]}</p>
{
internshipdata["company_person_name"] == "Whomsoever it may concern"?(
<>
<p className='text-center font-semibold py-4'>To whomsoever it may concern</p>
</>
):(<>
<p>{internshipdata["company_person_name"]}</p>
<p>{internshipdata["company_name"]}</p>
{/* <p>Designation</p> */}
<p>{internshipdata["company_location"]}</p>
</>)
}

</div>
<div className='my-5 font-medium'>
<div className='my-5 font-semibold'>
<p>Sub: - Request for Internship for {username["course"]} student.</p>
</div>
<div className='my-5'>
Expand All @@ -115,7 +125,7 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
{username["school"]} is one of the several professional institutions under Amrita Vishwa
Vidyapeetham, established under section 3 of the UGC Act, 1956. {username["course"]} students
studying in {username["school"] === "Amrita School Of Arts and Science" && (<>ASAS</>)} are advised to do Internship in reputed organizations. This will give them some practical
experience which will contribute substantially to their learning process
experience which will contribute substantially to their learning process.
</div>

<div>
Expand Down Expand Up @@ -148,7 +158,7 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
<div className="my-5 mx-2">
Thanking you,
</div>
<div className='flex flex-row justify-between mx-3 items-end my-6'>
<div className='flex flex-row justify-between mx-3 items-end mt-6'>
<div>
<p>Br. Vishwanathamrita Chaitanya </p>
<p>Head - Corporate & Industry Relations</p>
Expand All @@ -159,7 +169,7 @@ const CompanyLetter = React.forwardRef<HTMLDivElement>(function InternshipLetter
</div>

{role!="Admin" ?(
<div className="flex flex-col justify-between absolute">
<div className="flex flex-col justify-between absolute -bottom-16">
<div className="flex flex-row divide-x text-sm divide-black justify-center mb-2">
<p className="text-base px-2">Amritapuri</p>
<p className="text-base px-2">Bengaluru</p>
Expand Down
11 changes: 5 additions & 6 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ export default function landingPage() {
<div className="w-[100vw] h-[100vh] bg-no-repeat bg-[url('../public/img/setu-bg.jpg')] bg-cover">

<div className="flex justify-between flex-col md:flex-row">
<div className="m-5">
<div className="m-5 md:mx-7">
<Image src={logo} height={"100px"} width={"268px"} />

</div>
<div className="flex space-x-8 m-5 p-4 justify-center text-lg font-medium items-start">
<Link href={"/login"}><div className="bg-primary shadow-lg md:bg-transparent md:border md:border-white py-2 px-3 rounded-md hover:underline hover:bg-slate-100/50 hover:shadow-lg cursor-pointer truncate">Login</div></Link>
<Link href={"/signup"}><div className="bg-primary shadow-lg md:bg-transparent md:border md:border-white py-2 px-3 rounded-md hover:underline hover:bg-slate-100/50 hover:shadow-lg cursor-pointer truncate">Sign up</div></Link>
<div className="flex space-x-8 m-5 p-4 justify-center text-base md:text-xl font-medium items-start">
<Link href={"/login"}><div className="bg-primary shadow-lg md:bg-transparent md:border md:border-white py-2 px-3 rounded-md hover:bg-slate-100/50 hover:shadow-lg cursor-pointer truncate backdrop-blur-md">Login</div></Link>
<Link href={"/signup"}><div className="bg-primary shadow-lg md:bg-transparent md:border md:border-white py-2 px-3 rounded-md hover:bg-slate-100/50 hover:shadow-lg cursor-pointer truncate">Sign up</div></Link>

</div>
</div>
<div className="border border-white py-4 px-3 max-w-6xl bg-slate-100/50 rounded-md text-center md:mx-auto my-12 mx-3 ">
<div className="border border-white py-4 px-3 max-w-6xl bg-slate-100/40 backdrop-blur-sm rounded-md text-center md:mx-auto my-12 mx-3 ">
<h1 className="font-medium md:text-5xl text-2xl tracking-wider text-primary" >Online Internship Registration Portal</h1>
<p className="my-5 text-base font-medium md:text-2xl" >Corporate & Industry Relations(CIR),Amritapuri</p>

Expand Down

1 comment on commit 6463f85

@vercel
Copy link

@vercel vercel bot commented on 6463f85 Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cir-internship – ./

cir-internship.vercel.app
cir-internship-git-main-rishuriya.vercel.app
cir-internship-rishuriya.vercel.app

Please sign in to comment.