BUG 加入完整功能 20250604
This commit is contained in:
parent
c52509b478
commit
7ceed0b108
@ -8,10 +8,11 @@ use App\Models\Branch;
|
|||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use App\Services\ApiClient;
|
use App\Services\ApiClient;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use WireUi\Traits\WireUiActions;
|
||||||
|
|
||||||
class RoomDetailModal extends Component
|
class RoomDetailModal extends Component
|
||||||
{
|
{
|
||||||
|
use WireUiActions;
|
||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'openModal', 'closeModal',
|
'openModal', 'closeModal',
|
||||||
@ -78,14 +79,14 @@ class RoomDetailModal extends Component
|
|||||||
$token = $user->api_plain_token ?? null;
|
$token = $user->api_plain_token ?? null;
|
||||||
|
|
||||||
if (!$token) {
|
if (!$token) {
|
||||||
$this->addError('api', 'API token is missing.');
|
$this->sendErrorNotification('api', 'API token is missing.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$api = new ApiClient(config('app.url') , $token );
|
$api = new ApiClient(config('app.url') , $token );
|
||||||
$response = $api->post('/api/room/sendSwitch', $data);
|
$response = $api->post('/api/room/sendSwitch', $data);
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
$this->addError('api', 'API request failed: ' . $response->body());
|
$this->sendErrorNotification('api', 'API request failed: ' . $response->body());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// ✅ 成功提示
|
// ✅ 成功提示
|
||||||
@ -98,7 +99,14 @@ class RoomDetailModal extends Component
|
|||||||
$this->showModal = false;
|
$this->showModal = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public function sendErrorNotification(string $title = '錯誤', string $description = '發生未知錯誤')
|
||||||
|
{
|
||||||
|
$this->notification()->send([
|
||||||
|
'icon' => 'error',
|
||||||
|
'title' => $title,
|
||||||
|
'description' =>$description,
|
||||||
|
]);
|
||||||
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.admin.room-detail-modal');
|
return view('livewire.admin.room-detail-modal');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user