<?php

use Illuminate\Support\Facades\Route;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\DbrLoginController;
use Themes\kbgolf\pro\app\Http\Controllers\ContactUsController;
use Themes\kbgolf\pro\app\Http\Controllers\Etc\OneToOneController;
use Themes\kbgolf\pro\app\Http\Controllers\IndexController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\CompanySignupController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\FindMemberIdController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\FindMemberIdVerifyController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\FindMemberPwVerifyController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\FindMemberPwVerifyinputController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\MemberDeviceBlockController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\MemberUnlockController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\MemberWithdrawalController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\PasswordChangeController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\LoginController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\MemberSignupVerifyController;
use Themes\kbgolf\pro\app\Http\Controllers\Auth\SignupController;
use Themes\kbgolf\pro\app\Http\Controllers\MyPage\NoticeController;
use Themes\kbgolf\pro\app\Http\Controllers\MyPage\QnaController;
use Themes\kbgolf\pro\app\Http\Controllers\PrivacyController;
use Themes\kbgolf\pro\app\Http\Controllers\Page\SiseController;
use Themes\kbgolf\pro\app\Http\Controllers\Page\ContactUsCustomController;


Route::middleware(['check.device.scale', 'check.gate.token'])->group(function () {
    Route::get('/intro', function () {
        return view('views.intro');
    })->name('intro');

    Route::get('/contact-custom-list', function () {
        return view('views.page.contact-custom-list');
    })->name('contact-custom-list');

    Route::get('/chat-ui-test', function () {
        return view('views.chat-ui');
    })->name('chat-ui');

    Route::get('/', [IndexController::class, 'index'])->name('index');

    Route::get('/privacy-list', [PrivacyController::class, 'index'])->name('privacy.index');
    Route::get('/privacy-detail/{unique}', [PrivacyController::class, 'show'])->name('privacy.show');

    Route::get('/post/faq', [QnaController::class, 'list'])->name('faq');

    Route::get('/post/1to1', [OneToOneController::class, 'list'])->name('1to1.list');
    Route::get('/post/1to1-details/{id}', [OneToOneController::class, 'show'])->name('1to1.show');
    Route::get('/post/1to1-form', function() {
        return view('views.etc.1to1-form');
    })->name('1to1.form');
    Route::post('/post/1to1-form', [OneToOneController::class, 'store'])->name('1to1.store');

    Route::get('/post/notice', [NoticeController::class, 'list'])->name('notice.list');
    Route::get('/post/notice-details/{id}', [NoticeController::class, 'show'])->name('notice.show');

    Route::get('/ai-chatbot-solutions', function() {
        return view('views.page.ai-chatbot-solutions');
    })->name('ai-chatbot-solutions.index');

    Route::get('/ai-matching-solutions', function() {
        return view('views.page.ai-matching-solutions');
    })->name('ai-matching-solutions.index');

    Route::get('/maint-matching', function() {
        return view('views.page.maint-matching');
    })->name('maint-matching.index');

    Route::get('/partner-showcases', function() {
        return view('views.page.partner-showcases');
    })->name('partner-showcases.index');

    Route::get('/partner-addnew', function() {
        return view('views.page.partner-addnew');
    })->name('partner-addnew.index');

    Route::get('/platform-solutions', function() {
        return view('views.page.platform-solutions');
    })->name('platform-solutions.index');

    Route::get('/platform-showcases', function() {
        return view('views.page.platform-showcases');
    })->name('platform-showcases.index');

    Route::get('/partner-mobile-kiosk', function() {
        return view('views.page.partner-mobile-kiosk');
    })->name('partner-mobile-kiosk.index');

    Route::get('/partner-coexistence', function() {
        return view('views.page.partner-coexistence');
    })->name('partner-coexistence.index');

    Route::get('/post/whats-new', function () {
        return view('views.post.whats-new');
    })->name('post.whats-new.index');

    Route::get('/post/functionality', function () {
        return view('views.post.functionality');
    })->name('post.functionality.index');

    Route::get('/feature/crm', function () {
        return view('views.feature.crm');
    })->name('feature.crm.index');

    Route::get('/feature/design', function () {
        return view('views.feature.design');
    })->name('feature.design.index');

    Route::get('/feature/basic', function () {
        return view('views.feature.basic');
    })->name('feature.basic.index');

    Route::get('/feature/cms', function () {
        return view('views.feature.cms');
    })->name('feature.cms.index');

    Route::get('/feature/erp', function () {
        return view('views.feature.erp');
    })->name('feature.erp.index');

    Route::get('/feature/pos', function () {
        return view('views.feature.pos');
    })->name('feature.pos.index');

    Route::get('/feature/extend', function () {
        return view('views.feature.extend');
    })->name('feature.extend.index');

    Route::get('/price/basic', function () {
        return view('views.price.basic');
    })->name('price.basic.index');

    Route::get('/price/quote', function () {
        return view('views.price.quote');
    })->name('price.quote.index');

    Route::get('/intro/ceo', function () {
        return view('views.intro.ceo');
    })->name('intro.ceo.index');

    Route::get('/intro/history', function () {
        return view('views.intro.history');
    })->name('intro.history.index');

    Route::get('/intro/development', function () {
        return view('views.intro.development');
    })->name('intro.development.index');

    Route::get('/intro/organization', function () {
        return view('views.intro.organization');
    })->name('intro.organization.index');

    Route::get('/intro/certificate', function () {
        return view('views.intro.certificate');
    })->name('intro.certificate.index');

    Route::get('/my-page/order-list', function () {
        return view('views.my-page.order-list');
    })->name('my-page.order.index');

    Route::get('/my-page/member-edit', function () {
        return view('views.my-page.member-edit');
    })->name('my-page.member-edit.index');

    Route::get('/my-page/event-list', function () {
        return view('views.my-page.event-list');
    })->name('my-page.event.index');

    Route::get('/my-page/notice-list', function () {
        return view('views.my-page.notice-list');
    })->name('my-page.notice.index');

    Route::get('/1to1-list', function () {
        return view('views.etc.1to1-list');
    })->name('1to1.index');

    Route::get('/paq', function () {
        return view('views.etc.paq');
    })->name('paq.index');

    Route::get('/policy-list', function () {
        return view('views.terms.policy-list');
    })->name('policy.index');


    Route::get('/e-finance-list', function () {
        return view('views.terms.e-finance-list');
    })->name('e-finance.index');

    Route::get('/refund-list', function () {
        return view('views.terms.refund-list');
    })->name('refund.index');

    /* 페이지보기위해 디자이너가 추가*/
    Route::get('/erp-solutions', function () {
        return view('views.erp-solutions');
    })->name('erp-solutions.index');

    Route::get('/blockchain-solutions', function () {
        return view('views.blockchain-solutions');
    })->name('blockchain-solutions.index');

    Route::get('/searchengine-solutions', function () {
        return view('views.searchengine-solutions');
    })->name('searchengine-solutions.index');

    Route::get('/maintenance-solutions', function () {
        return view('views.maintenance-solutions');
    })->name('maintenance-solutions.index');

    Route::get('/kkcrm-solutions', function () {
        return view('views.kkcrm-solutions');
    })->name('kkcrm-solutions.index');

    Route::get('/shop-solutions', function () {
        return view('views.shop-solutions');
    })->name('shop-solutions.index');

    Route::get('/elastic-solutions', function () {
        return view('views.elastic-solutions');
    })->name('elastic-solutions.index');

    Route::get('/pos-solutions', function () {
        return view('views.pos-solutions');
    })->name('pos-solutions.index');

    Route::get('/pos-solutions', function () {
        return view('views.pos-solutions');
    })->name('pos-solutions.index');

    Route::get('/sso-solutions', function () {
        return view('views.sso-solutions');
    })->name('sso-solutions.index');

    Route::get('/contact-us ', [ContactUsController::class, 'index'])->name('contact-us.index');
    Route::post('/contact-us', [ContactUsController::class, 'store'])->name('contact-us.store');

    Route::post('/contact-us-custom', [ContactUsCustomController::class, 'store'])->name('contact-us-custom.store');

    Route::get('/member-go-email', function() {
        return view('views.auth.member-go-email');
    })->name('member-go-email');

    Route::post('/review', [ReviewController::class, 'store'])->name('review.store');

    Route::get('/member-signup', [SignupController::class, 'index'])->name('member-signup.index');
    Route::post('/member-signup', [SignupController::class, 'store'])->name('member-signup.store');
    Route::get('/confirm', [SignupController::class, 'confirm'])->name('confirm');

    Route::get('/member-verify-ok', function() {
        return view('views.auth.member-verify-ok');
    })->name('member-verify-ok');

    Route::get('/member-verify-resend', function() {
        return view('views.auth.member-verify-resend');
    })->name('member-verify-resend');

    Route::post('/member-verify-resend', [SignupController::class, 'activateCodeResend'])->name('member-verify-resend');

    Route::get('/password-reset', function() {
        return view('views.auth.password-reset');
    })->name('password-reset');

    Route::get('/member-withdraw-cancel', function() {
        return view('views.auth.member-withdraw-cancel');
    })->name('member-withdraw-cancel');

    Route::get('/member-sso-login', function() {
        return view('views.auth.member-sso-login');
    })->name('member-sso-login');

    Route::get('/member-signup-agree', function() {
        return view('views.auth.member-signup-agree');
    })->name('member-signup-agree');

    Route::get('/member-company-signup', [CompanySignupController::class, 'index'])->name('member-company-signup.index');
    Route::post('/member-company-signup', [CompanySignupController::class, 'store'])->name('member-company-signup.store');

    Route::get('/member-signup-branch', function() {
        return view('views.auth.member-signup-branch');
    })->name('member-signup-branch');

    Route::get('/member-signup-verify', [MemberSignupVerifyController::class, 'index'])->name('member-signup-verify.index');
    Route::post('/member-signup-verify', [MemberSignupVerifyController::class, 'store'])->name('member-signup-verify.store');
    Route::post('/member-signup-verify-send', [MemberSignupVerifyController::class, 'sendCert'])->name('member-signup-verify.send');

    Route::get('/member-activate-failed', function() {
        return view('views.auth.member-activate-failed');
    })->name('member-activate-failed');

    Route::get('/password-reset-code-failed', function() {
        return view('views.auth.password-reset-code-failed');
    })->name('password-reset-code-failed');

    Route::get('/member-device-block-failed', function() {
        return view('views.auth.member-device-block-failed');
    })->name('member-device-block-failed');

    Route::get('/member-device-block-success', function() {
        return view('views.auth.member-device-block-success');
    })->name('member-device-block-success');

    Route::get('/member-unlock', [MemberUnlockController:: class, 'index'])->name('member-unlock.index');
    Route::post('/member-unlock', [MemberUnlockController:: class, 'store'])->name('member-unlock.store');
    Route::post('/member-unlock-send', [MemberUnlockController:: class, 'sendCert'])->name('member-unlock.send');

    Route::get('/member-device-block', [MemberDeviceBlockController:: class, 'store'])->name('member-device-block.store');

    Route::get('/find-member-id-verify', [FindMemberIdVerifyController:: class, 'index'])->name('find-member-id-verify.index');
    Route::post('/find-member-id-verify', [FindMemberIdVerifyController:: class, 'store'])->name('find-member-id-verify.store');

    Route::get('/find-member-id', [FindMemberIdController::class, 'index'])->name('find-member-id.index');

    Route::get('/find-member-pw-memcheck', function() {
        return view('views.auth.find-member-pw-memcheck');
    })->name('find-member-pw-memcheck.index');

    Route::get('/find-member-pw-verify', [FindMemberPwVerifyController::class, 'index'])->name('find-member-pw-verify.index');
    Route::post('/find-member-pw-verify', [FindMemberPwVerifyController::class, 'store'])->name('find-member-pw-verify.store');

    Route::get('/find-member-pw-verifyinput', [FindMemberPwVerifyinputController::class, 'emailVerifyinput'])->name('find-member-pw-verifyinput');

    Route::get('/password-change', [PasswordChangeController::class, 'index'])->name('password-change.index');
    Route::post('/password-change', [PasswordChangeController::class, 'store'])->name('password-change.store');

    Route::get('/member-login-broker', function () {
        session()->put('url.intended', url()->previous());
        return redirect()->route('member-login');
    });

    Route::group(['middleware' => 'check.pro.guest'], function () {

        Route::get('/member-login-dbr', [DbrLoginController::class, 'index'])->name('member-login-dbr');

        Route::get('/member-login', [LoginController::class, 'index'])->name('member-login');
        Route::post('/member-login', [LoginController::class, 'store'])->name('member-login.store');
    });

    Route::middleware('check.pro.member')->group(function () {
        Route::get('/member-withdrawal', [MemberWithdrawalController::class, 'index'])->name('member-withdrawal.index');
        Route::post('/member-withdrawal', [MemberWithdrawalController::class, 'store'])->name('member-withdrawal.store');

        Route::prefix('my-page')->name('my-page.')->group(function () {
            Route::get('/member-edit', [MemberEditController::class, 'index'])->name('member-edit.index');
            Route::post('/member-edit', [MemberEditController::class, 'store'])->name('member-edit.store');
//            Route::get('/member-edit', [MemberEditController::class, 'index'])->name('member-edit.index');
            Route::get('/member-edit/{id}', [MemberEditController::class, 'show'])->name('member-edit.show');
            Route::post('/member-edit/{id}', [MemberEditController::class, 'update'])->name('member-edit.update');
        });
    });

    // Route::get('/sise/{sisetype}/{area?}', [SiseController::class, 'index'])->name('sise');
    Route::get('/sise/{sisetype}/{area?}/{memberbershipname?}', [SiseController::class, 'index'])->name('sise');

    Route::get('/contactus-custom/{siseType?}/{postTitle?}', function($siseType = null, $postTitle = null) {
        if (is_null($postTitle) && !is_null($siseType)) {
            $postTitle = $siseType;
            $siseType = null;
        }
        return view('views.page.contactus-custom', [
            'siseType' => $siseType,
            'postTitle' => $postTitle,
        ]);
    })->name('contactus-custom');

    Route::get('/load-more-sise', [IndexController::class, 'loadMoreSise'])->name('load.more.sise');

    Route::get('/load-more-youtube', [IndexController::class, 'loadMoreYoutube'])->name('load.more.youtube');

    Route::get('/load-more-blog', [IndexController::class, 'loadMoreBlog'])->name('load.more.blog');

	// Route::get('/golf', function() {
    //     return view('views.page.golf');
    // })->name('golf');

	// Route::get('/condo', function() {
    //     return view('views.page.condo');
    // })->name('condo');

	// Route::get('/fitness', function() {
    //     return view('views.page.fitness');
    // })->name('fitness');


    Route::get('/contactus-custom-list/{id?}', [ContactUsCustomController::class, 'index'])->name('contactus-custom-list');

	Route::get('/status', function() {
        return view('views.page.status');
    })->name('status');

    Route::get('/status-details/{id}', [\Themes\kbgolf\pro\app\Http\Controllers\Post\StatusController::class, 'show'])->name('status-details');

    Route::get('/about', function() {
        return view('views.page.about');
    })->name('about');

	Route::get('/policy', function() {
        return view('views.page.policy');
    })->name('policy');

	Route::get('/map', function() {
        return view('views.page.map');
    })->name('map');

});

Route::get('/member-logout', function() {
    session()->forget('member');
    session()->forget('GateToken');
    session()->forget('locale');

    return redirect()->to('/');
})->name('member-logout');
