diff --git a/resources/views/head.antlers.html b/resources/views/head.antlers.html new file mode 100755 index 0000000..b91e0b5 --- /dev/null +++ b/resources/views/head.antlers.html @@ -0,0 +1,18 @@ + + diff --git a/resources/views/head.blade.php b/resources/views/head.blade.php deleted file mode 100755 index 2c209a2..0000000 --- a/resources/views/head.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -
- @if ($configured) - - - @endif -
diff --git a/routes/actions.php b/routes/actions.php new file mode 100644 index 0000000..73de7fd --- /dev/null +++ b/routes/actions.php @@ -0,0 +1,6 @@ +name('front.config'); diff --git a/src/Http/Controllers/ConfigController.php b/src/Http/Controllers/ConfigController.php new file mode 100644 index 0000000..7db5667 --- /dev/null +++ b/src/Http/Controllers/ConfigController.php @@ -0,0 +1,38 @@ +email(); + $hash = hash_hmac('sha256', $email, config('front.secret_key')); + $name = $user->get('name'); + } + + return response()->json([ + 'configured' => $this->isConfigured(), + 'chatId' => config('front.chat.id'), + 'email' => $email, + 'name' => $name, + 'hash' => $hash, + ]); + } + + private function isConfigured(): bool + { + return config('front.chat.show_on_front_end') && + config('front.chat.id') && + config('front.secret_key'); + } +} diff --git a/src/Http/Livewire/Scripts.php b/src/Http/Livewire/Scripts.php deleted file mode 100644 index b6fbc8c..0000000 --- a/src/Http/Livewire/Scripts.php +++ /dev/null @@ -1,33 +0,0 @@ -email(); - $u['hash'] = hash_hmac('sha256', $u['email'], config('front.secret_key')); - $u['name'] = $user->get('name'); - } - - return view('front::head', [ - 'configured' => $this->isConfigured(), - 'chatId' => config('front.chat.id'), - 'user' => $u, - ]); - } - - private function isConfigured(): bool - { - return config('front.chat.show_on_front_end') && - config('front.chat.id') && - config('front.secret_key'); - } -} diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index ef061e0..a13c003 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -5,16 +5,18 @@ use Illuminate\Notifications\ChannelManager; use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\View; -use Livewire\Livewire; use Statamic\Facades\User as UserFacade; use Statamic\Providers\AddonServiceProvider; use Statamic\Statamic; use Statamic\Support\Arr; -use TransformStudios\Front\Http\Livewire\Scripts; use TransformStudios\Front\Notifications\Channel; class ServiceProvider extends AddonServiceProvider { + protected $routes = [ + 'actions' => __DIR__.'/../routes/actions.php', + ]; + protected $vite = [ 'input' => [ 'resources/css/cp.css', @@ -28,8 +30,6 @@ public function bootAddon() { $this->bootScript(); - Livewire::component('front.scripts', Scripts::class); - // needed for testing but not production // $this->loadViewsFrom( // __DIR__.'/../resources/views',