Skip to content

Commit

Permalink
FIxed bug if no consents with fields
Browse files Browse the repository at this point in the history
  • Loading branch information
cannycookie authored and AravindRam-Ranium committed Mar 4, 2024
1 parent 6fcace7 commit 2f96059
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Livewire/ConsentOptionFormBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Visualbuilder\FilamentUserConsent\Livewire;

use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Concerns\InteractsWithForms;
Expand All @@ -13,9 +13,9 @@
use Illuminate\Support\HtmlString;
use Visualbuilder\FilamentUserConsent\Notifications\ConsentsUpdatedNotification;

class ConsentOptionFormBuilder extends SimplePage implements Forms\Contracts\HasForms
class ConsentOptionFormBuilder extends SimplePage implements Forms\Contracts\HasForms
{
use InteractsWithForms, InteractsWithFormActions;
use InteractsWithForms, InteractsWithFormActions;

public static ?string $title = 'Your consent is required';

Expand Down Expand Up @@ -50,15 +50,15 @@ public function mount(): void
abort(403, 'Forbidden User');
}

$this->user->collections = $this->user->outstandingConsents();
$this->user->collections = $this->user->outstandingConsents();

if ($this->user->collections->count() < 1) {
abort(403, 'No required consent');
}
}


protected function getFormSchema(): array
protected function getFormSchema(): array
{
if(!$this->user->collections) {
$this->user->collections = $this->user->outstandingConsents();
Expand All @@ -73,7 +73,7 @@ protected function getFormSchema(): array
];

if((int)$consentOption->additional_info === 1) {

$additionInfo = [];
foreach ($consentOption->fields as $field) {
$fieldName = "consents_info.$consentOption->id.{$field['name']}";
Expand Down Expand Up @@ -113,7 +113,7 @@ protected function getFormSchema(): array
}

return $formFields;
}
}

public function previousConsents($key)
{
Expand All @@ -123,7 +123,7 @@ public function previousConsents($key)
}
}

public function submit(): void
public function submit(): void
{
$formData = $this->form->getState();

Expand All @@ -146,7 +146,7 @@ public function submit(): void
]
);
}

Notification::make()
->title('Success')
->body('Your consent preferences have been saved.')
Expand All @@ -173,4 +173,4 @@ public function prepareField($component, $fieldOption, $consentOption)
}
return $component->required((bool)$fieldOption['required']);
}
}
}

0 comments on commit 2f96059

Please sign in to comment.