@props([ // The shop's intake code. Null when its intake is closed, which is the one // case where there is nothing worth installing. 'code' => null, // The request whose progress this device would follow. Null on the intake // form itself, where there is not a job to be told about yet. 'token' => null, 'company' => null, ]) @php $company = $company ?: __('the shop'); // Notifications are offered only where they can actually be delivered: // there is a request to follow AND this installation has notification keys. // A fresh deploy has none, and promising a customer their phone will buzz // when nothing can send is worse than saying nothing. $canNotify = $token && app(\App\Services\PushService::class)->publicKey(); // Every browser-side outcome, in words a customer can act on. The staff // page has its own version of this list; the wording is different here on // purpose, because nobody standing in a print queue knows what a service // worker is. $reasons = [ 'unsupported' => __('This browser cannot do notifications. Chrome, Edge, Firefox and Safari all can.'), 'not-configured' => __('The shop has not switched notifications on yet.'), 'ios-needs-install' => __('On iPhone, add this page to your home screen first — then open it from there and turn notifications on.'), 'blocked' => __('Your browser is blocking notifications for this site. Open the padlock in the address bar and allow them, then try again.'), 'dismissed' => __('You closed the box without choosing. Tap again when you are ready.'), 'no-worker' => __('Your browser would not start the background helper needed for this.'), 'subscribe-failed' => __('Your browser refused to register for notifications. Try again, or restart it.'), 'server-refused' => __('We could not save this device. Try again in a moment.'), 'too-many-devices' => __('This request is already being followed on several devices.'), 'unavailable' => __('Your browser is not offering to install right now. Use its own menu and look for "Install" or "Add to Home screen".'), 'ios-manual' => __('Tap the Share button below, then "Add to Home Screen".'), ]; @endphp {{-- Nothing to install and nothing to be notified about: a closed intake on a server with no notification keys. Say nothing rather than draw an empty card offering neither. --}} @if ($code || $canNotify)

{{ __('Keep :company on your phone', ['company' => $company]) }}

{{ $canNotify ? __('Add this to your home screen so you can check back with one tap, and let us buzz you the moment your job moves.') : __('Add this to your home screen so your next request is one tap away.') }}

@if ($code) {{-- 1 · Install. Nothing to offer once it is already installed. --}} @endif @if ($canNotify) {{-- 2 · Notifications. Only ever about this one request. --}} {{-- Not offered at all where it cannot work: a browser without push, or a shop whose server has no notification keys yet. A button that can only ever apologise is worse than none. --}} @endif
@endif