@php
	$companies = \App\Models\Company::whereNotNull('name_english')->whereNotNull('name_chinese')->orderBy('created_at', 'desc')->get()->take(5);

	if ($companies && ! auth()->user()->adminActiveCompany) {
		auth()->user()->update([
			'admin_active_company_id' => $companies->first()->id,
		]);
	}
@endphp
<div class="main-dashboard-navigation">
	<div class="main-dashboard-title">
		<h1 class="h2-title white">{{ __("Hi, :Name Welcome back!", ['name' => auth()->user()->name]) }}</h1>
	</div>
	<div class="main-dashboard-buttons">
		<ul>
			<li class="has-dropdown">
				<a href="" class="with-dropdown"><img src="{{ asset('themes/tailwind/images/language.svg') }}"> {{ strtoupper(app()->getLocale()) }}</a>
				<ul class="dropdown user-selection">
					@foreach(config('app.available_locales') as $available_locale => $locale_name)
						<li class="{{ $available_locale === app()->getLocale() ? 'active' : '' }}"><a class="change-language" href="{{ route('language', [$available_locale]) }}">{{ $locale_name }}</a></li>
					@endforeach
				</ul>
			</li>
			<li class="has-dropdown">
				{{-- <a href="" class="with-dropdown"><img src="{{ asset('themes/tailwind/images/sample-user.svg') }}"> {{ auth()->user()->name }}</a> --}}
				<a href="" class="with-dropdown"><img src="{{ asset('themes/tailwind/images/sample-user.svg') }}"> {{ isset(auth()->user()->adminActiveCompany->name) ? auth()->user()->adminActiveCompany->name : '' }}</a>
				<ul class="dropdown user-selection">
					@foreach($companies as $company)
						<li class="{{ auth()->user()->admin_active_company_id === $company->id ? 'active' : '' }}"><a class="" href="{{ route('cms.change-active-company', [$company->id]) }}"><img src="{{ asset('themes/tailwind/images/sample-company.png') }}"> {{ $company->name ?? 'null' }}</a></li>
					@endforeach
					<li>
						<div class="user-selection__buttons">
							<button  class="btn" type="button">{{ __("Add Account") }}</button>
							<a href="{{ route('wave.logout') }}" class="btn btn-error" >{{ __("Logout this account") }}</a>
						</div>
					</li>
				</ul>
			</li>
			<li class="has-dropdown mr-0">
				<a href="" class="position-relative notification-icon">
					<img src="{{ asset('themes/tailwind/images/notification.svg') }}">
					<span class="new-icon" style="display:none;"></span>
				</a>
				<ul class="dropdown notification-selection">
					<h3 class="dropdown-title">{{ __("Notification") }}</h3>
					<div id="notificationWrapper">
						{{-- <div class="dropdown-list-item">
							<div class="dropdown-sidetext">
								<h4 class="dropdown-subtitle">{{ __("Service Chat") }}</h4>
								<a href="">{{ __("Check") }}</a>
							</div>
							<ul class="dropdown-list">
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/building.svg') }}">
										<span>Hi. I am Logistics Manager at companyA. My Name is Ellen... </span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/building.svg') }}">
										<span>Hi. I am Logistics Manager at companyA. My Name is Ellen... </span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
							</ul>
						</div>
						<div class="dropdown-list-item">
							<div class="dropdown-sidetext">
								<h4 class="dropdown-subtitle">{{ __("Service Chat") }}</h4>
								<a href="">{{ __("Check") }}</a>
							</div>
							<ul class="dropdown-list">
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/pdf.svg') }}">
										<span>ABC Ltd_202301Bank statement_... <i class="success item-list-note">Entry Completed</i></span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/pdf.svg') }}">
										<span>ABC Ltd_202301Bank statement_... <i class="success item-list-note">Entry Completed</i></span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
							</ul>
						</div>
						<div class="dropdown-list-item">
							<div class="dropdown-sidetext">
								<h4 class="dropdown-subtitle">{{ __("Service Chat") }}</h4>
								<a href="">{{ __("Check") }}</a>
							</div>
							<ul class="dropdown-list">
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/jpg.svg') }}">
										<span>ABC Ltd_202301Bank statement_... <i class="item-list-note success">Entry Completed</i></span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
								<li>
									<div class="item-list">
										<img src="{{ asset('themes/tailwind/images/jpg.svg') }}">
										<span>ABC Ltd_202301Bank statement_... <i class="failed item-list-note">Failed</i></span>
										<a href="">{{ __("Check") }}</a>
									</div>
								</li>
							</ul>
						</div> --}}
					</div>
					<a href="#" class="d-flex align-items-center justify-content-center py-3" id="notificationShowMore" style="font-size: 16px;">{{ __("Show more") }}</a>
				</ul>
			</li>
			@if (auth()->user()->userRole->hasAccess('manage-company-settings'))
				<li>
					<a href="{{ route('cms.settings') }}"><img src="{{ asset('themes/tailwind/images/setting.svg') }}"></a>
				</li>
			@endif
		</ul>
	</div>
</div>
