# Next Steps for Architecture Cleanup ## ๐Ÿšจ Priority 1: Critical Architecture Violations ### 1. Fix Event Submission Direct API Call **Location:** `astro-church-website/src/pages/events/submit.astro:748` **Issue:** Still uses `fetch('https://api.rockvilletollandsda.church/api/events/submit')` **Fix:** Replace with `submitEventJson()` function from bindings ### 2. Data Model Mismatches **Issue:** Frontend expects Schedule fields that may not exist in Rust models **Check:** Does `church-core/src/models/admin.rs` Schedule struct have: - `song_leader` - `childrens_story` - `ss_teacher` - `ss_leader` - `mission_story` - `special_notes` **Fix:** Update Rust Schedule model if fields are missing ## ๐Ÿงน Priority 2: Code Cleanup ### 1. Remove Dead Code (Rust Warnings) ```bash # Fix these warnings from build output: cargo fix --lib -p church-core ``` **Locations:** - `church-core/src/models/streaming.rs:1` - unused Serialize/Deserialize - `church-core/src/utils/formatting.rs:56` - unused FixedOffset - `church-core/src/client/http.rs:197` - unused delete method ### 2. Missing Admin Functions **Add to `church-core/src/api.rs`:** - `fetch_admin_stats_json()` - Dashboard statistics - `fetch_recurring_types_json()` - Configuration data - `get_admin_users_json()` - User management ### 3. Upload Functionality **Issue:** Old admin JS had image upload logic not yet converted **Add to `church-core/src/api.rs`:** - `upload_event_image_json()` - `upload_bulletin_cover_json()` ## ๐Ÿ”„ Priority 3: Enhanced Admin Features ### 1. Add TypeScript Types **Create:** `astro-church-website/src/types/admin.ts` - Define admin API response types - Add type safety for admin operations ### 2. Improve Error Handling **Replace:** Generic `alert()` calls in admin pages **With:** Proper error UI components ### 3. Add Loading States **Add to admin pages:** - Loading spinners for operations - Disabled states during API calls - Better UX feedback ## ๐ŸŽฏ Priority 4: Testing & Validation ### 1. Test New Admin Functionality - [ ] Login/logout flow - [ ] Event approval/rejection - [ ] Bulletin CRUD operations - [ ] Schedule management - [ ] Event submission without thumbnail ### 2. Add Form Validation - [ ] Client-side validation for admin forms - [ ] Real-time feedback - [ ] Error message display ## ๐Ÿ“ Implementation Order 1. **Immediate (blocking):** Fix event submission API call 2. **High:** Check/fix Schedule model data mismatches 3. **Medium:** Add missing admin functions 4. **Low:** UI/UX improvements and TypeScript types ## ๐Ÿ”ง Commands to Run ```bash # Test current state cd astro-church-website npm run build npm run dev # Fix Rust warnings cd ../church-core cargo fix --lib -p church-core # Rebuild after Rust changes cd ../astro-church-website npm run build:native npm run build ``` ## ๐Ÿ† Architecture Success Metrics **โœ… ACHIEVED:** - Removed 1843 lines of direct API call violations - All admin routes now use Rust core functions - Proper Astro/TypeScript structure implemented **๐ŸŽฏ TARGET:** - Zero direct API calls from frontend - All business logic in Rust crate - Complete type safety with TypeScript - Full test coverage for admin operations