Skip to content

Commit

Permalink
Merge pull request #83 from BaldissaraMatheus/fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
BaldissaraMatheus authored Feb 12, 2024
2 parents 583ab7a + 3c05f49 commit b24787e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 0 additions & 2 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"koa": "^2.14.1",
"koa-bodyparser": "^4.3.0",
"koa-mount": "^4.0.0",
"koa-send": "^5.0.1",
"koa-static": "^5.0.0",
"uuid": "^9.0.0"
},
Expand Down
10 changes: 1 addition & 9 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const router = require("@koa/router")();
const bodyParser = require("koa-bodyparser");
const cors = require("@koa/cors");
const multer = require("@koa/multer");
const send = require("koa-send");
const mount = require("koa-mount");
const serve = require("koa-static");

Expand Down Expand Up @@ -320,14 +319,6 @@ async function saveCardsSort(ctx) {

router.post("/sort/cards", saveCardsSort);

async function getImage(ctx) {
await send(ctx, `${process.env.CONFIG_DIR}/images/${ctx.params.image}`, {
root: process.env.NODE_ENV === "prod" ? "/" : __dirname,
});
}

router.get("/images/:image", getImage);

async function saveImage(ctx) {
const imageName = ctx.request.file.originalname;
await fs.promises.mkdir(`${process.env.CONFIG_DIR}/images`, {
Expand Down Expand Up @@ -374,6 +365,7 @@ app.use(async (ctx, next) => {
});
app.use(mount(`${BASE_PATH}api`, router.routes()));
app.use(mount(BASE_PATH, serve("/static")));
app.use(mount(`${BASE_PATH}api/images`, serve(`${process.env.CONFIG_DIR}/images`)));
app.use(
mount(
`${BASE_PATH}stylesheets/`,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export function handleKeyDown(e, enterCb, cancelCb) {

export function getButtonCoordinates(event) {
event.stopPropagation();
const btnCoordinates = event.target.getBoundingClientRect();
let x = btnCoordinates.x + event.target.offsetWidth - 3;
const btnCoordinates = event.currentTarget.getBoundingClientRect();
let x = btnCoordinates.x + event.currentTarget.offsetWidth - 3;
const menuWidth = 82;
const offsetX = x + menuWidth >= window.innerWidth ? menuWidth : 0;
x -= offsetX;
const offsetY = offsetX ? 0 : 3;
const y = btnCoordinates.y + event.target.offsetHeight - offsetY;
const y = btnCoordinates.y + event.currentTarget.offsetHeight - offsetY;
return { x, y };
}

0 comments on commit b24787e

Please sign in to comment.