<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PenggunaController;
use App\Http\Controllers\AnakController;
use App\Http\Controllers\CatatanPertumbuhanController;
use App\Http\Controllers\JadwalImunisasiController;
use App\Http\Controllers\RiwayatPenyakitController;

Route::post('/register', [PenggunaController::class, 'register']);
Route::post('/login', [PenggunaController::class, 'login']);
Route::post('/forgot-password', [PenggunaController::class, 'forgotPassword']);
Route::post('/reset-password', [PenggunaController::class, 'resetPassword']);

Route::middleware('auth:sanctum')->group(function () {
    Route::post('/logout', [PenggunaController::class, 'logout']);
    Route::get('/profile', [PenggunaController::class, 'profile']);
    Route::post('/update-profile', [PenggunaController::class, 'updateProfile']);

    // ANAK
    Route::get('/anak', [AnakController::class, 'index']);
    Route::post('/anak', [AnakController::class, 'store']);
    Route::get('/anak/{id}', [AnakController::class, 'show']);
    Route::put('/anak/{id}', [AnakController::class, 'update']);
    Route::delete('/anak/{id}', [AnakController::class, 'destroy']);

    // CATATAN PERTUMBUHAN
    Route::get('/catatan-pertumbuhan/anak/{anak_id}', [CatatanPertumbuhanController::class, 'index']);
    Route::post('/catatan-pertumbuhan', [CatatanPertumbuhanController::class, 'store']);
    Route::get('/catatan-pertumbuhan/{id}', [CatatanPertumbuhanController::class, 'show']);
    Route::put('/catatan-pertumbuhan/{id}', [CatatanPertumbuhanController::class, 'update']);
    Route::delete('/catatan-pertumbuhan/{id}', [CatatanPertumbuhanController::class, 'destroy']);

    // JADWAL IMUNISASI
    Route::get('/jadwal-imunisasi', [JadwalImunisasiController::class, 'index']);
    Route::post('/jadwal-imunisasi', [JadwalImunisasiController::class, 'store']);
    Route::get('/jadwal-imunisasi/{id}', [JadwalImunisasiController::class, 'show']);
    Route::put('/jadwal-imunisasi/{id}', [JadwalImunisasiController::class, 'update']);
    Route::delete('/jadwal-imunisasi/{id}', [JadwalImunisasiController::class, 'destroy']);
    Route::patch('/jadwal-imunisasi/{id}/toggle', [JadwalImunisasiController::class, 'toggleStatus']);

    // RIWAYAT PENYAKIT
    Route::get('/riwayat-penyakit', [RiwayatPenyakitController::class, 'index']);
    Route::post('/riwayat-penyakit', [RiwayatPenyakitController::class, 'store']);
    Route::get('/riwayat-penyakit/{riwayat_penyakit}', [RiwayatPenyakitController::class, 'show']);
    Route::put('/riwayat-penyakit/{riwayat_penyakit}', [RiwayatPenyakitController::class, 'update']);
    Route::patch('/riwayat-penyakit/{riwayat_penyakit}', [RiwayatPenyakitController::class, 'update']);
    Route::delete('/riwayat-penyakit/{riwayat_penyakit}', [RiwayatPenyakitController::class, 'destroy']);
});
