fix: refactore create blade#177
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the "Période et horaire" section of the form, updating the grid layout and separating the "Pauses" and "Jours d'école" sections into distinct blocks. The review feedback indicates that these changes break the reactivity of the Alpine.js component by narrowing its scope and removing shared state. It is recommended to move the projectHoursCalculator initialization to a higher-level container to ensure that all related fields, such as dates and school days, are correctly observed for calculations and validation.
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4" x-data="{ | ||
| totalHours: {{ old('nombre_heures', '90') }} | ||
| }"> | ||
| <div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> |
There was a problem hiding this comment.
The removal of the x-data object that previously held the totalHours state (line 242 in the original version) breaks the reactivity between the hour calculation and the planning section. The planning section (line 352) depends on this value for its calculations and validation. By removing this shared scope, the two sections are now decoupled, which will likely lead to incorrect data being submitted or validation errors in the UI. To maintain reactivity across all project-related fields (Dates, Hours, Pauses, and School Days), the projectHoursCalculator should be initialized at this level.
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6" x-data="projectHoursCalculator()" x-init="init()">| </div> | ||
|
|
||
| <!-- Colonne 2: Horaires --> | ||
| <div x-data="projectHoursCalculator()" x-init="init()"> |
There was a problem hiding this comment.
The projectHoursCalculator component is now scoped only to the 'Horaire de travail' section. This is problematic because the calculation of total project hours typically requires data from the 'Dates', 'Pauses', and 'Jours d'école' sections, which are now outside this component's scope. This prevents the calculator from observing changes in those fields. If you move the x-data declaration to the parent container as suggested above, this local initialization should be removed to avoid redundant nested scopes.
<div>
No description provided.