From 4afb6adaeddc396ebba44062adadb8e7056fdc31 Mon Sep 17 00:00:00 2001 From: skidoodle Date: Tue, 19 Sep 2023 08:22:37 +0200 Subject: [PATCH] milk --- src/pages/api/erettsegi.ts | 24 +++++++++--------------- src/pages/index.tsx | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/pages/api/erettsegi.ts b/src/pages/api/erettsegi.ts index 8e30377..bb5bce1 100644 --- a/src/pages/api/erettsegi.ts +++ b/src/pages/api/erettsegi.ts @@ -2,8 +2,8 @@ import { NextApiRequest, NextApiResponse } from 'next' import { subjects } from '@/utils/subjects' export default function handler(req: NextApiRequest, res: NextApiResponse) { - const { ev, szint, vizsgatargy, idoszak } = req.query - const baseUrl = 'https://dload-oktatas.educatio.hu/erettsegi/feladatok_' + const { vizsgatargy, ev, idoszak, szint } = req.query + const baseUrl = `https://dload-oktatas.educatio.hu/erettsegi/feladatok_${ev}${idoszak}_${szint}/` const missingParams = [] if (!ev) missingParams.push('ev') @@ -56,25 +56,19 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { const megoldas = 'meg' const shortev = ev!.slice(-2) - let flPdfUrl, utPdfUrl, flZipUrl, utZipUrl, ZipUrl + let flPdfUrl, utPdfUrl, flZipUrl, utZipUrl switch (vizsgatargy) { case 'inf': case 'infoism': case 'digkult': - switch (ZipUrl) { - case ZipUrl: - flZipUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}${forras}_${shortev}${honap}_${feladat}.zip` - flPdfUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}_${shortev}${honap}_${utmutato}.pdf` - utZipUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}${megoldas}_${shortev}${honap}_${utmutato}.zip` - utPdfUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}_${shortev}${honap}_${utmutato}.pdf` - break - default: - return res.status(400).json({ error: 'Érvénytelen fájl' }) - } + flZipUrl = `${baseUrl}${prefix}${forras}_${shortev}${honap}_${feladat}.zip` + flPdfUrl = `${baseUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf` + utZipUrl = `${baseUrl}${prefix}${megoldas}_${shortev}${honap}_${utmutato}.zip` + utPdfUrl = `${baseUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf` break default: - flPdfUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}_${shortev}${honap}_${feladat}.pdf` - utPdfUrl = `${baseUrl}${ev}${idoszak}_${szint}/${prefix}_${shortev}${honap}_${utmutato}.pdf` + flPdfUrl = `${baseUrl}${prefix}_${shortev}${honap}_${feladat}.pdf` + utPdfUrl = `${baseUrl}${prefix}_${shortev}${honap}_${utmutato}.pdf` break } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 40974aa..c656383 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -68,7 +68,9 @@ export default function Home() { onChange={(e) => setSelectedSubject(e.target.value)} className="bg-[#181a1b] text-[#efefef] w-56 max-w-lg h-10 px-4 text-sm border border-[#3C4143] rounded-lg focus:outline-none hover:bg-[#3C4143] transition-colors duration-150" > - + {subjects.map((subject) => ( + {years.map((year) => ( + @@ -107,7 +113,9 @@ export default function Home() { onChange={(e) => setSelectedLevel(e.target.value)} className="bg-[#181a1b] text-[#efefef] w-56 max-w-lg h-10 px-4 text-sm border border-[#3C4143] rounded-lg focus:outline-none hover:bg-[#3C4143] transition-colors duration-150" > - +