Proje: Okul B2B App · Hub: Okul B2B App — Conventions

SchoolContentService CRUD Pattern

services/SchoolContentService.ts — Tüm içerik türleri için tek unified service.

SchoolContentResult Pattern

interface SchoolContentResult {
  success: boolean,
  data?: SchoolContentItem,
  errorMessage?: string,     // Kullanıcıya gösterilecek mesaj
  fieldErrors?: Record<string, string[]>  // Form field hataları
}

CRUD operasyonları throw etmez, SchoolContentResult döner.

Create Payload

interface CreateSchoolContentPayload {
  title: string,
  text: string,
  sort?: number,
  is_active?: boolean,
  school_ids: number[],         // Hangi okullara ait
  starts_on?: string | null,    // Etkinlik tarihi
  ends_on?: string | null,      // Duyuru bitiş tarihi
  media?: string | FormData,    // Tek görsel (duyurular)
  medias?: ...,                 // Çoklu görsel
}

toggleStatus

SchoolContentService.toggleStatus(contentType, id, isActive: boolean)
// → PUT /customer/school-content/{type}/{id}
// → Payload: { is_active: !currentStatus }

Cache Bypass

bypassCache: true_t={timestamp} query param eklenir. Yeni içerik oluşturma/güncelleme sonrası cache invalidate etmek için.