@php $modalName = $modalName ?? null; $session = $session ?? null; $method = strtoupper($method ?? 'POST'); $action = $action ?? route('activities.sessions.store'); $submitLabel = $submitLabel ?? 'Enregistrer'; $cancelUrl = $cancelUrl ?? null; $formTitle = $formTitle ?? 'Renseigner une activité'; $formEyebrow = $formEyebrow ?? 'Activité'; $selectedDate = $selectedDate ?? now(); $showHeader = $showHeader ?? true; $formClass = $formClass ?? 'module-modal'; $gridClass = $gridClass ?? 'module-form-grid mt-5'; $actionsClass = $actionsClass ?? 'module-modal__actions'; $lockCategory = (bool) ($lockCategory ?? false); $lockedCategory = $lockedCategory ?? null; $resetOnOpen = $resetOnOpen ?? ($session === null); $showFormErrors = $errors->any() && (! $modalName || old('_modal') === $modalName); $formCategories = $activityCategories ?? $categories ?? collect(); $formTypes = $activityTypes ?? $types ?? collect(); $initialCategoryId = (string) old('activity_category_id', data_get($session, 'activity_category_id', data_get($lockedCategory, 'id', ''))); $initialTypeId = (string) old('activity_type_id', data_get($session, 'activity_type_id', '')); $initialAllDay = (bool) old('all_day', data_get($session, 'all_day', false)); $initialDeepwork = (bool) old('is_deepwork', data_get($session, 'is_deepwork', false)); $initialSocialContextId = (string) old('activity_social_context_id', data_get($session, 'activity_social_context_id', '')); $initialAdvancedMode = $initialDeepwork ? 'deepwork' : ($initialSocialContextId !== '' ? 'social' : ''); $socialContexts = collect($socialContexts ?? []); $existingMetrics = collect(data_get($session, 'metrics', [])); $activityTypeOptions = collect($formTypes)->map(function ($type) use ($existingMetrics) { return [ 'id' => (string) data_get($type, 'id'), 'category_id' => (string) data_get($type, 'activity_category_id'), 'name' => (string) data_get($type, 'name'), 'allows_deepwork' => (bool) data_get($type, 'allows_deepwork', false), 'metric_definitions' => collect(data_get($type, 'metricDefinitions', []))->map(function ($definition) use ($existingMetrics) { $id = (string) data_get($definition, 'id'); $name = (string) data_get($definition, 'name'); $oldValue = old('metrics.' . $id . '.value'); $existingValue = data_get($existingMetrics->all(), $name . '.value', ''); return [ 'id' => $id, 'name' => $name, 'label' => (string) data_get($definition, 'label'), 'unit' => (string) data_get($definition, 'unit', ''), 'is_required' => (bool) data_get($definition, 'is_required'), 'value' => (string) ($oldValue ?? $existingValue ?? ''), ]; })->values(), ]; })->values(); @endphp
@csrf @if ($modalName) @endif @if ($method !== 'POST') @method($method) @endif @if ($showHeader)

{{ $formEyebrow }}

{{ $formTitle }}

@endif @if ($showFormErrors)

{{ __('Certains champs obligatoires sont manquants ou invalides.') }}

@endif
@if ($lockCategory) @else @endif @if ($socialContexts->isNotEmpty() || $activityTypeOptions->contains('allows_deepwork', true))
{{ __('Paramètres avancés') }}
@if ($socialContexts->isNotEmpty()) @endif
@error('is_deepwork'){{ $message }}@enderror @if ($socialContexts->isNotEmpty())
@endif
@endif

{{ __('Métriques') }}

{{ __('Détails configurés') }}

{{ __('Aucune métrique configurée pour ce type.') }}

@if ($cancelUrl) {{ __('Annuler') }} @elseif ($modalName) @endif