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