Proje: Okul B2B App · Hub: Okul B2B App — Conventions
TypeScript Tip Sistemi
Tip Dosyaları (types/)
types/
├── index.ts → tüm domain tip re-export'ları
├── api.ts → ApiResponse, isSuccessStatus helper
├── analytics.ts → Analytics event tipleri
├── auth.ts → User, AuthTokens
├── company.ts → Company, School
├── context.ts → Context tipleri
├── gallery.ts → GalleryPhoto, GalleryResponse
├── leads.ts → Lead, ApiLeadsResponse, LeadsResponse
├── media.ts → MediaResource, StoreMediaRequest, MEDIA_ROLES
├── notifications.ts → Bildirim tipleri
├── stats.ts → DashboardStats, StatsResponse
├── ui.ts → UI bileşen tipleri
└── utils.ts → Yardımcı tipler
Önemli Tip: Lead
types/leads.ts — Lead API ve UI alanları birlikte:
interface Lead {
// API alanları
id, school_id, name, phone, is_locked, interaction_status, school, stage
schoolAnsweredLeadStatus, agentUser, ...
// Legacy UI compat alanları
contactName?, schoolName?, date?, time?, statusText?, isRestricted?
}Legacy alanlar LeadsService.transformLead() içinde API’den map edilir.
Önemli Tip: MediaResource
interface MediaResource {
id, name, sort, full_url, role_id, row_id, status: '0' | '1', ...
}MEDIA_ROLES.COVER / MEDIA_ROLES.GALLERY sabitleri ile role belirlenir.
isSuccessStatus Helper
import { isSuccessStatus } from '@/types/api';
if (!isSuccessStatus(response.status)) {
throw new Error(response.data.message);
}200-299 arası true döner. Servis katmanında her API yanıtı bu helper ile kontrol edilir.
ApiResponse Tipleri
services/ApiService.ts (mock): ApiResponse<T> = { status?, data?, message?, error? }
utils/ApiClient.ts (gerçek): ApiResponse<T> = { data: T, status: number, headers: Record }
İkisi karıştırılmamalı — gerçek istemci utils/ApiClient.ts.
Related
- api-client-pattern — ApiResponse kullanımı
- leads-basvu-yonetimi — Lead tipi detayları
- galeri-yonetimi — MediaResource tipi