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
+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') {