Skip to content

Commit

Permalink
Fix creating events and deleting callers
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatanaatos committed Dec 24, 2023
1 parent 7e11b17 commit e322378
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.env

data
2 changes: 1 addition & 1 deletion admin-panel/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const App = () => {
const location = useLocation();
const navigate = useNavigate();
return (
<Container>
<Container className="py-4">
<div className="d-flex py-4 justify-content-between align-items-center">
<h1>Admin panel</h1>
</div>
Expand Down
1 change: 1 addition & 0 deletions admin-panel/src/util/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const postEvent = (event: object) =>
request<Event>(['events'], {
method: 'POST',
body: JSON.stringify(event),
headers,
});
export const deleteEvent = (id: string) =>
request<Event>(['events', id], { method: 'DELETE' });
Expand Down
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"db-push": "prisma db push"
},
"dependencies": {
"@prisma/client": "^5.5.2",
"@prisma/client": "^5.7.1",
"app-root-path": "^3.1.0",
"cors": "^2.8.5",
"debug": "^4.3.4",
Expand All @@ -33,7 +33,7 @@
"eslint": "^8.56.0",
"nodemon": "^3.0.1",
"prettier": "^2.8.8",
"prisma": "^5.5.2",
"prisma": "^5.7.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
}
Expand Down
4 changes: 2 additions & 2 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ model Event {
id String @id @default(uuid())
time DateTime
answers Answer[]
caller Caller @relation(fields: [callerId], references: [id])
caller Caller @relation(fields: [callerId], references: [id], onDelete: Cascade)
callerId String
}

model Answer {
id String @id @default(uuid())
event Event @relation(fields: [eventId], references: [id])
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
eventId String
user User @relation(fields: [userId], references: [id])
userId String
Expand Down
6 changes: 5 additions & 1 deletion backend/src/routers/caller-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const upload = multer({ storage, limits: { fileSize: 100 * 1024 * 1024 } });

router.get('/', requireAdminToken, async (req, res) => {
try {
const callers = await prisma.caller.findMany();
const callers = await prisma.caller.findMany({
orderBy: {
name: 'asc',
},
});
res.send(callers);
} catch (e) {
console.error(e);
Expand Down
3 changes: 2 additions & 1 deletion backend/src/routers/event-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ router.get('/', async (_req, res) => {
router.get('/all', requireAdminToken, async (_req, res) => {
const events = await prisma.event.findMany({
orderBy: {
time: 'asc',
time: 'desc',
},
take: 10,
});
res.status(200).send(events);
});
Expand Down
66 changes: 45 additions & 21 deletions backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,46 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@prisma/client@^5.5.2":
version "5.5.2"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.5.2.tgz#ce6389e7ad9e9cf0fc2a7c6a0032ad2e12a9fd61"
integrity sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==
dependencies:
"@prisma/engines-version" "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a"

"@prisma/engines-version@5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a":
version "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a.tgz#35cd59ed65ee1f9e333f4865ec86a4432c4d0a9c"
integrity sha512-O+qHFnZvAyOFk1tUco2/VdiqS0ym42a3+6CYLScllmnpbyiTplgyLt2rK/B9BTjYkSHjrgMhkG47S0oqzdIckA==

"@prisma/engines@5.5.2":
version "5.5.2"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-5.5.2.tgz#fe0d2361a48c7d59568ccf0d35c75432594e1ac1"
integrity sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==
"@prisma/client@^5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.7.1.tgz#a124afd05663267f7255a639a81d28303684a063"
integrity sha512-TUSa4nUcC4nf/e7X3jyO1pEd6XcI/TLRCA0KjkA46RDIpxUaRsBYEOqITwXRW2c0bMFyKcCRXrH4f7h4q9oOlg==

"@prisma/debug@5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-5.7.1.tgz#064177066e630beb43492ffa608acc21a118e2ce"
integrity sha512-yrVSO/YZOxdeIxcBtZ5BaNqUfPrZkNsAKQIQg36cJKMxj/VYK3Vk5jMKkI+gQLl0KReo1YvX8GWKfV788SELjw==

"@prisma/engines-version@5.7.1-1.0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5":
version "5.7.1-1.0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.7.1-1.0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5.tgz#b7845425313e5395a3a3e64f3e0d04c1f320fa92"
integrity sha512-dIR5IQK/ZxEoWRBDOHF87r1Jy+m2ih3Joi4vzJRP+FOj5yxCwS2pS5SBR3TWoVnEK1zxtLI/3N7BjHyGF84fgw==

"@prisma/engines@5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-5.7.1.tgz#631c27daa326bbacd5d7119446e0d3f15c0f274c"
integrity sha512-R+Pqbra8tpLP2cvyiUpx+SIKglav3nTCpA+rn6826CThviQ8yvbNG0s8jNpo51vS9FuZO3pOkARqG062vKX7uA==
dependencies:
"@prisma/debug" "5.7.1"
"@prisma/engines-version" "5.7.1-1.0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5"
"@prisma/fetch-engine" "5.7.1"
"@prisma/get-platform" "5.7.1"

"@prisma/fetch-engine@5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-5.7.1.tgz#d7baa3493867c6f7cedfc41df477cfd0963059ca"
integrity sha512-9ELauIEBkIaEUpMIYPRlh5QELfoC6pyHolHVQgbNxglaINikZ9w9X7r1TIePAcm05pCNp2XPY1ObQIJW5nYfBQ==
dependencies:
"@prisma/debug" "5.7.1"
"@prisma/engines-version" "5.7.1-1.0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5"
"@prisma/get-platform" "5.7.1"

"@prisma/get-platform@5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-5.7.1.tgz#bc2fe43838c7d47b321aa4728a0f60990d02bc9e"
integrity sha512-eDlswr3a1m5z9D/55Iyt/nZqS5UpD+DZ9MooBB3hvrcPhDQrcf9m4Tl7buy4mvAtrubQ626ECtb8c6L/f7rGSQ==
dependencies:
"@prisma/debug" "5.7.1"

"@tsconfig/node10@^1.0.7":
version "1.0.9"
Expand Down Expand Up @@ -1439,12 +1463,12 @@ prettier@^2.8.8:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

prisma@^5.5.2:
version "5.5.2"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.5.2.tgz#54ad2f04f0dd4174f27128e4447013e8d75c4d69"
integrity sha512-WQtG6fevOL053yoPl6dbHV+IWgKo25IRN4/pwAGqcWmg7CrtoCzvbDbN9fXUc7QS2KK0LimHIqLsaCOX/vHl8w==
prisma@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.7.1.tgz#af60ed90531adc0ab8a683c9b1fc86d841c39864"
integrity sha512-ekho7ziH0WEJvC4AxuJz+ewRTMskrebPcrKuBwcNzVDniYxx+dXOGcorNeIb9VEMO5vrKzwNYvhD271Ui2jnNw==
dependencies:
"@prisma/engines" "5.5.2"
"@prisma/engines" "5.7.1"

process-nextick-args@~2.0.0:
version "2.0.1"
Expand Down

0 comments on commit e322378

Please sign in to comment.