diff --git a/client/src/Api.ts b/client/src/Api.ts
index ff89e73..4f26ac6 100644
--- a/client/src/Api.ts
+++ b/client/src/Api.ts
@@ -22,8 +22,8 @@ const api = {
post:
(url: string, body: TBody) => request(url, { method: 'POST', body, headers: { 'Content-Type': 'application/json' } }),
}
-export const getQrUrl = () => {
- return `${getBaseUrl()}/api/qr`;
+export const getQrUrl = (login: string) => {
+ return `${getBaseUrl()}/api/qr?login=${login}`;
}
export const getData = async () => {
diff --git a/client/src/App.tsx b/client/src/App.tsx
index 745f1ed..871153b 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -353,7 +353,7 @@ function App() {
QR platba
Částka: {myOrder.totalPrice} Kč
-
})
+
Generování QR kódů je v experimentální fázi - doporučujeme si překontrolovat údaje před odesláním platby.
}
diff --git a/server/src/index.ts b/server/src/index.ts
index a8635c7..48b07cf 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -57,6 +57,20 @@ app.post("/api/login", (req, res) => {
res.status(200).json(generateToken(req.body.login));
});
+// TODO dočasné řešení - QR se zobrazuje přes
, nemáme sem jak dostat token
+app.get("/api/qr", (req, res) => {
+ // const login = getLogin(parseToken(req));
+ if (!req.query?.login) {
+ throw Error("Nebyl předán login");
+ }
+ const img = getQr(req.query.login as string);
+ res.writeHead(200, {
+ 'Content-Type': 'image/png',
+ 'Content-Length': img.length
+ });
+ res.end(img);
+});
+
// ----------------------------------------------------
/** Middleware ověřující JWT token */
@@ -182,16 +196,6 @@ app.post("/api/updateChoice", (req, res) => {
res.status(200).json(data);
});
-app.get("/api/qr", (req, res) => {
- const login = getLogin(parseToken(req));
- const img = getQr(login);
- res.writeHead(200, {
- 'Content-Type': 'image/png',
- 'Content-Length': img.length
- });
- res.end(img);
-});
-
app.post("/api/updateNote", (req, res) => {
const login = getLogin(parseToken(req));
if (req.body.note && req.body.note.length > 100) {