From 34af4db15d4381d4dcf615fc4060b9c50a248a54 Mon Sep 17 00:00:00 2001 From: Simon Ostendorf Date: Sun, 8 Sep 2024 14:21:56 +0200 Subject: [PATCH] feat: telegram group links (#661) * feat: telegram group links * fix: pr review comments * fix: use array_key_exists instead of in_array --------- Co-authored-by: Tobias Grether --- ...dd_telegram_group_link_to_groups_table.php | 28 ++++++++ ...add_telegram_group_link_to_slots_table.php | 28 ++++++++ database/seeders/EventsDemoSeeder.php | 7 ++ database/seeders/EventsErstiwocheSeeder.php | 70 ++++++++++++++++--- database/seeders/tutors.csv.example | 2 + resources/js/components/ui/Message.vue | 9 ++- resources/js/pages/Dashboard/Event/Index.vue | 63 ++++++++++++----- resources/js/pages/Dashboard/Tutor/Group.vue | 8 +++ resources/js/pages/Dashboard/Tutor/Slot.vue | 8 +++ 9 files changed, 195 insertions(+), 28 deletions(-) create mode 100644 database/migrations/2024_08_19_142538_add_telegram_group_link_to_groups_table.php create mode 100644 database/migrations/2024_08_20_091921_add_telegram_group_link_to_slots_table.php create mode 100644 database/seeders/tutors.csv.example diff --git a/database/migrations/2024_08_19_142538_add_telegram_group_link_to_groups_table.php b/database/migrations/2024_08_19_142538_add_telegram_group_link_to_groups_table.php new file mode 100644 index 00000000..a3008b97 --- /dev/null +++ b/database/migrations/2024_08_19_142538_add_telegram_group_link_to_groups_table.php @@ -0,0 +1,28 @@ +string('telegram_group_link')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('groups', function (Blueprint $table) { + $table->dropColumn(['telegram_group_link']); + }); + } +}; diff --git a/database/migrations/2024_08_20_091921_add_telegram_group_link_to_slots_table.php b/database/migrations/2024_08_20_091921_add_telegram_group_link_to_slots_table.php new file mode 100644 index 00000000..0ec72698 --- /dev/null +++ b/database/migrations/2024_08_20_091921_add_telegram_group_link_to_slots_table.php @@ -0,0 +1,28 @@ +string('telegram_group_link')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('slots', function (Blueprint $table) { + $table->dropColumn(['telegram_group_link']); + }); + } +}; diff --git a/database/seeders/EventsDemoSeeder.php b/database/seeders/EventsDemoSeeder.php index 4214859f..d148ab62 100644 --- a/database/seeders/EventsDemoSeeder.php +++ b/database/seeders/EventsDemoSeeder.php @@ -59,6 +59,7 @@ public function runGroupPhase(): void for ($i = 1; $i <= 14; $i++) { $groups[] = [ 'name' => "Gruppe $i", + 'telegram_group_link' => "https://example.com/invalid-telegram-link", ]; } @@ -67,6 +68,7 @@ public function runGroupPhase(): void $group = new Group; $group->name = $groupData['name']; $group->event_id = $event->id; + $group->telegram_group_link = $groupData['telegram_group_link']; $group->save(); } @@ -251,21 +253,25 @@ public function runSlotBooking(): void 'name' => 'Lorem ipsum', 'has_requirements' => true, 'maximum_participants' => 10, + 'telegram_group_link' => "https://example.com/invalid-telegram-link", ], [ 'name' => 'Dolor sit', 'has_requirements' => true, 'maximum_participants' => 20, + 'telegram_group_link' => "https://example.com/invalid-telegram-link", ], [ 'name' => 'Amet consectetur', 'has_requirements' => true, 'maximum_participants' => 30, + 'telegram_group_link' => "https://example.com/invalid-telegram-link", ], [ 'name' => 'Adipiscing elit', 'has_requirements' => true, 'maximum_participants' => 40, + 'telegram_group_link' => "https://example.com/invalid-telegram-link", ], [ 'name' => 'Sed vitae eros', @@ -291,6 +297,7 @@ public function runSlotBooking(): void $slot->event_id = $event->id; $slot->has_requirements = $slotData['has_requirements']; $slot->maximum_participants = $slotData['maximum_participants']; + $slot->telegram_group_link = in_array('telegram_group_link', $slotData) ? $slotData['telegram_group_link'] : null; $slot->save(); } diff --git a/database/seeders/EventsErstiwocheSeeder.php b/database/seeders/EventsErstiwocheSeeder.php index 055e53ea..329b2ef8 100644 --- a/database/seeders/EventsErstiwocheSeeder.php +++ b/database/seeders/EventsErstiwocheSeeder.php @@ -98,7 +98,7 @@ public function runStadtrallye(): void $event->description = '

Die Stadtrallye ist ein Event, bei dem du in Gruppen die Stadt erkundest. Dabei gibt es verschiedene Aufgaben, die ihr lösen müsst. Dabei könnt ihr euch gegenseitig unterstützen und euch so besser kennenlernen.

Treffpunkt: 9:00 Uhr Campus Eupener Straße

'; $event->type = 'group_phase'; $event->registration_from = new DateTime('2023-09-25 8:00:00'); - $event->registration_to = new DateTime('2023-09-26 10:00:00'); + $event->registration_to = new DateTime('2024-09-26 10:00:00'); $event->has_requirements = false; $event->consider_alcohol = true; $event->sort_order = 110; @@ -107,19 +107,71 @@ public function runStadtrallye(): void $event->save(); // create event groups - $groups = []; - - for ($i = 1; $i <= 14; $i++) { - $groups[] = [ - 'name' => "Gruppe $i", - ]; - } + $groups = [ + [ + 'name' => "Gruppe 1", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 2", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 3", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 4", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 5", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 6", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 7", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 8", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 9", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 10", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 11", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 12", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 13", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ], + [ + 'name' => "Gruppe 14", + 'telegram_group_link' => "https://example.com/invalid-telegram-link" + ] + ]; // save groups foreach ($groups as $groupData) { $group = new Group; $group->name = $groupData['name']; $group->event_id = $event->id; + $group->telegram_group_link = array_key_exists('telegram_group_link', $groupData) ? $groupData['telegram_group_link'] : null; $group->save(); } } @@ -329,6 +381,7 @@ public function runSport(): void 'name' => 'Lasertag', 'has_requirements' => true, 'maximum_participants' => 57, + 'telegram_group_link' => "https://example.com/invalid-telegram-link" ], ]; @@ -338,6 +391,7 @@ public function runSport(): void $slot->event_id = $event->id; $slot->has_requirements = $slotData['has_requirements']; $slot->maximum_participants = $slotData['maximum_participants']; + $slot->telegram_group_link = array_key_exists('telegram_group_link', $slotData) ? $slotData['telegram_group_link'] : null; $slot->save(); } diff --git a/database/seeders/tutors.csv.example b/database/seeders/tutors.csv.example new file mode 100644 index 00000000..70cd42a0 --- /dev/null +++ b/database/seeders/tutors.csv.example @@ -0,0 +1,2 @@ +lastname;firstname;course;email;roles;disabled +Mustermann;Max;INF;max.mustermann@alumni.fh-aachen.de;super admin|admin|stage tutor;0 \ No newline at end of file diff --git a/resources/js/components/ui/Message.vue b/resources/js/components/ui/Message.vue index b8eecb0a..9ea9ac3b 100644 --- a/resources/js/components/ui/Message.vue +++ b/resources/js/components/ui/Message.vue @@ -43,7 +43,9 @@ }" class="text-sm font-medium" > -
+ +
+
@@ -56,7 +58,6 @@ import { computed } from "vue"; const { type } = defineProps({ message: { type: String, - required: true, }, type: { type: String, @@ -66,6 +67,10 @@ const { type } = defineProps({ }, }); +defineSlots<{ + message?: HTMLElement; +}>(); + const icon = computed(() => { if (type === "success") return "circle-check"; if (type === "error") return "circle-xmark"; diff --git a/resources/js/pages/Dashboard/Event/Index.vue b/resources/js/pages/Dashboard/Event/Index.vue index 19392bd0..dfa7e73c 100644 --- a/resources/js/pages/Dashboard/Event/Index.vue +++ b/resources/js/pages/Dashboard/Event/Index.vue @@ -52,18 +52,36 @@ userRegistration.fulfils_requirements) " type="success" - :message=" - 'Die Einteilung ist erfolgt. Du bist in ' + - (userRegistration.group.name - ? 'der Gruppe ' + - userRegistration.group.name + - '' - : 'Gruppe ' + - userRegistration.group.id + - '') + - '.' - " - /> + > + + + > + + + + Telegram Gruppe + Für diese Gruppe wurde eine Telegram Gruppe erstellt. Diesen Link sehen + nur Gruppenmitglieder und Tutoren. + + {{ group.telegram_group_link }} + + diff --git a/resources/js/pages/Dashboard/Tutor/Slot.vue b/resources/js/pages/Dashboard/Tutor/Slot.vue index 8dfcb7b8..48c2a26c 100644 --- a/resources/js/pages/Dashboard/Tutor/Slot.vue +++ b/resources/js/pages/Dashboard/Tutor/Slot.vue @@ -2,6 +2,14 @@ + + Telegram Gruppe + Für diesen Slot wurde eine Telegram Gruppe erstellt. Diesen Link sehen + nur Slotmitglieder und Tutoren. + + {{ slot.telegram_group_link }} + +