{{-- Ongoing incremental sync panel. Rendered ONLY for Shopify integrations that are enabled + Configured. Distinct from the historical sync panel (`_sync-panel.blade.php`) — different controls, different state subtree, different mental model. Required variables in scope: - $integration (App\Models\Integration) - $incrementalSnapshots (array{customers: array, orders: array}) - $canManage (bool) - $isLocal (bool) Methods on parent Livewire component: - enableIncremental(int, string) - disableIncremental(int, string) - runIncrementalNow(int, string) - clearIncrementalError(int, string) - runIncrementalSchedulerNow() --}} @php $incrementalStateLabel = function (?string $state): string { return match ($state) { 'idle' => __('Idle'), 'queued' => __('Queued'), 'syncing' => __('Running…'), 'failed' => __('Failed'), default => __('Idle'), }; }; $incrementalStateColor = function (?string $state): string { return match ($state) { 'idle' => 'zinc', 'queued' => 'zinc', 'syncing' => 'sky', 'failed' => 'red', default => 'zinc', }; }; $iso = fn ($v) => is_string($v) && $v !== '' ? \Illuminate\Support\Carbon::parse($v)->diffForHumans() : null; $resources = [ ['key' => 'customers', 'label' => __('Customers'), 'snap' => $incrementalSnapshots['customers'] ?? []], ['key' => 'orders', 'label' => __('Orders'), 'snap' => $incrementalSnapshots['orders'] ?? []], ]; @endphp
{{ __('Ongoing incremental sync') }}
{{ __('Lightweight 5-minute check for new and updated records. Runs only after the historical sync is complete.') }}
@foreach ($resources as $resource) @php $key = $resource['key']; $snap = $resource['snap']; $enabled = (bool) ($snap['enabled'] ?? false); $state = $snap['state'] ?? 'idle'; $blocked = (bool) ($snap['blocked_by_historical'] ?? false); $isRunning = in_array($state, ['queued', 'syncing'], true); @endphp
{{ $resource['label'] }} {{ $enabled ? __('Enabled') : __('Disabled') }} {{ $incrementalStateLabel($state) }}
@if ($blocked)
{{ __('Incremental sync will begin after the initial sync is complete.') }}
@endif
{{ __('Last checked') }}
{{ $iso($snap['last_checked_at'] ?? null) ?? '—' }}
{{ __('Last successful sync') }}
{{ $iso($snap['last_success_at'] ?? null) ?? '—' }}
{{ __('Records imported (last run)') }}
{{ number_format((int) ($snap['records_imported_last_run'] ?? 0)) }}
{{ __('Records imported (total)') }}
{{ number_format((int) ($snap['records_imported_total'] ?? 0)) }}
@if ($state === 'failed' && ! empty($snap['last_error']))
{{ $snap['last_error'] }}
@endif @if ($canManage)
@if (! $enabled) {{ __('Enable incremental sync') }} @else {{ __('Disable incremental sync') }} @if (! $blocked && ! $isRunning) {{ __('Run check now') }} @endif @if ($state === 'failed') {{ __('Clear error') }} @endif @endif
@endif
@endforeach
@if ($isLocal && $canManage)
{{ __('Incremental dev tools') }}: {{ __('Run scheduler now') }}

{{ __('Local development only. In production the scheduler runs automatically every 5 minutes via:') }} php artisan schedule:run {{ __('(driven by cron).') }}

@endif