feat: podpora více odkazů na podnik při objednávání

This commit is contained in:
2026-08-25 11:28:57 +02:00
parent 93242b7c7e
commit ce051447e6
13 changed files with 338 additions and 81 deletions
+5 -2
View File
@@ -21,12 +21,15 @@ router.get("/dates", async (_req, res, next) => {
router.post("/create", async (req: Request, res, next) => {
const login = getLogin(parseToken(req));
const { name } = req.body ?? {};
const { name, url } = req.body ?? {};
if (!name || typeof name !== 'string') {
return res.status(400).json({ error: 'Nebyl předán název skupiny' });
}
if (url != null && typeof url !== 'string') {
return res.status(400).json({ error: 'Neplatná URL nabídky' });
}
try {
const data = await createGroup(login, name);
const data = await createGroup(login, name, undefined, url);
broadcastExtra(data);
res.status(200).json(data);
} catch (e: any) { next(e); }
+4 -4
View File
@@ -11,18 +11,18 @@ router.get("/", async (_req, res, next) => {
});
router.post("/add", async (req, res, next) => {
const { name, heslo, url } = req.body ?? {};
const { name, heslo, urls } = req.body ?? {};
if (!name || typeof name !== 'string') {
return res.status(400).json({ error: 'Nebyl předán název obchodu' });
}
if (!heslo || typeof heslo !== 'string') {
return res.status(400).json({ error: 'Nebylo předáno heslo' });
}
if (url != null && typeof url !== 'string') {
return res.status(400).json({ error: 'Neplatná URL obchodu' });
if (urls != null && (!Array.isArray(urls) || urls.some((u: unknown) => typeof u !== 'string'))) {
return res.status(400).json({ error: 'Neplatný seznam URL obchodu' });
}
try {
const stores = await addStore(name, heslo, url);
const stores = await addStore(name, heslo, urls);
res.status(200).json(stores);
} catch (e: any) {
if (e.message === 'UNAUTHORIZED') {