<?php

use App\Http\Controllers\AkademisiController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\FollowController;
use App\Http\Controllers\FollowPenawaranController;
use App\Http\Controllers\InvestorController;
use App\Http\Controllers\KomunitasController;
use App\Http\Controllers\LandingPageController;
use App\Http\Controllers\PemerintahController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\permohonanProjectController;
use App\Http\Controllers\PenawaranProjectController;
use App\Http\Controllers\PreferencesController;
use App\Http\Controllers\UMKMController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;


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

Route::get('/', [LandingPageController::class, 'index']);
Route::resource('landingpage', LandingPageController::class);

// routes/web.php
Route::get('/about', function () {
    return view('about');
});

Route::get('/contact', function () {
    return view('contact');
});




Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    // Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    // Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');

    // Route::get('/preferences', [PreferencesController::class, 'showForm']);
    // Route::post('/preferences/save', [PreferencesController::class, 'savePreferences']);
    // Route::get('/preferences/get', [PreferencesController::class, 'getPreferences']);

    // Rute untuk menampilkan notifikasi follow
    Route::get('/notification/permohonan', [FollowController::class, 'index'])->name('notification.permohonan');

    // Rute untuk menampilkan notifikasi follow
    Route::get('/notification/penawaran', [FollowPenawaranController::class, 'index'])->name('notification.penawaran');

    Route::post('/follow/permohonan/accept/{id}', [FollowController::class, 'accept'])->name('follow.accept');
    Route::post('/follow/permohonan/decline/{id}', [FollowController::class, 'decline'])->name('follow.decline');
    Route::post('/follow/penawaran/accept/{id}', [FollowPenawaranController::class, 'accept'])->name('follow.penawaran.accept');
    Route::post('/follow/penawaran/decline/{id}', [FollowPenawaranController::class, 'decline'])->name('follow.penawaran.decline');


    // Rute untuk menyimpan permintaan follow
    Route::post('/follow/permohonan', [FollowController::class, 'store'])->name('follow.store');
    Route::post('/follow/penawaran', [FollowPenawaranController::class, 'store'])->name('follow.penawaran.store');

    // Rute untuk memperbarui status follow
    Route::post('/follow/update/{follow}', [FollowController::class, 'update'])->name('follow.update');

    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
    Route::get('/profile', [ProfileController::class, 'show'])->name('profile.show');
    Route::get('/profile/edit/{id}', [RegisteredUserController::class, 'edit'])->name('profile.edit');
    Route::post('/profile/update/{id}', [RegisteredUserController::class, 'update'])->name('profile.update');

    Route::get('/profile/{id}', [ProfileController::class, 'detail'])->name('profile.detail');

    // Route::post('/preferences', [ProfileController::class, 'storePreferencesPermohonan'])->name('preferencesPermohonan.store');
    Route::post('/preferences', [PreferencesController::class, 'storeOrUpdatePreferences'])->name('preferencesPermohonan.store');


    // Route untuk menampilkan daftar proyek (index)
    Route::get('/permohonanprojects', [permohonanProjectController::class, 'index'])->name('permohonanprojects.index');

    // Route untuk menampilkan form pembuatan proyek (create)
    Route::get('/permohonanprojects/create', [permohonanProjectController::class, 'create'])->name('permohonanprojects.create');

    // Route untuk menyimpan proyek baru (store)
    Route::post('/permohonanprojects', [permohonanProjectController::class, 'store'])->name('permohonanprojects.store');

    // Route untuk menampilkan detail proyek (show)
    Route::get('/permohonanprojects/{id}', [permohonanProjectController::class, 'show'])->name('permohonanprojects.show');

    // Route untuk menampilkan form edit proyek (edit)
    Route::get('/permohonanprojects/{id}/edit', [permohonanProjectController::class, 'edit'])->name('permohonanprojects.edit');

    // Route untuk memperbarui proyek yang ada (update)
    Route::put('/permohonanprojects/{id}', [permohonanProjectController::class, 'update'])->name('permohonanprojects.update');

    // Route untuk menghapus proyek (delete)
    Route::delete('/permohonanprojects/{id}', [permohonanProjectController::class, 'destroy'])->name('permohonanprojects.destroy');


    Route::get('/permohonanpelatihan', [permohonanProjectController::class, 'pelatihan'])->name('permohonanpelatihan');


    Route::get('/permohonanpendanaan', [permohonanProjectController::class, 'pendanaan'])->name('permohonanpendanaan');


    Route::get('/permohonanriset', [permohonanProjectController::class, 'riset'])->name('permohonanriset');


    Route::get('/permohonanproyekInvestor', [permohonanProjectController::class, 'proyekInvestor'])->name('permohonanproyekInvestor');


    Route::get('/permohonanpelatihan/{id}', [permohonanProjectController::class, 'showPelatihan'])->name('permohonanpelatihan.show');
    Route::get('/permohonanpendanaan/{id}', [permohonanProjectController::class, 'showPendanaan'])->name('permohonanpendanaan.show');
    Route::get('/permohonanriset/{id}', [permohonanProjectController::class, 'showRiset'])->name('permohonanriset.show');
    Route::get('/permohonanproyek-investor/{id}', [permohonanProjectController::class, 'showProyekInvestor'])->name('permohonanproyek-investor.show');


    // Route untuk menampilkan daftar proyek (index)
    Route::get('/penawaranprojects', [PenawaranProjectController::class, 'index'])->name('penawaranprojects.index');
    // Route untuk menampilkan form pembuatan proyek (create)
    Route::get('/penawaranprojects/create', [PenawaranProjectController::class, 'create'])->name('penawaranprojects.create');

    // Route untuk menyimpan proyek baru (store)
    Route::post('/penawaranprojects', [PenawaranProjectController::class, 'store'])->name('penawaranprojects.store');

    // Route untuk menampilkan detail proyek (show)
    Route::get('/penawaranprojects/{id}', [PenawaranProjectController::class, 'show'])->name('penawaranprojects.show');

    // Route untuk menampilkan form edit proyek (edit)
    Route::get('/penawaranprojects/{id}/edit', [PenawaranProjectController::class, 'edit'])->name('penawaranprojects.edit');

    // Route untuk memperbarui proyek yang ada (update)
    Route::put('/penawaranprojects/{id}', [PenawaranProjectController::class, 'update'])->name('penawaranprojects.update');

    // Route untuk menghapus proyek (delete)
    Route::delete('/penawaranprojects/{id}', [PenawaranProjectController::class, 'destroy'])->name('penawaranprojects.destroy');

    Route::get('/penawaranpelatihan/{id}', [PenawaranProjectController::class, 'showPelatihan'])->name('penawaranpelatihan.show');
    Route::get('/penawaranpendanaan/{id}', [PenawaranProjectController::class, 'showPendanaan'])->name('penawaranpendanaan.show');
    Route::get('/penawaranriset/{id}', [PenawaranProjectController::class, 'showRiset'])->name('penawaranriset.show');


    Route::get('/penawaranpelatihan', [PenawaranProjectController::class, 'pelatihan'])->name('penawaranpelatihan');


    Route::get('/penawaranpendanaan', [PenawaranProjectController::class, 'pendanaan'])->name('penawaranpendanaan');


    Route::get('/penawaranriset', [PenawaranProjectController::class, 'riset'])->name('penawaranriset');
});

