Skip to content

Commit

Permalink
TestType added
Browse files Browse the repository at this point in the history
  • Loading branch information
sheninthjr committed Nov 6, 2023
1 parent 44f19f7 commit 23d68d5
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coverage
.next/
out/
build
dist

# misc
.DS_Store
Expand Down
Binary file removed apps/client/dist/assets/GitHub_logo-f53b383c.png
Binary file not shown.
Binary file removed apps/client/dist/assets/github-mark-60d03f0f.png
Binary file not shown.
71 changes: 0 additions & 71 deletions apps/client/dist/assets/index-186c1b8a.js

This file was deleted.

1 change: 0 additions & 1 deletion apps/client/dist/assets/index-79a74f1a.css

This file was deleted.

27 changes: 0 additions & 27 deletions apps/client/dist/index.html

This file was deleted.

1 change: 0 additions & 1 deletion apps/client/dist/vite.svg

This file was deleted.

4 changes: 3 additions & 1 deletion apps/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PostingQuestion from "./components/Posting";
import Landing from "./components/Landing";
import GetQuestion from "./components/GetQuestion";
import NavBar from "./components/NavBar";
import TestType from "./components/TestType";

function App() {
return (
Expand All @@ -12,7 +13,8 @@ function App() {
<Routes>
<Route path="/" element={<Landing/>}></Route>
<Route path="/post" element={<PostingQuestion />}></Route>
<Route path="/get" element={<GetQuestion />}></Route>
<Route path="/get" element={<TestType />}></Route>
<Route path="/get/:testtype" element={<GetQuestion />}></Route>
</Routes>
</Router>
</>
Expand Down
10 changes: 9 additions & 1 deletion apps/client/src/components/GetQuestion.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import axios from "axios";
import { BASE_URL } from "../config";
import { useState, useEffect } from "react";
import { useLocation, useParams } from "react-router";

export default function GetQuestion() {
const { type } = useParams();
const location = useLocation();
const searchParams = new URLSearchParams(location.search);
const date = searchParams.get("date");
const sem = searchParams.get("sem");
const year = searchParams.get("year");
const setTypeA = searchParams.get("setTypeA");
const [pdfName, setPdfName] = useState("");
const [pdfUrl, setPdfUrl] = useState("");
const [showPdf, setShowPdf] = useState(false);

const fetchPdf = async () => {
try {
const res = await axios.get(`${BASE_URL}/get/IA1`, {
const res = await axios.get(`${BASE_URL}/get/${type}?date=${date}&sem=${sem}&year=${year}&setTypeA=${setTypeA}`, {
responseType: "blob",
});
const blob = new Blob([res.data], { type: "application/pdf" });
Expand Down
29 changes: 29 additions & 0 deletions apps/client/src/components/TestType.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

import { TypePost } from "ui";
import { Link } from "react-router-dom";

export default function TestType() {
return (
<>
<TypePost
onClick={async (
date: string,
type: string,
year: string,
sem: string,
setTypeA:string
) => {
const urlData = {
date,
type,
year,
sem,
};
return (
<Link to={{pathname:`/get/${urlData.type}`,search:`?date=${date}&sem=${sem}&year=${year}&setTypeA=${setTypeA}`}} ></Link>
)
}}
/>
</>
);
}
2 changes: 1 addition & 1 deletion apps/client/src/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const BASE_URL = "https://generator.sheninthjr.com"
export const BASE_URL = "http://localhost:3000"
2 changes: 1 addition & 1 deletion packages/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@prisma/client": "5.5.2",
"@prisma/client": "^5.5.2",
"@types/cors": "^2.8.15",
"@types/express": "^4.17.20",
"cors": "^2.8.5",
Expand Down
15 changes: 6 additions & 9 deletions packages/prisma/server/routes/QuestionRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,10 @@ router.post("/post/:unit", async (req, res) => {

router.get("/get/:testtype", async (req, res) => {
const testType = req.params.testtype;
const currentDate = new Date();
const currentYear = currentDate.getFullYear() % 100;
const currentMonth = currentDate.getMonth() + 1;
const currentDay = currentDate.getDate();
const formattedMonth = currentMonth < 10 ? `0${currentMonth}` : currentMonth;
const formattedDay = currentDay < 10 ? `0${currentDay}` : currentDay;
const formattedDate = `${formattedDay}.${formattedMonth}.${currentYear}`;
const date = req.query.date;
const sem = req.query.sem;
const year = req.query.year;
const set = req.query.setTypeA;
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
Expand Down Expand Up @@ -186,7 +183,7 @@ router.get("/get/:testtype", async (req, res) => {
partB12Questions,
partB21Questions,
partC1Questions,
currentDate: formattedDate,
currentDate: date,
};
const htmlDataParta1 = partA11Questions.map((q) => q.parta1);
const htmlDataParta1Qtype = partA11Questions.map((q) => q.parta1qtype);
Expand Down Expand Up @@ -250,7 +247,7 @@ router.get("/get/:testtype", async (req, res) => {
<h3>Velammal Institute of technology</h3>
</div>
<div>
<h3>Dept of AI&DS/${testType}/III Year/V Sem/${formattedDate}/1.45hr/60Marks/Set B</h3>
<h3>Dept of AI&DS/${testType}/${year}/${sem}/${date}/1.45hr/60Marks/${set}</h3>
</div>
<div>
<h3>CCS334-BIG DATA ANALYTICS</h3>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// component exports
export { Card } from "./card";
export { Post,GetQuestionPage,LandingPage } from "./src/components"
export { Post,GetQuestionPage,LandingPage,TypePost } from "./src/components"
88 changes: 88 additions & 0 deletions packages/ui/src/components/TypePost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { useState } from "react";

export function TypePost(props: {
onClick: (date: string, type: string, year: string, sem: string,setTypeA:string) => void;
}) {
const [date, setDate] = useState("");
const [type, setType] = useState("");
const [year, setYear] = useState("");
const [sem, setSem] = useState("");
const [setTypeA,setSetTypeA] = useState("")
return (
<>
<div className="flex flex-col justify-center items-center p-40">
<div className="flex flex-col rounded-lg space-y-5 p-4 border-4 bg-white border-white w-80 h-[55vh] w-100 lg:h-[55vh]">
<input
className="rounded-lg w-1/25 h-15 p-4 border-2 border-gray-700"
type="date"
name="Date"
value={date}
onChange={(e) => {
setDate(e.target.value);
}}
/>
<select
className="rounded-lg border-2 border-gray-700 h-15 p-4 bg-white"
name="Type of Exam"
value={type}
onChange={(e) => setType(e.target.value)}
>
<option value="IA1">IA1</option>
<option value="IA2">IA2</option>
<option value="IA3">IA3</option>
<option value="MODEL">MODEL</option>
</select>
<select
className="rounded-lg border-2 border-gray-700 h-15 p-4 bg-white"
name="Year"
value={year}
onChange={(e) => {
setYear(e.target.value);
}}
>
<option value="I Year">I Year</option>
<option value="II Year">II Year</option>
<option value="III Year">III Year</option>
<option value="IV Year">IV Year</option>
</select>
<select
className="rounded-lg border-2 border-gray-700 h-15 p-4 bg-white"
name="Sem"
value={sem}
onChange={(e) => {
setSem(e.target.value);
}}
>
<option value="I Sem">I Sem</option>
<option value="II Sem">II Sem</option>
<option value="III Sem">III Sem</option>
<option value="IV Sem">IV Sem</option>
<option value="V Sem">V Sem</option>
<option value="VI Sem">VI Sem</option>
<option value="VII Sem">VII Sem</option>
<option value="VIII Sem">VIII Sem</option>
</select>
<select
className="rounded-lg border-2 border-gray-700 h-15 p-4 bg-white"
name="Type of Exam"
value={setTypeA}
onChange={(e) => setSetTypeA(e.target.value)}
>
<option value="Set A">Set A</option>
<option value="Set B">Set B</option>
</select>
<div className="flex justify-end">
<button
className="flex justify-center items-center rounded-lg border-2 border-red-600 h-5 p-4 bg-white"
onClick={async () => {
props.onClick(date, type, year, sem,setTypeA);
}}
>
Submit
</button>
</div>
</div>
</div>
</>
);
}
3 changes: 2 additions & 1 deletion packages/ui/src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { Post } from "./Post";
export { GetQuestionPage } from "./GetQuestionPage"
export { LandingPage } from './LandingPage'
export { LandingPage } from './LandingPage'
export { TypePost } from './TypePost'
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
picocolors "^1.0.0"
tslib "^2.6.0"

"@prisma/client@5.5.2", "@prisma/client@^5.5.2":
"@prisma/client@^5.5.2":
version "5.5.2"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.5.2.tgz#ce6389e7ad9e9cf0fc2a7c6a0032ad2e12a9fd61"
integrity sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==
Expand Down

0 comments on commit 23d68d5

Please sign in to comment.