Dočasná oprava zobrazování QR kódů
This commit is contained in:
parent
d21291c643
commit
26609ebd6b
@ -22,8 +22,8 @@ const api = {
|
||||
post: <TBody extends BodyInit, TResponse>(url: string, body: TBody) => request<TResponse>(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 () => {
|
||||
|
@ -353,7 +353,7 @@ function App() {
|
||||
<div className='qr-code'>
|
||||
<h3>QR platba</h3>
|
||||
<div>Částka: {myOrder.totalPrice} Kč</div>
|
||||
<img src={getQrUrl()} alt='QR kód' />
|
||||
<img src={getQrUrl(auth.login)} alt='QR kód' />
|
||||
<p>Generování QR kódů je v experimentální fázi - doporučujeme si překontrolovat údaje před odesláním platby.</p>
|
||||
</div>
|
||||
}
|
||||
|
@ -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 <img>, 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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user