# Frontend (Next.js) — API Entegrasyon Rehberi ## Genel Bilgi Backend: Laravel API, Base URL: `{API_URL}/api/v1` Auth gerektirmeyen tüm public endpoint'ler burada. Frontend SSR/ISR ile fetch edebilir. --- ## Tüm Public Endpoint'ler | Method | Endpoint | Açıklama | |--------|----------|----------| | `GET` | `/v1/settings` | Site ayarları (nested group format) | | `GET` | `/v1/settings/{group}` | Tek grup ayarları | | `GET` | `/v1/categories` | Eğitim kategorileri | | `GET` | `/v1/categories/{slug}` | Kategori detayı | | `GET` | `/v1/courses` | Eğitim listesi (paginated) | | `GET` | `/v1/courses/{slug}` | Eğitim detayı (blocks + schedules dahil) | | `GET` | `/v1/schedules` | Eğitim takvimi | | `GET` | `/v1/schedules/upcoming` | Yaklaşan eğitimler | | `GET` | `/v1/schedules/{id}` | Takvim detayı | | `GET` | `/v1/announcements` | Duyurular | | `GET` | `/v1/announcements/{slug}` | Duyuru detayı | | `GET` | `/v1/hero-slides` | Hero slider (aktif, sıralı) | | `GET` | `/v1/faqs` | SSS listesi | | `GET` | `/v1/faqs/{category}` | Kategoriye göre SSS | | `GET` | `/v1/guide-cards` | Eğitim rehberi kartları | | `GET` | `/v1/menus/{location}` | Menü (header, footer, vb.) | | `GET` | `/v1/pages/{slug}` | Sayfa detayı (blocks dahil) | | `GET` | `/v1/preview/{token}` | Sayfa önizleme (cache bazlı) | | `GET` | `/v1/comments/{type}/{id}` | Yorumlar | | `POST` | `/v1/leads` | Lead/başvuru formu | | `POST` | `/v1/comments` | Yorum gönder | | `GET` | `/v1/sitemap-data` | Sitemap verisi | --- ## Eğitimler (Courses) ### GET /v1/courses — Liste Query parametreleri: - `category` — Kategori slug filtresi (ör: `guverte`, `stcw`, `makine`) - `search` — Başlık/açıklama arama - `sort` — Sıralama: `title`, `-created_at` (varsayılan), `students`, `rating` (- prefix = desc) - `per_page` — Sayfa başına (varsayılan: 15) ``` GET /v1/courses?category=guverte&sort=-rating&per_page=12 ``` Response (paginated): ```json { "data": [ { "id": 1, "category_id": 1, "category": { "id": 1, "slug": "guverte", "label": "Güverte Eğitimleri" }, "slug": "gemici-birlesik-egitimi", "title": "Gemici (Birleşik) Eğitimi", "sub": "STCW / IMO Uyumlu", "desc": "Güverte bölümünde gemici olarak görev yapmak isteyen...", "long_desc": "Detaylı açıklama...", "duration": "32 Gün", "students": 772, "rating": 4.9, "badge": "most_preferred", "badge_label": "En Çok Tercih Edilen", "image": null, "price": "₺14.500", "includes": ["Basılı eğitim materyalleri", "Uygulamalı güverte tatbikatları", "..."], "requirements": ["En az 16 yaşında olmak", "..."], "scope": ["Denizde kişisel güvenlik", "Yangınla mücadele", "..."], "standard": "STCW / IMO Uyumlu", "language": "Türkçe", "location": "Kadıköy, İstanbul", "meta_title": "Gemici (Birleşik) Eğitimi | Boğaziçi Denizcilik", "meta_description": "STCW A-II/4 uyumlu...", "created_at": "2026-03-02T...", "updated_at": "2026-03-23T..." } ], "links": { "first": "...", "last": "...", "prev": null, "next": "..." }, "meta": { "current_page": 1, "last_page": 3, "per_page": 12, "total": 32 } } ``` ### GET /v1/courses/{slug} — Detay Detayda ek olarak `blocks` ve `schedules` array'leri gelir: ```json { "data": { "id": 1, "slug": "gemici-birlesik-egitimi", "title": "Gemici (Birleşik) Eğitimi", "sub": "STCW / IMO Uyumlu", "desc": "...", "long_desc": "...", "duration": "32 Gün", "students": 772, "rating": 4.9, "badge": "most_preferred", "badge_label": "En Çok Tercih Edilen", "image": null, "price": "₺14.500", "includes": ["Basılı eğitim materyalleri", "..."], "requirements": ["En az 16 yaşında olmak", "..."], "scope": ["Denizde kişisel güvenlik", "..."], "standard": "STCW / IMO Uyumlu", "language": "Türkçe", "location": "Kadıköy, İstanbul", "category": { "id": 1, "slug": "guverte", "label": "Güverte Eğitimleri" }, "blocks": [ { "id": 1, "type": "text", "content": { "label": "EĞİTİM HAKKINDA", "title": "Neden Bu Eğitim?", "body": "
...
" }, "order_index": 0 }, { "id": 2, "type": "text", "content": { "_width": "half", "label": "EĞİTİM KAPSAMI", "title": "Ne Öğreneceksiniz?", "body": "HTML içerik...
", "image": "/storage/uploads/...", "is_featured": true, "meta_title": "...", "meta_description": "...", "published_at": "2026-03-15" } ] } ``` --- ## SSS (FAQs) ### GET /v1/faqs ```json { "data": [ { "id": 1, "question": "STCW belgesi nedir?", "answer": "...", "category": "genel", "order_index": 0, "is_active": true } ] } ``` Kategoriye göre: `GET /v1/faqs/genel` --- ## Lead Formu (Başvuru) ### POST /v1/leads Rate limited. Request: ```json { "name": "Ad Soyad", "phone": "+90 532 ...", "source": "web", "target_course": "gemici-birlesik-egitimi", "education_level": "lise", "subject": "Eğitim başvurusu", "message": "Bilgi almak istiyorum", "kvkk_consent": true, "marketing_consent": false, "utm_source": "google", "utm_medium": "cpc", "utm_campaign": "denizcilik-2026" } ``` --- ## Sayfa Önizleme (Preview) ### GET /v1/preview/{token} Admin panelden gönderilen önizleme. Auth yok, Next.js SSR ile fetch edilir. 10 dakika geçerli. Bulunamazsa 404. Response formatı `GET /v1/pages/{slug}` ile aynı: ```json { "data": { "id": 1, "slug": "kalite-politikasi", "title": "...", "blocks": [...] } } ``` --- ## Sayfa Bazlı Veri Haritası ### Anasayfa (`/`) | Veri | Endpoint | |------|----------| | Hero slider | `GET /v1/hero-slides` | | Eğitim kartları | `GET /v1/courses?per_page=6&sort=-rating` | | Kategoriler | `GET /v1/categories` | | Yaklaşan eğitimler | `GET /v1/schedules/upcoming` | | SSS | `GET /v1/faqs` | | Site ayarları | `GET /v1/settings` (layout'tan) | ### Eğitimler (`/egitimler`) | Veri | Endpoint | |------|----------| | Eğitim listesi | `GET /v1/courses?category=guverte&per_page=12` | | Kategoriler (filter) | `GET /v1/categories` | ### Eğitim Detay (`/egitimler/{slug}`) | Veri | Endpoint | |------|----------| | Eğitim + bloklar + takvim | `GET /v1/courses/{slug}` | ### Kurumsal Sayfalar (`/kurumsal/{slug}`) | Veri | Endpoint | |------|----------| | Sayfa + bloklar | `GET /v1/pages/{slug}` | ### Duyurular (`/duyurular`) | Veri | Endpoint | |------|----------| | Duyuru listesi | `GET /v1/announcements` | ### İletişim (`/iletisim`) | Veri | Endpoint | |------|----------| | İletişim bilgileri | `GET /v1/settings/contact` | | Harita | `GET /v1/settings/maps` | | Form gönderimi | `POST /v1/leads` | ### Layout (Her Sayfa) | Veri | Endpoint | |------|----------| | Header/Footer/SEO | `GET /v1/settings` | | Menü | `GET /v1/menus/header` + `GET /v1/menus/footer` | | Kategoriler (mega menu) | `GET /v1/categories` | --- ## TypeScript Tipleri ```ts interface Course { id: number; category_id: number; category?: Category; slug: string; title: string; sub: string | null; desc: string; long_desc: string; duration: string; students: number; rating: number; badge: 'most_preferred' | 'popular' | null; badge_label: string | null; image: string | null; price: string; includes: string[]; requirements: string[]; scope: string[]; standard: string | null; language: string | null; location: string | null; blocks?: Block[]; schedules?: Schedule[]; meta_title: string | null; meta_description: string | null; created_at: string; updated_at: string; } interface Category { id: number; slug: string; label: string; desc: string | null; image: string | null; courses_count?: number; menu_courses?: { title: string; slug: string }[]; } interface Block { id: number; type: 'hero' | 'text' | 'text_image' | 'cards' | 'stats_grid' | 'cta' | 'faq' | 'gallery' | 'video' | 'testimonials' | 'html'; content: Record