<?php
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\Member\DashboardController as MemberDashboardController;
use App\Http\Controllers\Partner\DashboardController as PartnerDashboardController;
use App\Livewire\Form;
use Illuminate\Support\Facades\Route;

Route::view('/', 'website.pages.index')->name('website.home');
Route::view('/about', 'website.pages.about')->name('website.about');
Route::view('/industrial-park', 'website.pages.industrial-park')->name('website.industrial-park');
Route::view('/map', 'website.pages.map')->name('website.map');
Route::view('/why-batam', 'website.pages.why-batam')->name('website.why-batam');
Route::view('/contact', 'website.pages.contact')->name('website.contact');

Route::get('form', Form::class);

Route::middleware('guest')->group(function () {
    Route::view('/login', 'website.auth.selector')->name('login');

    Route::get('/register', [AuthController::class, 'showRegister'])->name('register');
    Route::post('/register', [AuthController::class, 'register'])->name('register.store');
    Route::get('/register/partners', [AuthController::class, 'showPartnerRegister'])->name('register.partners');
    Route::post('/register/partners', [AuthController::class, 'registerPartner'])->name('register.partners.store');

    Route::get('/login/members', [AuthController::class, 'showMemberLogin'])->name('login.members');
    Route::post('/login/members', [AuthController::class, 'loginMember'])->name('login.members.submit');

    Route::get('/login/partners', [AuthController::class, 'showPartnerLogin'])->name('login.partners');
    Route::post('/login/partners', [AuthController::class, 'loginPartner'])->name('login.partners.submit');

    Route::get('/login/admin', [AuthController::class, 'showAdminLogin'])->name('login.admin');
    Route::post('/login/admin', [AuthController::class, 'loginAdmin'])->name('login.admin.submit');
});

Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth')->name('logout');

Route::middleware(['auth', 'role:member'])->group(function () {
    Route::get('/member/dashboard', [MemberDashboardController::class, 'index'])->name('member.dashboard');
    Route::view('/member/card', 'member.card')->name('member.card');
    Route::view('/member/offers', 'member.offers')->name('member.offers');
    Route::view('/member/partners', 'member.partners')->name('member.partners');
    Route::view('/member/history', 'member.history')->name('member.history');
    Route::view('/member/profile', 'member.profile')->name('member.profile');
});

Route::middleware(['auth', 'role:partner'])->group(function () {
    Route::get('/partner/dashboard', [PartnerDashboardController::class, 'index'])->name('partner.dashboard');
    Route::view('/partner/offers', 'partner.offers')->name('partner.offers');
    Route::view('/partner/redemptions', 'partner.redemptions')->name('partner.redemptions');
    Route::view('/partner/analytics', 'partner.analytics')->name('partner.analytics');
    Route::view('/partner/members', 'partner.members')->name('partner.members');
    Route::view('/partner/settings', 'partner.settings')->name('partner.settings');
});

Route::middleware(['auth', 'role:admin'])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::view('/members', 'admin.members')->name('members');
    Route::view('/partners', 'admin.partners')->name('partners');
    Route::view('/content', 'admin.content')->name('content');
    Route::view('/system', 'admin.system')->name('system');
    Route::get('/users', [UserController::class, 'index'])->name('users.index');
    Route::get('/users/create', [UserController::class, 'create'])->name('users.create');
    Route::post('/users', [UserController::class, 'store'])->name('users.store');
});


