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" > - <option className="hidden" value="">Tárgy</option> + <option className="hidden" value=""> + Tárgy + </option> {subjects.map((subject) => ( <option key={subject.value} value={subject.value}> {subject.label} @@ -82,7 +84,9 @@ export default function Home() { onChange={(e) => setSelectedYear(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" > - <option className="hidden" value="">Év</option> + <option className="hidden" value=""> + Év + </option> {years.map((year) => ( <option key={year} value={year}> {year} @@ -96,7 +100,9 @@ export default function Home() { onChange={(e) => setSelectedPeriod(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" > - <option className="hidden" value="">Időszak</option> + <option className="hidden" value=""> + Időszak + </option> <option value="tavasz">Tavasz</option> <option value="osz">Ősz</option> </select> @@ -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" > - <option className="hidden" value="">Szint</option> + <option className="hidden" value=""> + Szint + </option> <option value="kozep">Közép</option> <option value="emelt">Emelt</option> </select>