<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\api\JobController;
use App\Http\Controllers\api\AuthController;
use App\Http\Controllers\api\UserController;
use App\Http\Controllers\api\SkillController;
use App\Http\Controllers\Api\DashboardController;
use App\Http\Controllers\api\ParameterController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::get('/test', function () {
    return response()->json([
        'error' => false,
        'message' => 'Test akses api.',
        'data' => []
    ], 200);
});

Route::post('login', [AuthController::class, 'login'])->name('api.login');
Route::post('login/user', [AuthController::class, 'login_user'])->name('api.login.user');
Route::post('register', [AuthController::class, 'register'])->name('api.register');

Route::middleware(['auth:sanctum'])->group(function () {
    // Auth
    Route::post('account', [UserController::class, 'account'])->name('api.account');
    Route::post('logout', [AuthController::class, 'logout'])->name('api.logout');
    Route::post('complete_profile', [AuthController::class, 'complete_profile'])->name('api.complete_profile');

    // User
    Route::post('edit_profil', [UserController::class, 'update_profile'])->name('api.user.edit_profile');
    // Route::post('terima', [UserController::class, 'accept_applicant'])->name('api.user.terima');
    // Route::post('tolak', [UserController::class, 'decline_applicant'])->name('api.user.tolak');
    Route::delete('user/{id}', [UserController::class, 'destroy'])->name('api.user.delete');
    Route::post('user/{id}/addskills', [UserController::class, 'add_skills'])->name('api.user.addskills');
    Route::post('user/{id}/adddetails', [UserController::class, 'add_details'])->name('api.user.adddetails');
    Route::post('user/verify', [UserController::class, 'verify_account'])->name('api.user.verifyaccount');
    Route::post('user/setimage', [UserController::class, 'set_image'])->name('api.user.setimage');
    Route::get('user/{id}', [UserController::class, 'show'])->name('api.user.detail');
    Route::get('user/get/maids', [UserController::class, 'get_maids'])->name('api.user.getmaids');

    Route::get('user/getdata/maids', [UserController::class, 'admin_get_maids'])->name('api.user.admingetmaids');
    Route::get('user/getdata/owners', [UserController::class, 'admin_get_owners'])->name('api.user.admingetowners');
    Route::get('user/getdata/kyc', [UserController::class, 'admin_get_kyc'])->name('api.user.admingetkyc');
    Route::post('user/kyc', [UserController::class, 'admin_set_kyc'])->name('api.user.adminsetkyc');

    Route::get('user/getdata/admins', [UserController::class, 'admin_get_admins'])->name('api.admin.index');
    Route::post('user/getdata/admins', [UserController::class, 'admin_post_admins'])->name('api.admin.store');
    Route::put('user/getdata/admins/{id}', [UserController::class, 'admin_update_admins'])->name('api.admin.update');
    Route::delete('user/getdata/admins/{id}', [UserController::class, 'admin_delete_admins'])->name('api.admin.delete');

    Route::post('user/password/{id}', [UserController::class, 'change_password'])->name('api.password');

    // Parameter
    Route::get('parameter', [ParameterController::class, 'index'])->name('api.parameter.index');

    // Skill
    Route::get('skill', [SkillController::class, 'index'])->name('api.skill.index');
    Route::get('skill/{id}', [SkillController::class, 'show'])->name('api.skill.detail');
    Route::post('skill', [SkillController::class, 'store'])->name('api.skill.store');
    Route::put('skill/{id}', [SkillController::class, 'update'])->name('api.skill.update');
    Route::delete('skill/{id}', [SkillController::class, 'destroy'])->name('api.skill.delete');

    // Job
    Route::get('job2', [JobController::class, 'index2'])->name('api.job.index2');
    Route::get('job', [JobController::class, 'index'])->name('api.job.index');
    Route::get('job/owner/{user_id}', [JobController::class, 'owner_jobs'])->name('api.job.ownerjobs');
    Route::get('job/maid/{user_id}', [JobController::class, 'show_applied_job'])->name('api.job.show_applied_job');
    Route::get('job/{id}', [JobController::class, 'show'])->name('api.job.detail');
    Route::post('job', [JobController::class, 'store'])->name('api.job.store');
    Route::put('job/{id}', [JobController::class, 'update'])->name('api.job.update');
    Route::delete('job/{id}', [JobController::class, 'destroy'])->name('api.job.delete');
    // Job~~
    Route::post('job/{id}/skills', [JobController::class, 'add_skills'])->name('api.job.add_skills');
    Route::post('job/{id}/parameter', [JobController::class, 'add_parameter'])->name('api.job.add_parameter');
    Route::post('job/{id}/applicant', [JobController::class, 'add_applicant'])->name('api.job.add_applicant');

    Route::post('job/{id}/applicant/recruit', [JobController::class, 'recruit_applicant'])->name('api.job.recruit_applicant');
    // Job Applicant
    Route::get('job/applicant/{user_id}', [JobController::class, 'show_recent_applicant'])->name('api.job.show_recent_applicant');
    Route::get('job/{id}/applicant', [JobController::class, 'show_applicant'])->name('api.job.show_applicant');
    Route::get('job/{id}/applicant/wp', [JobController::class, 'show_applicant_wp'])->name('api.job.show_applicant_wp');



    // Lain-lain
    Route::get('dashboard/main', [DashboardController::class, 'index'])->name('api.dashboard.index');
    // Route::get('jabatan', [OtherController::class, 'get_jabatan'])->name('api.jabatan');

    // Route::get('notifikasi', [NotificationController::class, 'index'])->name('api.notifikasi.index');
    // Route::get('notifikasi/{id}', [NotificationController::class, 'show'])->name('api.notifikasi.detail');

});
