Skip to content

feat: Add functionality to create surf sessions from trip page#57

Merged
RomMad merged 3 commits into
mainfrom
feat/add-session-from-trip-page
Jun 3, 2026
Merged

feat: Add functionality to create surf sessions from trip page#57
RomMad merged 3 commits into
mainfrom
feat/add-session-from-trip-page

Conversation

@RomMad

@RomMad RomMad commented Jun 2, 2026

Copy link
Copy Markdown
Owner

This pull request introduces the ability to create a new surf session directly from a trip, along with several related improvements. It adds a new route and controller logic to pre-fill the surf session form with trip data, enhances trip pages with an "Add session" button, and centralizes session initialization logic. Additionally, it improves error handling for missing trips and updates tests and translations accordingly.

New Surf Session Creation from Trip

  • Added a new route (/trip/{tripId}/sessions/new) and controller logic in NewSurfSessionController to support creating a surf session from a specific trip, pre-filling the form with trip data and enforcing access control (TripVoter::EDIT). [1] [2]
  • Introduced SurfSessionWriteModelFactory to encapsulate the logic for initializing a SurfSessionWriteModel, including setting default times and trip/spot information.

Trip Page UI Enhancements

  • Updated show.html.twig and edit.html.twig to display an "Add session" button for users with edit permissions, linking to the new session creation route. [1] [2]
  • Added the translation key surf_session.add.label in both English and French. [1] [2]

Error Handling and Code Cleanup

  • Centralized trip existence validation in TripReadModelProvider::getById, throwing TripNotFoundHttpException if a trip is not found, and removed redundant null checks from controllers. [1] [2] [3] [4] [5] [6]

Testing

  • Added and updated functional tests to verify the new session creation flow from a trip, including form pre-filling and UI changes. [1] [2] [3] [4]…date related templates and translations

@RomMad RomMad requested a review from Copilot June 2, 2026 16:40
@RomMad RomMad self-assigned this Jun 2, 2026
@RomMad RomMad added the enhancement New feature or request label Jun 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a “create surf session from trip” flow by introducing a dedicated route/controller path that pre-fills the surf session form with trip data, updates trip pages to surface an “Add session” action, and centralizes session write-model initialization while tightening trip-not-found handling.

Changes:

  • Added /trip/{tripId}/sessions/new entry point in NewSurfSessionController with access control and pre-filled form data.
  • Introduced SurfSessionWriteModelFactory to centralize default start/end time + trip/spot initialization logic.
  • Updated trip templates, translations, and functional tests to cover the new UI and flow; centralized trip 404 behavior in TripReadModelProvider.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
translations/messages+intl-icu.fr.yaml Adds French translation for the new “Add session” button label.
translations/messages+intl-icu.en.yaml Adds English translation for the new “Add session” button label.
tests/Functional/Controller/Trip/ShowTripControllerTest.php Asserts the “Add session” action appears on the trip show page.
tests/Functional/Controller/SurfSession/NewSurfSessionControllerTest.php Adds a functional test for the “new session from trip” pre-fill behavior.
templates/trip/show.html.twig Adds an “Add session” button (permission-gated) in the trip show page header.
templates/trip/edit.html.twig Adds an “Add session” button (permission-gated) in the trip edit page header.
src/Service/Trip/TripReadModelProvider.php Makes getById() throw a TripNotFoundHttpException instead of returning null.
src/Service/SurfSession/SurfSessionWriteModelFactory.php New factory encapsulating surf session write-model initialization (incl. trip-based defaults).
src/Controller/Trip/ShowTripController.php Removes redundant null-check due to provider now throwing on missing trips.
src/Controller/Trip/EditTripController.php Removes redundant null-check due to provider now throwing on missing trips.
src/Controller/SurfSession/NewSurfSessionController.php Adds a second route to create a new session from a trip and uses the new factory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Service/SurfSession/SurfSessionWriteModelFactory.php
@RomMad RomMad merged commit e834526 into main Jun 3, 2026
2 checks passed
@RomMad RomMad deleted the feat/add-session-from-trip-page branch June 3, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants