<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\LandingControllers;

use App\Http\Controllers\User\MasterDataControllers;
use App\Http\Controllers\User\DashboardControllers;
use App\Http\Controllers\User\PrediksiControllers;
use App\Http\Controllers\User\RiwayatControllers;
use App\Http\Controllers\User\ProfileControllers as UserProfile;
use App\Http\Controllers\User\BantuanControllers;

use App\Http\Controllers\Admin\DataPenjualanUserControllers;
use App\Http\Controllers\Admin\ManagementArtikelControllers;
use App\Http\Controllers\Admin\ManagementBantuanControllers;
use App\Http\Controllers\Admin\DashboardAdminControllers;
use App\Http\Controllers\Admin\HasilPrediksiControllers;
use App\Http\Controllers\Admin\ManagementFaqControllers;
use App\Http\Controllers\Admin\DataUserControllers;
use App\Http\Controllers\User\ProfileControllers as AdminProfile;



Route::get('/', [LandingControllers::class, 'index']);
Route::post('/send-contact-mail', [LandingControllers::class, 'sendContactMail'])->name('landing.contact.mail');

// User
Route::middleware(['auth', 'verified'])->prefix('user')->name('user.')->group(function () {
    
    Route::get('/dashboard', [DashboardControllers::class, 'index'])->name('dashboard');
    
    Route::get('/prediksi', [PrediksiControllers::class, 'index'])->name('prediksi');
    Route::post('/prediksi/forecast', [PrediksiControllers::class, 'getForecast'])->name('prediksi.forecast');
    Route::get('/prediksi/check-status', [PrediksiControllers::class, 'checkFlaskStatus'])->name('prediksi.check');

    Route::prefix('masterdata')->name('masterdata.')->group(function () {
        Route::get('/', [MasterDataControllers::class, 'index'])->name('index');
        Route::post('/import', [MasterDataControllers::class, 'import'])->name('import');
        Route::post('/siapkan-prediksi', [MasterDataControllers::class, 'siapkanPrediksi'])->name('siapkan');
        Route::post('/store-bulan', [MasterDataControllers::class, 'store_bulan'])->name('store_bulan');
        Route::post('/update-massal', [MasterDataControllers::class, 'updateMassal'])->name('update_massal');
        Route::delete('/delete-all', [MasterDataControllers::class, 'deleteAll'])->name('deleteAll');
        Route::delete('/delete-bulan/{bulan_tahun}', [MasterDataControllers::class, 'destroyBulan'])->name('destroy_bulan');
    });

    Route::get('/riwayat', [RiwayatControllers::class, 'index'])->name('riwayat');
    Route::get('/riwayat/export/{year}/{month}', [RiwayatControllers::class, 'exportExcel'])->name('riwayat.export');
    Route::delete('/riwayat/delete/{year}/{month}', [RiwayatControllers::class, 'destroy'])->name('riwayat.delete');

    Route::get('/bantuan', [BantuanControllers::class, 'index'])->name('bantuan');
    Route::post('/bantuan/store', [BantuanControllers::class, 'store'])->name('bantuan.store');
    
    Route::prefix('profile')->name('profile.')->group(function () {
        Route::get('/', [UserProfile::class, 'index'])->name('index');
        Route::post('/update', [UserProfile::class, 'update'])->name('update');
        Route::post('/password', [UserProfile::class, 'updatePassword'])->name('password');
    });
});

// Admin
Route::middleware(['auth'])->prefix('admin')->name('admin.')->group(function () {
    
    Route::get('/dashboard', [DashboardAdminControllers::class, 'index'])->name('dashboard');

    Route::get('/data-user', [DataUserControllers::class, 'index'])->name('data-user');
    Route::get('/data-user/{id}', [DataUserControllers::class, 'show'])->name('data-user.show');
    Route::delete('/data-user/{id}', [DataUserControllers::class, 'destroy'])->name('data-user.destroy');

    Route::get('/data-penjualan-user/export-rekap-massal', [DataPenjualanUserControllers::class, 'exportRekapMassal'])->name('data-penjualan-user.export-rekap-massal');
    Route::get('/data-penjualan-user', [DataPenjualanUserControllers::class, 'index'])->name('data-penjualan-user.index');
    Route::get('/data-penjualan-user/{id}', [DataPenjualanUserControllers::class, 'show'])->name('data-penjualan-user.show');
    Route::get('/data-penjualan-user/export/{id}', [DataPenjualanUserControllers::class, 'export'])->name('data-penjualan-user.export');

    Route::get('/hasil-prediksi/export-rekap-massal', [HasilPrediksiControllers::class, 'exportRekapMassal'])->name('hasil-prediksi.export-rekap-massal');
    Route::get('/hasil-prediksi', [HasilPrediksiControllers::class, 'index'])->name('hasil-prediksi');
    Route::get('/hasil-prediksi/detail/{id}', [HasilPrediksiControllers::class, 'show'])->name('hasil-prediksi.show');
    Route::get('/hasil-prediksi/export/{id}', [HasilPrediksiControllers::class, 'export'])->name('hasil-prediksi.export');
    
    Route::resource('management-artikel', ManagementArtikelControllers::class);
    Route::resource('management-faq', ManagementFaqControllers::class);
    Route::resource('management-bantuan', ManagementBantuanControllers::class);

    Route::prefix('profile')->name('profile.')->group(function () {
        Route::get('/', [AdminProfile::class, 'index'])->name('index');
        Route::post('/update', [AdminProfile::class, 'update'])->name('update');
        Route::post('/password', [AdminProfile::class, 'updatePassword'])->name('password');
    });
});

require __DIR__.'/auth.php';