Simplify Form logic

This commit is contained in:
weeb 2025-05-03 20:39:46 +02:00
parent 8a2cb7fb1f
commit b330c431ab
2 changed files with 22 additions and 30 deletions

View File

@ -21,8 +21,6 @@ class ApplicationForm extends Component
public $message = '';
public $applicationId;
public $applicationUuid;
public $captcha;
@ -73,10 +71,8 @@ class ApplicationForm extends Component
]);
}
$this->applicationId = $application->id;
$this->applicationUuid = (string) $application->uuid;
session()->flash('message', 'Application submitted successfully!');
$this->reset(['photos', 'message', 'captchaInput']);
}

View File

@ -1,19 +1,15 @@
<div class="max-w-2xl w-full md:w-xl mx-auto mt-10 flex flex-col gap-6">
@if (session()->has('message'))
@if ($applicationUuid)
<flux:callout variant="success" icon="check-circle">
<flux:callout.heading>Your application has been submitted.</flux:callout.heading>
<flux:callout.text>
You can check its status here: <flux:callout.link
href="{{ route('application', ['uuid' => $applicationUuid]) }}">View Application Status
</flux:callout.link>
<br>Please save or bookmark that link, as the approval process can take 24-48 hours.
</flux:callout.text>
</flux:callout>
@endif
@endif
@if (!$applicationUuid)
@if ($applicationUuid)
<flux:callout variant="success" icon="check-circle">
<flux:callout.heading>Your application has been submitted.</flux:callout.heading>
<flux:callout.text>
You can check its status here: <flux:callout.link
href="{{ route('application', ['uuid' => $applicationUuid]) }}">View Application Status
</flux:callout.link>
<br>Please save or bookmark that link, as the approval process can take 24-48 hours.
</flux:callout.text>
</flux:callout>
@else
<form wire:submit.prevent="submit" enctype="multipart/form-data">
<div class="flex flex-col gap-4 mb-6">
<flux:callout variant="secondary" icon="information-circle" heading="Here you can submit your application."
@ -28,6 +24,17 @@
<flux:input type="file" wire:model="photos" label="Loli Photos (max. 6 files, max. 8MB per file)"
multiple />
@if ($photos)
<div class="mt-4">
<flux:heading>Photo Preview</flux:heading>
<div class="flex gap-4 mt-2">
@foreach ($photos as $photo)
<img src="{{ $photo->temporaryUrl() }}" class="w-24 h-24 object-cover rounded">
@endforeach
</div>
</div>
@endif
<div class="mt-4">
<div class="flex">
<flux:input label="Captcha" wire:model.defer="captchaInput" />
@ -39,15 +46,4 @@
<flux:button class="w-full" variant="primary" wire:click="submit">Submit Application</flux:button>
</form>
@endif
@if ($photos)
<div class="mt-4">
<h3 class="font-bold">Photo Preview:</h3>
<div class="flex gap-4 mt-2">
@foreach ($photos as $photo)
<img src="{{ $photo->temporaryUrl() }}" class="w-24 h-24 object-cover rounded">
@endforeach
</div>
</div>
@endif
</div>