Route::middleware('role:pemerintah')->group(function () {
    Route::get('/pemerintah', [PemerintahController::class, 'index'])->name('pemerintah.dashboard');
    Route::get('/pemerintah/search', [PemerintahController::class, 'search'])->name('pemerintah.search');

});

Route::middleware('role:investor')->group(function () {
    Route::get('/investor', [InvestorController::class, 'index'])->name('investor.dashboard');
    Route::get('/investor/search', [InvestorController::class, 'search'])->name('investor.search');
});

Route::middleware('role:akademisi')->group(function () {
    Route::get('/akademisi', [AkademisiController::class, 'index'])->name('akademisi.dashboard');
    Route::get('/akademisi/search', [AkademisiController::class, 'search'])->name('akademisi.search');
});

Route::middleware('role:umkm')->group(function () {
    Route::get('/umkm', [UMKMController::class, 'index'])->name('umkm.dashboard');
    Route::get('/umkm/search', [UMKMController::class, 'search'])->name('umkm.search');
});

Route::middleware('role:komunitas')->group(function () {
    Route::get('/komunitas', [KomunitasController::class, 'index'])->name('komunitas.dashboard');
    Route::get('/komunitas/search', [KomunitasController::class, 'search'])->name('komunitas.search');
});

require __DIR__ . '/auth.php';
