feat: nová stránka pro návrhy na vylepšení
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 21s
CI / Build server (push) Successful in 24s
CI / Build client (push) Successful in 38s
CI / Playwright E2E tests (push) Successful in 1m18s
CI / Build and push Docker image (push) Successful in 40s
CI / Notify (push) Successful in 2s

This commit is contained in:
2026-06-05 19:15:46 +02:00
parent f28f127a92
commit 17132d4124
27 changed files with 857 additions and 515 deletions
+50
View File
@@ -0,0 +1,50 @@
import express, { Request } from "express";
import { getLogin } from "../auth";
import { parseToken } from "../utils";
import { addSuggestion, deleteSuggestion, listSuggestions, voteSuggestion } from "../suggestions";
import { AddSuggestionData, VoteSuggestionData, DeleteSuggestionData } from "../../../types";
const router = express.Router();
router.get("/list", async (req: Request, res, next) => {
try {
const login = getLogin(parseToken(req));
const data = await listSuggestions(login);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
router.post("/add", async (req: Request<{}, any, AddSuggestionData["body"]>, res, next) => {
try {
const login = getLogin(parseToken(req));
if (!req.body?.title || !req.body?.description) {
return res.status(400).json({ error: "Chybné parametry volání" });
}
const data = await addSuggestion(login, req.body.title, req.body.description);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
router.post("/vote", async (req: Request<{}, any, VoteSuggestionData["body"]>, res, next) => {
try {
const login = getLogin(parseToken(req));
if (!req.body?.id || !req.body?.direction) {
return res.status(400).json({ error: "Chybné parametry volání" });
}
const data = await voteSuggestion(login, req.body.id, req.body.direction);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
router.post("/delete", async (req: Request<{}, any, DeleteSuggestionData["body"]>, res, next) => {
try {
const login = getLogin(parseToken(req));
if (!req.body?.id) {
return res.status(400).json({ error: "Chybné parametry volání" });
}
const data = await deleteSuggestion(login, req.body.id);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
export default router;
-33
View File
@@ -1,33 +0,0 @@
import express, { Request } from "express";
import { getLogin } from "../auth";
import { parseToken } from "../utils";
import { getUserVotes, updateFeatureVote, getVotingStats } from "../voting";
import { GetVotesData, UpdateVoteData } from "../../../types";
const router = express.Router();
router.get("/getVotes", async (req: Request<{}, any, GetVotesData["body"]>, res) => {
const login = getLogin(parseToken(req));
const data = await getUserVotes(login);
res.status(200).json(data);
});
router.post("/updateVote", async (req: Request<{}, any, UpdateVoteData["body"]>, res, next) => {
const login = getLogin(parseToken(req));
if (req.body?.option == null || req.body?.active == null) {
res.status(400).json({ error: "Chybné parametry volání" });
}
try {
const data = await updateFeatureVote(login, req.body.option, req.body.active);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
router.get("/stats", async (req, res, next) => {
try {
const data = await getVotingStats();
res.status(200).json(data);
} catch (e: any) { next(e) }
});
export default router;