<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\User\UserThemeController;
use App\Http\Controllers\Api\User\PostController;
use App\Http\Controllers\Api\User\MyPostController;
use App\Http\Controllers\Api\Admin\EditorUploadController;

Route::middleware(['auth:sanctum'])->group(function () {
    Route::patch('/theme', [UserThemeController::class, 'update']);
    
    // News Submission Routes
    Route::get('/categories', [PostController::class, 'getCategories']);
    Route::post('/posts', [PostController::class, 'store']);
    Route::post('/posts/fetch-url', [PostController::class, 'fetchUrl']);

    Route::post('/editor/image-upload', [EditorUploadController::class, 'uploadImage']);

    // My Posts Routes
    Route::get('/my-posts', [MyPostController::class, 'index']);
    Route::put('/my-posts/{post}', [MyPostController::class, 'update']);
    Route::delete('/my-posts/{post}', [MyPostController::class, 'destroy']);
    Route::delete('/my-posts/{post}/image', [MyPostController::class, 'destroyImage']);
});