<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\BannerController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\SubCategoryController;
use App\Http\Controllers\BrandController;
use App\Http\Controllers\RazorpayPaymentController;

/*
|--------------------------------------------------------------------------
| 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('/privacy-policy', function () {
    return view('privacy_policy');
})->name('privacy_policy');
Route::get('/payment-success', [App\Http\Controllers\IndexController::class, 'paymentSuccess'])->name('front.payment.success');
Route::post('/user_login', [App\Http\Controllers\IndexController::class, 'UserLogin'])->name('user.login');
Route::get('reset-password/{token}', [App\Http\Controllers\IndexController::class, 'showResetPasswordForm'])->name('reset.password.get');
Route::post('reset-password', [App\Http\Controllers\IndexController::class, 'submitResetPasswordForm'])->name('reset.password.post');
Route::get('/states/{countryId}', [App\Http\Controllers\IndexController::class, 'getStates']);

Route::controller(IndexController::class)->group(function () {
    
    Route::get('/','index')->name('user.home');
    Route::get('/product-details/{slug}','ProductDetails')->name('product.details');
    Route::get('/about-us','about')->name('user.about');
    Route::get('/contact-us','contact')->name('user.contact');
    Route::get('/login','login')->name('user.login');
    Route::get('/get-cart', 'getCart')->name('user.get.cart');
    Route::post('/add-to-cart', 'addToCart')->name('user.add.cart');
    Route::get('/remove-to-cart/{id}', 'removeFromCart')->name('user.remove.cart');
    Route::get('/cart', 'checkout')->name('user.checkout');
    Route::post('/address', 'address')->name('user.address');
    Route::post('/final-step', 'CheckoutFinal')->name('user.checkout.final');
    Route::post('/final_step', 'final_step')->name('user.final_step');
    Route::get('/categories/{id}', 'category')->name('user.category');
    
    Route::get('/order-success/{id}', 'orderSuccess')->name('user.order.success');
    
    Route::get('/sub-categories/{id}/{sub_id}', 'sub_category')->name('user.sub.category');
    
    Route::get('/products','shop')->name('user.shop');
    
    Route::post('/product-render', 'ProductRender')->name('user.product.render');
    // Route::get('/get-countries','getCountry')->name('');
    // Route::get('/get-countries','getCountry')->name('');
    
    Route::post('search-product', 'search_product')->name('user.search.product');
    // Route::post('verification-code', 'verification_code');
    // Route::post('resend-code', 'resend_code');
    // Route::post('login', 'login');
    // Route::post('forget-password', 'forget_password');
    // Route::get('banner-images', 'getbannerImage');
    // Route::get('products', 'get_product');
    // Route::get('get-all-products', 'get_all_product');
    // Route::post('productdetails', 'productdetails');
    
    // Cart Section
    // Route::get('get-cart', 'getCart');
    // Route::get('cart-count', 'getCartCount');
    // Route::post('add-to-cart', 'addToCart');
    // Route::post('remove-to-cart', 'removeFromCart');
    // Route::post('cart-update', 'CartUpdate');

    // Country, State
    Route::get('/get-countries','getCountry');
    Route::post('/get-state','getStates'); 
    Route::post('/get-city','getCities');
    Route::get('/refund-policy','refundPolicy')->name('refund.policy');
    Route::get('/privacy-policy','privacyPolicy')->name('privacy-policy');
    Route::get('/terms-of-service','termsService')->name('terms.of.service');
    Route::get('/shipping-policy','shippingPolicy')->name('shipping.policy');
    Route::get('/contact-information','contactInformation')->name('contact.information');
    // Wish List Section
    // Route::get('get-wish-list', 'getWishlist');
    // Route::get('wish-list-count', 'getWishlistCount');
    // Route::post('add-to-wish-list', 'addToWishlist');
    // Route::post('remove-to-wish-list', 'removeFromWishlist');
    
});

Route::controller(RazorpayPaymentController::class)->group(function () {
    Route::get('razorpay-payment', 'index');
    Route::post('razorpay-payment', 'store')->name('razorpay.payment.store');
});

Route::controller(IndexController::class)->group(function () {
    Route::any('instamojopayments/success', 'InstaSuccess')->name('quotationSelection');
    Route::any('success', 'InstaSuccess1');
});

Route::middleware('auth:sanctum')->group(function() {
    
    Route::controller(HomeController::class)->group(function () {
        
        // Order Process
        Route::post('check-coupen', 'CheckCoupen');
        Route::post('check-business-plan', 'CheckBusinessPlan');
        Route::post('checkout', 'checkout');
        Route::post('wallet', 'wallet');
        Route::post('select_address', 'select_address');
        Route::post('final-step', 'final_step');
        
        Route::post('orders-get', 'order_view');
        Route::post('order-details', 'order_details');
        Route::post('discount-amount', 'DiscountAmount');
        Route::post('invoice-download', 'invoice_download');
        
        // User Profile
        Route::post('view-profile', 'ViewProfile');
        Route::post('update-profile', 'BankUpdate');
        Route::post('change-password', 'change_password');
        Route::post('add-address', 'add_address');
        Route::post('update-address', 'update_address');
        Route::post('delete-address', 'deleteAddress');
        Route::post('get-address', 'getAddress');
        
        Route::post('user-chart', 'UserChart');
        Route::post('user-chart1', 'UserChart1');
        Route::post('user-chart2', 'UserChart2');
        
    });
    
    
});


Auth::routes();

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

Route::group(['prefix'=>'super-admin'],function (){
    Route::middleware(['super_admin', 'auth'])->group(function() {

        Route::controller(HomeController::class)->group(function () {
            Route::get('', 'admin_index')->name('admin.index');
            
            Route::get('/site-setting', 'SiteSetting')->name('site.setting');
            Route::post('/site-setting-update/{id}', 'SiteSettingUpdate')->name('site.setting.update');
            
            Route::get('/profile', 'AdminProfile')->name('admin.profile');
            Route::post('/profile/upload/{id}', 'AdminProfileUpload')->name('admin.profile.upload');
        });

        //User
        Route::group(['prefix'=>'user'],function (){
            Route::controller(UserController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.user.create');
                Route::get('/view', 'view')->name('admin.user.view');
                Route::get('/edit/{id}', 'edit')->name('admin.user.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.user.delete');

                Route::post('/store', 'store')->name('admin.user.store');
                Route::post('/update/{id}', 'update')->name('admin.user.update');
                
                Route::get('/details/{id}', 'details')->name('admin.user.details');
                Route::post('/transaction-history', 'TransactionHistory')->name('admin.user.transaction.history');
                
                Route::get('/user-chart/{id}', 'UserChart')->name('admin.user.details.chart');
                Route::post('/user-chart-leavel-1', 'UserChart1')->name('admin.user.chart.level.one');
                Route::post('/user-chart-leavel-2', 'UserChart2')->name('admin.user.chart.level.two');
                
            });
        });

        //Category
        Route::group(['prefix'=>'category'],function (){
            Route::controller(CategoryController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.category.create');
                Route::get('/view', 'view')->name('admin.category.view');
                Route::get('/edit/{id}', 'edit')->name('admin.category.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.category.delete');

                Route::post('/store', 'store')->name('admin.category.store');
                Route::post('/update/{id}', 'update')->name('admin.category.update');
            });
        });
        
        //Sub Category
        Route::group(['prefix'=>'sub-category'],function (){
            Route::controller(SubCategoryController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.sub.category.create');
                Route::get('/view', 'view')->name('admin.sub.category.view');
                Route::get('/edit/{id}', 'edit')->name('admin.sub.category.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.sub.category.delete');

                Route::post('/store', 'store')->name('admin.sub.category.store');
                Route::post('/update/{id}', 'update')->name('admin.sub.category.update');
            });
        });
        
        //Category
        Route::group(['prefix'=>'brand'],function (){
            Route::controller(BrandController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.brand.create');
                Route::get('/view', 'view')->name('admin.brand.view');
                Route::get('/edit/{id}', 'edit')->name('admin.brand.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.brand.delete');

                Route::post('/store', 'store')->name('admin.brand.store');
                Route::post('/update/{id}', 'update')->name('admin.brand.update');
            });
        });

        //Product
        Route::group(['prefix'=>'product'],function (){
            Route::controller(ProductController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.product.create');
                Route::get('/view', 'view')->name('admin.product.view');
                Route::get('/edit/{id}', 'edit')->name('admin.product.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.product.delete');

                Route::post('/store', 'store')->name('admin.product.store');
                Route::post('/update/{id}', 'update')->name('admin.product.update');
            });
        });

        //Banner
        Route::group(['prefix'=>'banner'],function (){
            Route::controller(BannerController::class)->group(function () {

                Route::get('/', 'view')->name('banner.page');
                Route::get('/banner-delete/{id}', 'delete')->name('banner.delete');

                Route::post('/banner-edit', 'edit')->name('banner.edit');
                Route::post('/banner-store', 'store')->name('banner.store');
                
            });
        });
        
        //Banner
        Route::group(['prefix'=>'orders'],function (){
            Route::controller(OrderController::class)->group(function () {

                Route::get('/', 'index')->name('order.page');
                Route::get('/order-delete/{id}', 'delete')->name('order.delete');
                Route::get('/order-details/{id}', 'OrderDetails')->name('order.details');
                Route::get('/invoice/{id}', 'invoice')->name('order.invoice');
                
                Route::post('/order-shipping-status', 'OrderShippingStatus')->name('order.shipping.status');
                
            });
        });
        
        //Report
        Route::group(['prefix'=>'report'],function (){
            Route::controller(OrderController::class)->group(function () {
                Route::get('/order-report', 'orderReport')->name('admin.report.order');
                Route::get('/user-report', 'userReport')->name('admin.report.user');
        
                Route::post('/user-report-download', 'UserReportDownload')->name('admin.report.user.download');
                Route::post('/order-report-download', 'OrderReportDownload')->name('admin.report.order.download');
            });
        });

        Route::group(['prefix'=>'notification'],function (){
            Route::controller(NotificationController::class)->group(function () {
                Route::get('', 'ViewAdminNotification')->name('admin.notification.view');
                Route::post('/status', 'NotificationAdminUpdate')->name('admin.notification.update');
            });
        });


    });
});

