<?php

use App\Http\Controllers\CustomerController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\TransactionController;
use App\Http\Controllers\BranchController;
use App\Http\Controllers\CashierController;
use App\Http\Controllers\MailTemplateController;
use App\Http\Controllers\VoucherController;
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 within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    // return view('auth.login');
    return redirect()->route('pelanggan-baru');
});
Route::get('komunitas', [CustomerController::class, 'createKomunitas']);
Route::get('owner', [CustomerController::class, 'createOwner']);
Route::get('karyawan', [CustomerController::class, 'createKaryawan']);
Route::post('store-new-member', [CustomerController::class, 'storeNew']);
Route::get('member/create-new', [CustomerController::class, 'create']);
Route::post('member/store-new', [CustomerController::class, 'store']);

// Route::get('/dashboard', function () {
//     return view('dashboard');
// })->middleware(['auth'])->name('dashboard');
Route::middleware(['auth'])->group(
    function () {
        // Route::get('/', function () {
        //     $param['pageIcon'] = 'fa fa-home';
        //     $param['pageTitle'] = 'Aplikasi Member';
        //     return view('dashboard', $param);
        // })->middleware(['auth'])->name('dashboard');
        Route::get('/dashboard', function () {
            $param['pageIcon'] = 'fa fa-home';
            $param['pageTitle'] = 'Aplikasi Member';
            return view('dashboard', $param);
        })->middleware(['auth'])->name('dashboard');
        // Route::resource('dashboard', DashboardController::class);
        Route::get('cek-poin', [CustomerController::class, 'cekPoin']);
        // Route::get('get-by-phone', [CustomerController::class, 'cekPoinByPhone']);
        Route::get('settings', [VoucherController::class, 'settings']);
        Route::put('settings', [VoucherController::class, 'updateSettings']);
        Route::get('voucher/getMember', [VoucherController::class, 'getMember']);
        Route::resource('voucher', VoucherController::class);
        Route::get('member/export', [CustomerController::class, 'export']);
        Route::post('member/import', [CustomerController::class, 'import']);
        Route::get('list-member', [CustomerController::class, 'list']);
        Route::resource('member', CustomerController::class);
        Route::get('redeem', [TransactionController::class, 'redeem']);
        Route::resource('transaction', TransactionController::class);
        Route::resource('branch', BranchController::class);
        Route::get('change-password', [CashierController::class, 'changePassword'])->name('change_password');
        Route::put('change-password/{id}', [CashierController::class, 'updatePassword'])->name('update_password');
        Route::resource('cashier', CashierController::class);
        Route::get('mail-template/blast', [MailTemplateController::class, 'blast']);
        Route::post('mail-template/submit-blast', [MailTemplateController::class, 'submitBlast']);
        Route::post('mail-templpate/uploadImage', [MailTemplateController::class, 'uploadImage']);
        Route::resource('mail-template', MailTemplateController::class);
    }
);

Route::post('resendmail', [CustomerController::class, 'postResendmail']);
Route::get('confirm', [CustomerController::class, 'getConfirm']);
Route::get('get-by-phone', [CustomerController::class, 'cekPoinByPhone']);
Route::get('cek-poin-pelanggan', [CustomerController::class, 'cekPoinCustomer'])->name('cek-poin');
Route::get('pelanggan', [CustomerController::class, 'pelangganBaru'])->name('pelanggan-baru');
Route::post('store-pelanggan', [CustomerController::class, 'storePelanggan'])->name('simpan-pelanggan');

require __DIR__ . '/auth.php';
