<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\API\AsetController;
use App\Http\Controllers\API\KategoriAsetController;
use App\Http\Controllers\API\AuthController;
use App\Http\Controllers\API\MasterProductController;
use App\Http\Controllers\API\WarehouseStockController;
use App\Http\Controllers\API\OutboundController;
use App\Http\Controllers\API\HistoryController;
use App\Http\Controllers\API\SalesTransactionController;
use App\Http\Controllers\API\PermissionController;
use App\Http\Controllers\API\RoleController;
use App\Http\Controllers\API\UserPhotoController;
use App\Http\Controllers\API\AccurateOnlineController;
use App\Http\Controllers\API\InvoiceSalesTransactionController;
use App\Http\Controllers\API\KaryawanController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post('/register', [AuthController::class, 'register']);
Route::post('/login', [AuthController::class, 'login'])->middleware('guest');

Route::group(['middleware' => 'auth:sanctum'], function () {
    Route::post('/logout', [AuthController::class, 'logout']);
});

Route::get('datauser', [AuthController::class, 'show']);
Route::post('datauser/{id}', [AuthController::class, 'update']);
Route::delete('datauser/{id}', [AuthController::class, 'destroy']);

Route::post('changepassword/{id}', [AuthController::class, 'change']);

Route::post('userphoto/{id}', [UserPhotoController::class, 'update']);

Route::resource('aset', AsetController::class);
Route::post('aset', [AsetController::class, 'create']);
Route::get('aset/{id}', [AsetController::class, 'show']);
Route::post('aset/{id}', [AsetController::class, 'update']);
Route::delete('aset/{id}', [AsetController::class, 'destroy']);

Route::resource('kategoriaset', KategoriAsetController::class);
Route::post('kategoriaset', [KategoriAsetController::class, 'create']);
Route::get('kategoriaset/{id}', [KategoriAsetController::class, 'show']);
Route::post('kategoriaset/{id}', [KategoriAsetController::class, 'update']);
Route::delete('kategoriaset/{id}', [KategoriAsetController::class, 'destroy']);

Route::resource('masterproduct', MasterProductController::class);
Route::get('masterproduct/{id}', [MasterProductController::class, 'show']);

Route::resource('warehousestock', WarehouseStockController::class);
Route::post('warehousestock/{id}', [WarehouseStockController::class, 'update']);
Route::get('warehousestock/{id}', [WarehouseStockController::class, 'show']);

Route::resource('outbound', OutboundController::class);
Route::post('outbound/{id}', [OutboundController::class, 'update']);

Route::resource('history', HistoryController::class);

Route::resource('salestransaction', SalesTransactionController::class);
Route::post('salestransaction', [SalesTransactionController::class, 'create']);

Route::resource('role', RoleController::class);
Route::resource('permission', PermissionController::class);

Route::get('invoicesalestransaction/{id}', [InvoiceSalesTransactionController::class, 'invoice']);

Route::post('syncaccurateonline', [AccurateOnlineController::class, 'sync']);

Route::resource('karyawan', KaryawanController::class);
Route::post('karyawan', [KaryawanController::class, 'create']);
Route::get('karyawan/{id}', [KaryawanController::class, 'show']);
Route::post('karyawan/{id}', [KaryawanController::class, 'update']);
Route::delete('karyawan/{id}', [KaryawanController::class, 'destroy']);