delete environment confirmation

This commit is contained in:
ayntk-ai
2024-08-31 15:06:07 +02:00
parent a3dd48de1d
commit 830c047ccf
2 changed files with 11 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Environment; use App\Models\Environment;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component; use Livewire\Component;
class DeleteEnvironment extends Component class DeleteEnvironment extends Component
@@ -21,8 +23,12 @@ class DeleteEnvironment extends Component
$this->environmentName = Environment::findOrFail($this->environment_id)->name; $this->environmentName = Environment::findOrFail($this->environment_id)->name;
} }
public function delete() public function delete($password)
{ {
if (!Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
$this->validate([ $this->validate([
'environment_id' => 'required|int', 'environment_id' => 'required|int',
]); ]);

View File

@@ -1,14 +1,12 @@
<x-modal-confirmation <x-modal-confirmation
title="Confirm Delete Environment?" title="Confirm Environment Deletion?"
buttonTitle="Delete Environment" buttonTitle="Delete Environment"
isErrorButton isErrorButton
action="delete_environment" submitAction="delete"
:actions="['This will delete the selected environment.']" :actions="['This will delete the selected environment.']"
confirmationLabel="Please confirm the execution of the actions by entering the Environment Name below" confirmationLabel="Please confirm the execution of the actions by entering the Environment Name below"
shortConfirmationLabel="Environment Name" shortConfirmationLabel="Environment Name"
submitAction="delete_environment"
buttonTitle="Delete Environment" buttonTitle="Delete Environment"
confirmText="{{ $environmentName }}" confirmationText="{{ $environmentName }}"
step3ButtonText="Permanently Delete Environment" step3ButtonText="Permanently Delete Environment"
> />
</x-modal-confirmation>