@extends('layouts.dashboard') @section('title', trans('dashboard.onboarding_title')) @section('header_title', trans('dashboard.onboarding_header')) @section('content') @php $profileReady = $tenant->isReadyForProductionCsr(); $pendingDevices = $devices->filter(fn ($d) => $d->onboarding_status !== 'production_ready'); $complianceDevices = $devices->filter(fn ($d) => $d->onboarding_status === 'compliance_done'); $csrDevices = $devices->filter(fn ($d) => in_array($d->onboarding_status, ['pending', 'csr_generated'], true)); $env = $tenant->zatcaEnvironment(); @endphp
@foreach([ ['1', trans('dashboard.step_company'), $profileReady], ['2', trans('dashboard.step_csr'), $devices->isNotEmpty()], ['3', trans('dashboard.step_otp_csid'), $devices->contains(fn ($d) => in_array($d->onboarding_status, ['compliance_done', 'production_ready'], true))], ['4', trans('dashboard.step_production'), $devices->contains(fn ($d) => $d->onboarding_status === 'production_ready')], ] as [$n, $label, $done])
{{ $n }}
{{ $label }}
@endforeach
{{-- STEP 1: Organization Details (بيانات المنشأة) --}}

{{ trans('dashboard.org_details_title') }}

{{ trans('dashboard.org_subtitle') }}

@if($tenant->vat_number)
{{ trans('dashboard.vat_number') }} {{ $tenant->vat_number }}
@endif
@if($errors->any())
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
@csrf {{-- VAT Number (Input if not set or editing) --}}
{{-- Live validation message --}}
{{-- Visual progress bar --}}
{{-- Organization Name --}}
{{-- Organization Identifier --}}
{{-- Short National Address --}}

{{ trans('dashboard.short_address_hint') }}

{{-- Address Details Header --}}
{{ trans('dashboard.address_details_badge') }}
{{-- Street --}}

{{ trans('dashboard.address_zatca_required_hint') }}

{{-- STEP 2: ZATCA Linking & OTP Activation --}}

{{ trans('dashboard.otp_heading') }}

{{ trans($env->fatooraHintKey()) }}

{{-- Sandbox Notice --}}
{{ trans('dashboard.env_sandbox_name') }} (Sandbox)
{{ trans('dashboard.env_safe_testing') }}

{{ trans('dashboard.env_forced_sandbox_note') }}

{{-- Switch to Production CTA (if sandbox and profile ready) --}} @if($tenant->is_sandbox && $profileReady)

{{ trans('dashboard.env_switch_production_prompt') }}

{{ trans('dashboard.switch_to_production_desc') }}

{{ trans('dashboard.env_switch_production_btn') }}
@endif {{-- Direct OTP Form (No Manual Device Creation Required) --}}
@csrf {{-- Hidden field that submits the combined OTP value --}} @if($csrDevices->count() > 1)
@elseif($csrDevices->count() === 1) @endif {{-- 6-box OTP input --}}
@for($i = 0; $i < 6; $i++) @endfor

{{ trans('dashboard.otp_input_hint') }}

{{ trans('dashboard.registered_devices_title') }}

@forelse($devices as $d) @empty @endforelse
{{ trans('dashboard.device_th') }} {{ trans('dashboard.serial_th') }} {{ trans('dashboard.status_th') }} {{ trans('dashboard.cert_th') }}
{{ $d->name }} {{ $d->serial_number }} @if($d->onboarding_status === 'production_ready') {{ trans('dashboard.csid_ready') }} @else {{ $d->onboarding_status }} @endif {{ $d->certificate_pem ? trans('dashboard.cert_active') : trans('dashboard.cert_waiting_otp') }}
{{ trans('dashboard.no_devices_registered') }}
{{-- Interactive Guide Modal --}} {{-- Live Connecting / Progress Overlay --}}
@endsection