feat: Add functionality to create surf sessions from trip page#57
Merged
Conversation
…date related templates and translations
There was a problem hiding this comment.
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/newentry point inNewSurfSessionControllerwith access control and pre-filled form data. - Introduced
SurfSessionWriteModelFactoryto 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.
…ct new default time
…rove clarity and consistency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
/trip/{tripId}/sessions/new) and controller logic inNewSurfSessionControllerto support creating a surf session from a specific trip, pre-filling the form with trip data and enforcing access control (TripVoter::EDIT). [1] [2]SurfSessionWriteModelFactoryto encapsulate the logic for initializing aSurfSessionWriteModel, including setting default times and trip/spot information.Trip Page UI Enhancements
show.html.twigandedit.html.twigto display an "Add session" button for users with edit permissions, linking to the new session creation route. [1] [2]surf_session.add.labelin both English and French. [1] [2]Error Handling and Code Cleanup
TripReadModelProvider::getById, throwingTripNotFoundHttpExceptionif a trip is not found, and removed redundant null checks from controllers. [1] [2] [3] [4] [5] [6]Testing