Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ungdev/turboswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
DevNono committed May 16, 2024
2 parents 828ee3a + da36238 commit b6e2569
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions web/dbml/schema.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Table Borrow {
id Int [pk, increment]
userLogin String [not null]
joyconsTaken Int [not null]
borrowOpeningId Int [unique, not null]
returnOpeningId Int [unique, not null]
borrowOpeningId String [unique, not null]
returnOpeningId String [unique, not null]
createdAt DateTime [default: `now()`, not null]
user User [not null]
borrowOpening Opening [not null]
returnOpening Opening [not null]
}

Table Opening {
id Int [pk, increment]
id String [pk]
date DateTime
code String
codeGeneratedAt DateTime
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export async function getWaitingOpeningWithValidCode(userLogin: string) {
return formatOpening(opening);
}

export async function generateNewCode(borrowId: number) {
export async function generateNewCode(borrowId: string) {
const code = await generateCode();
await prisma.opening.update({
where: { id: borrowId },
Expand Down
6 changes: 2 additions & 4 deletions web/src/webRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ webRouter.get("/forceOpen", async (request: Request, response: Response) => {
const opening = formatOpening(
await prisma.opening.findUnique({
where: {
id: Number.parseInt(request.query.id as string),
id: request.query.id as string,
date: null,
borrow: null,
},
Expand All @@ -155,9 +155,7 @@ webRouter.get("/forceOpen", async (request: Request, response: Response) => {
if (!opening) {
return response.redirect("/");
}
const newCode = await generateNewCode(
Number.parseInt(request.query.id as string)
);
const newCode = await generateNewCode(request.query.id as string);
response.render(path.join(__dirname, "../www/getCode.html"), {
code: newCode,
joycons: opening.borrow.joyconsTaken,
Expand Down

0 comments on commit b6e2569

Please sign in to comment.