From 51df9e75ad5fd22b40bff57dd9e73036e13bca39 Mon Sep 17 00:00:00 2001 From: Antoine Pelletier Date: Tue, 25 Aug 2026 10:38:05 +0200 Subject: [PATCH] wip --- .env | 15 - .gitignore | 4 +- README.md | 3 +- config.example.yml | 44 ++ .../src/components/admin/ReservationAdmin.vue | 14 +- .../src/components/admin/ReservationCard.vue | 74 ++- .../admin/ReservationCreateDialog.vue | 63 +++ .../reservation/ReservationDetails.vue | 152 +++--- .../reservation/ReservationEditDialog.vue | 21 +- .../reservation/ReservationForm.vue | 489 ++++++++++++++++++ frontend/src/lib/api.d.ts | 132 ++++- frontend/src/locales/en.yml | 24 + frontend/src/locales/fr.yml | 25 + frontend/src/services/api/reservations.ts | 36 +- frontend/src/utils/types.ts | 1 + frontend/src/views/MyReservationsView.vue | 2 +- frontend/src/views/ReservationView.vue | 419 +-------------- src/api/reservations.rs | 79 ++- src/core/controller/reservations.rs | 343 ++++++++++-- src/core/models/user.rs | 25 + .../repositories/reservations_repository.rs | 9 + src/core/repositories/users_repository.rs | 22 +- src/main.rs | 21 + src/services/database/reservations.rs | 19 + src/services/database/users.rs | 80 ++- src/services/mail/mails/mod.rs | 165 ++++++ .../mail/mails/reservation_approved.rs | 80 +++ .../mail/mails/reservation_bikes_changed.rs | 46 ++ .../mail/mails/reservation_cancelled.rs | 81 +++ .../mail/mails/reservation_period_changed.rs | 44 ++ src/services/mail/mails/reservation_shared.rs | 68 +++ .../mail/mails/reservation_updated.rs | 51 ++ src/services/mail/mod.rs | 156 ++++++ src/services/mod.rs | 1 + src/services/telegram.rs | 233 --------- src/services/telegram/messages/mod.rs | 134 +++++ .../telegram/messages/reservation_decided.rs | 50 ++ .../messages/reservation_requested.rs | 67 +++ src/services/telegram/mod.rs | 313 +++++++++++ 39 files changed, 2805 insertions(+), 800 deletions(-) delete mode 100644 .env create mode 100644 frontend/src/components/admin/ReservationCreateDialog.vue create mode 100644 frontend/src/components/reservation/ReservationForm.vue create mode 100644 src/services/mail/mails/mod.rs create mode 100644 src/services/mail/mails/reservation_approved.rs create mode 100644 src/services/mail/mails/reservation_bikes_changed.rs create mode 100644 src/services/mail/mails/reservation_cancelled.rs create mode 100644 src/services/mail/mails/reservation_period_changed.rs create mode 100644 src/services/mail/mails/reservation_shared.rs create mode 100644 src/services/mail/mails/reservation_updated.rs create mode 100644 src/services/mail/mod.rs delete mode 100644 src/services/telegram.rs create mode 100644 src/services/telegram/messages/mod.rs create mode 100644 src/services/telegram/messages/reservation_decided.rs create mode 100644 src/services/telegram/messages/reservation_requested.rs create mode 100644 src/services/telegram/mod.rs diff --git a/.env b/.env deleted file mode 100644 index 7c01ab6..0000000 --- a/.env +++ /dev/null @@ -1,15 +0,0 @@ -# This file is used by dbmate, and by the sqlx macros at compile time. -DATABASE_URL=postgres://postgres:postgres@localhost:5432/cargagep?sslmode=disable - -# Read by the backend too: anything named APP__* here reaches the configuration -# exactly like an exported variable would, and a real environment variable still -# wins over this file. This is where the secrets live in development. -# -# The bot that posts to the cargobikes group. Leave both empty and nothing is -# sent — which is what a machine without the bot wants. -# * BOT_TOKEN comes from @BotFather -# * CHAT_ID is the group's id: add the bot to the group, post a message, then -# read it from https://api.telegram.org/bot/getUpdates (a group id is -# negative, e.g. -1001234567890) -APP__TELEGRAM__BOT_TOKEN= -APP__TELEGRAM__CHAT_ID= diff --git a/.gitignore b/.gitignore index e16256e..76c8f59 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ config.yml config.yaml /LEGACY -summary.ai \ No newline at end of file +summary.ai +.env +.env.example \ No newline at end of file diff --git a/README.md b/README.md index 51ee89e..edda67e 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,8 @@ change every time a domain model does. `query!`/`query_as!` check the sql against a **real database at compile time**, so the development database must be up and migrated for `cargo build` to work. `DATABASE_URL` is -read from `.env`. +read from `.env`, which is **gitignored**: copy `.env.example` to `.env` and fill +in the secrets there — never commit them. To build without a database (CI, docker image), commit the offline data: diff --git a/config.example.yml b/config.example.yml index e69de29..d7224c1 100644 --- a/config.example.yml +++ b/config.example.yml @@ -0,0 +1,44 @@ +# Copy to config.yml (gitignored) and adapt. Every value can also be given as an +# environment variable, e.g. APP__SERVER__PORT=3000 — and `.env` is read the same +# way, which is where the secrets belong in development. +server: + address: 0.0.0.0 + port: 3000 + # Public origin the browser reaches the app on; the OIDC redirect uri is built + # from it. In development this is the vite dev server, not the backend. + base_url: http://localhost:5000 + +postgres: + host: localhost + port: 5432 + user: postgres + password: postgres + name: cargagep + +oidc: + client_id: cargagep + client_secret: change-me + issuer_url: https://hydra.agepoly.ch + # Minutes + session_lifetime: 60 + +# The bot that posts to the cargobikes group. Leave the whole section out and +# nothing is sent, which is what a machine without the bot wants. Both values +# are secrets: give them through `.env` (APP__TELEGRAM__BOT_TOKEN, +# APP__TELEGRAM__CHAT_ID) rather than committing them here. +# telegram: +# bot_token: "123456:ABC-DEF..." +# chat_id: "-1001234567890" +# # Only to point the sender somewhere else than the real bot api +# api_url: https://api.telegram.org + +# Logged in without the provider, debug builds only (POST /api/login) +dev_users: + - firstname: Milan + name: Hyenne + email: milan.hyenne@epfl.ch + units: + - agepoly + admin: true + +frontend_dir: frontend/dist diff --git a/frontend/src/components/admin/ReservationAdmin.vue b/frontend/src/components/admin/ReservationAdmin.vue index c417055..08615a3 100644 --- a/frontend/src/components/admin/ReservationAdmin.vue +++ b/frontend/src/components/admin/ReservationAdmin.vue @@ -8,12 +8,13 @@ * ever holds the whole table. */ import { computed, ref } from 'vue' -import { Archive } from '@lucide/vue' +import { Archive, Plus } from '@lucide/vue' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Skeleton } from '@/components/ui/skeleton' import ReservationArchiveDialog from './ReservationArchiveDialog.vue' +import ReservationCreateDialog from './ReservationCreateDialog.vue' import ReservationCard from './ReservationCard.vue' import type { Bike, Reservation } from '@/utils/types' @@ -26,6 +27,7 @@ const props = defineProps<{ }>() const archiveOpen = ref(false) +const createOpen = ref(false) /** Soonest first: both sections are read as "what comes next" */ const byStart = (list: Reservation[]) => @@ -43,6 +45,13 @@ const activeSorted = computed(() => byStart(props.active)) +
+ +
+
@@ -85,7 +94,7 @@ const activeSorted = computed(() => byStart(props.active)) /> -
+