@extends('daylight::layouts.app')

@section('title', $user->fullName)

@section('content')
    <x-daylight::page-header :title="$user->fullName">
        @if(auth()->user()->can('impersonate:users'))
            <livewire:daylight::user-actions :user="$user" />
        @endif

        @if(auth()->user()->can('update:users'))
            <x-daylight::buttons.primary href="{{ route('daylight.store.customers.edit', $user) }}" element="a">
                {{ __('daylight::general.edit') }}
            </x-daylight::buttons.primary>
        @endif
    </x-daylight::page-header>

    <x-daylight::session-messages/>

    <x-daylight::input.group :label="__('daylight::general.name')">
        <p class="block text-sm leading-6 text-gray-700 sm:pt-1.5">{{ $user->fullName }}</p>
    </x-daylight::input.group>

    <x-daylight::input.group :label="__('daylight::general.email')">
        <p class="block text-sm leading-6 text-gray-700 sm:pt-1.5">
            {{ $user->email }}

            @if($user->email_verified_at)
               <small class="text-green-400 ml-1">{{ __('daylight::general.verified_at', ['date' => $user->email_verified_at->format('d-m-Y H:i')]) }}</small>
            @else
                <small class="text-red-400 ml-1">{{ __('daylight::general.unverified') }}</small>
            @endif
        </p>
    </x-daylight::input.group>

    <x-daylight::input.group :label="__('daylight::general.phone')">
        <p class="block text-sm leading-6 text-gray-700 sm:pt-1.5">{{ $user->phone ?? __('daylight::general.n_a') }}</p>
    </x-daylight::input.group>

    <x-daylight::input.group :label="__('daylight::store.customer')">
        <p class="block text-sm leading-6 text-gray-700 sm:pt-1.5">
            @if($user->customer)
                <a href="{{ route('daylight.store.customers.show', $user->customer) }}" class="text-sky-700">
                    {{ $user->customer->name }}
                </a>
            @else
                {{ __('daylight::general.n_a') }}
            @endif
        </p>
    </x-daylight::input.group>

    <div class="my-6">
        <h3 class="text-base font-semibold leading-7 text-gray-900 mb-6">{{ __('daylight::store.orders_for_user') }}</h3>
        @if($user->orders_count === 0)
            <p class="block text-sm leading-6 text-gray-700">{{ __('daylight::store.no_orders_for_user') }}</p>
        @else
            <livewire:daylight::user-order-table :user="$user"/>
        @endif
    </div>
@endsection
