# Dashboard Refactoring Guide ## Backend (Porto Architecture) ### ✅ Completed Changes #### 1. Actions реорганизованы по доменам: ``` Actions/ ├── Posts/ │ ├── CreatePostAction.php │ ├── UpdatePostAction.php │ ├── PublishPostAction.php │ └── QuickUploadFileAction.php ├── Sliders/ (9 files) ├── Schedules/ (5 files) ├── EducationalGroups/ (4 files) └── EmailNews/ (3 files) ``` #### 2. Tasks реорганизованы по доменам: ``` Tasks/ ├── Posts/ (7 files) ├── Sliders/ (1 file) ├── Files/ (2 files) ├── AI/ (7 files) └── Email/ (5 files) ``` #### 3. Все импорты обновлены: - Controllers используют новые пути Actions - Actions используют новые пути Tasks - Commands обновлены --- ## Frontend (Vue Components) ### ✅ Created Shared Components Расположение: `resources/js/Pages/Dashboard/Components/shared/` 1. **FlashMessages.vue** - Универсальный компонент flash-сообщений - Поддерживает глобальные ($page.props.flash) и локальные сообщения - Анимации появления/исчезновения 2. **Pagination.vue** - Pagination компонент - Принимает объект pagination data - Рендерит ссылки и информацию о показанных записях 3. **EmptyState.vue** - Empty state для таблиц - Настраиваемый заголовок и описание - Поддержка action кнопки (ссылка или функция) - Кастомизируемая иконка 4. **DataFilters.vue** - Контейнер фильтров - Slot-based архитектура для гибкости - Встроенная кнопка сброса - Emit события reset 5. **SearchInput.vue** - Поле поиска - v-model поддержка - Иконка лупы - Emit события search при Enter 6. **SelectFilter.vue** - Выпадающий список фильтра - v-model поддержка - Slot-based для options - Emit события change --- ## 📋 How to Refactor Pages ### Example: Refactoring Posts/Index.vue #### BEFORE (old approach - 718 lines): ```vue ``` #### AFTER (with shared components - ~400 lines): ```vue ``` ### Key Benefits: 1. **Reduced duplication**: ~150 lines saved from FlashMessages, ~30 from EmptyState, ~30 from Pagination 2. **Consistent UI**: All pages use same components 3. **Easier maintenance**: Fix once, apply everywhere 4. **Better readability**: Clear structure, less noise --- ## 🎯 Next Steps ### For Posts/Index.vue: 1. Replace FlashMessages section with `` 2. Replace Filters section with `` + child components 3. Replace Empty State with `` 4. Replace Pagination with `` 5. Keep table rows and modal as is (post-specific) ### For Schedules/Index.vue: Same approach, but with schedule-specific filters ### For Posts/Form.vue (1284 lines!): Break into subcomponents: - `PostMainInfo.vue` - title, slug, status, category - `PostContentBuilder.vue` - content blocks - `PostMedia.vue` - images, preview - `PostSliderSettings.vue` - slider config - `PostPublishSettings.vue` - publish settings - `PostSocialMedia.vue` - VK, other social --- ## 📝 Migration Checklist - [x] Backend Actions grouped by domain - [x] Backend Tasks grouped by domain - [x] All imports updated in Controllers - [x] Shared components created - [ ] Posts/Index refactored - [ ] Schedules/Index refactored - [ ] Posts/Form broken into subcomponents - [ ] All pages tested and working