<?php

use App\Http\Controllers\HomeController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\ShipmentController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\SettingController;
use App\Http\Controllers\TrackingUpdateController;
use App\Http\Controllers\TrackUpdateController;
use App\Http\Controllers\TrackingController;
use Illuminate\Support\Facades\Route;


Route::get('/link', function () {
    Artisan::call('storage:link');
});

Route::redirect('/home', '/admin/dashboard');

Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/about', [HomeController::class, 'about'])->name('about');
Route::get('/contact', [HomeController::class, 'contact'])->name('contact');
Route::post('/contact', [HomeController::class, 'submitContact'])->name('contact.submit');
Route::get('/track', [TrackingController::class, 'show'])->name('track');
Route::post('/track', [TrackingController::class, 'track'])->name('track.submit');
Route::get('/track/{tracking_number}', [TrackingController::class, 'track'])->name('track.number');

// Admin Routes
Route::middleware(['auth'])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [AdminController::class, 'dashboard'])->name('dashboard');
    Route::resource('shipments', ShipmentController::class);
 	Route::get('shipments/{shipment}/invoice', [ShipmentController::class, 'generateInvoice'])
        ->name('shipments.invoice');
    Route::post('shipments/{shipment}/update-status', [ShipmentController::class, 'updateStatus'])
        ->name('shipments.update-status');
    Route::get('shipments/{shipment}/tracking-update/create', [TrackingUpdateController::class, 'create'])
        ->name('tracking-updates.create');
    Route::post('shipments/{shipment}/tracking-update', [TrackingUpdateController::class, 'store'])
        ->name('tracking-updates.store');
     Route::get('shipments/{shipment}/updates', [TrackUpdateController::class, 'index'])
        ->name('shipments.updates.index');
    Route::delete('shipments/{shipment}/updates/{update}', [TrackUpdateController::class, 'destroy'])
        ->name('shipments.updates.destroy');
    Route::get('/settings/general', [SettingController::class, 'general'])->name('settings.general');
	Route::get('/settings/email', [SettingController::class, 'email'])->name('settings.email');
    Route::put('/settings/update', [SettingController::class, 'update'])->name('settings.update');
    Route::post('/settings/test-email', [SettingController::class, 'testEmail'])->name('settings.test-email');
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile');
    Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
});