Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(invitees): add confirmation dialog before removing shares or assistants (#69) #106

Merged
merged 5 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion app/Http/Controllers/Applications/InviteesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ public function view()
]);
}

/**
* This is the confirmation page for removing a share/assistant from a dealership.
* It has been added in place of the confirmationless @see InviteesController::destroy().
*/
public function delete(InviteeRemovalRequest $request)
{
$invitee = Application::findOrFail($request->get('invitee_id'));
// Note: We do not check the end dates here but in the actual destroy handler below.
// Users should not be routed to this view anyway if they are not allowed to do this.

return view('application.invitee-delete', [
"invitee" => $invitee,
]);
}

/**
* This is the actual destroy function, which was previously executed without a confirmation page.
* @param InviteeRemovalRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(InviteeRemovalRequest $request)
{
$invitee = Application::findOrFail($request->get('invitee_id'));
Expand All @@ -66,7 +86,7 @@ public function destroy(InviteeRemovalRequest $request)
if ($oldParent) {
$oldParent->user()->first()->notify(new LeaveNotification($oldApplicationType->value, $invitee->user()->first()->name));
}
return back();
return Redirect::route('applications.invitees.view');
}

public function codes(Request $request)
Expand Down
4 changes: 2 additions & 2 deletions database/factories/TableTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public function definition(): array
{
return [
'name' => $this->faker->name(),
'spaces' => $this->faker->randomNumber(),
'seats' => $this->faker->randomNumber(),
'spaces' => $this->faker->randomDigitNotZero() + 1,
'seats' => $this->faker->randomDigitNotZero() + 1,
'price' => $this->faker->randomNumber(),
'package' => $this->faker->word(),
'created_at' => Carbon::now(),
Expand Down
11 changes: 8 additions & 3 deletions resources/css/app.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
$primary: #00504b;
@import "bootstrap/scss/bootstrap.scss";

label.required:after, legend.required:after, span.required:after {
label.required:after,
legend.required:after,
span.required:after {
content: "*";
color: red;
}

/* DD Specific */
.dd-table-button {
width: 5ex;
height: 5ex;
width: 5.5ex;
height: 5.5ex;
font-weight: bold;
margin: 0.25ex;
display: inline-flex;
align-items: center;
justify-content: center;
}

.dd-table-button.border-danger {
Expand Down
41 changes: 41 additions & 0 deletions resources/views/application/invitee-delete.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@extends('layouts.app')
@section('title')
Remove {{ ucfirst($invitee->type->value) }} from your Dealership
@endsection
@section('content')
<div class="">
<h1 class="text-center">@yield('title')</h1>

<div class="mx-auto text-center mb-4">
<a href="{{ route('dashboard') }}" class="btn btn-sm btn-primary">Return to Dashboard</a>
</div>

<form class="needs-validation" method="POST" action="{{ route('applications.invitees.destroy') }}">
@method('DELETE')
@csrf
<input type="hidden" name="invitee_id" value="{{ $invitee->id }}">
<div class="card">
<div class="card-body">
<div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold">You are removing <span class="text-nowrap text-primary">{{ $invitee->user->name }}</span> from your Dealership!</h1>
<div class="col-lg-6 mx-auto">
<p class="lead mb-4">
This action will cause them to be completely removed as a {{ ucfirst($invitee->type->value) }} from your dealership.<br>
They will be notified of this.
</p>
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a href="{{ route('dashboard') }}"
class="btn btn-outline-secondary btn-lg px-4">
Stop! Take me back!
</a>
<button type="submit" class="btn btn-danger btn-lg px-4 gap-3">
Yes, remove this {{ ucfirst($invitee->type->value) }} from my Dealership
</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
@endsection
6 changes: 2 additions & 4 deletions resources/views/application/invitees.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
@endif
@foreach ($shares as $share)
<li class="list-group-item">
<form method="POST" action="{{ route('applications.invitees.destroy') }}">
@method('DELETE')
<form method="POST" action="{{ route('applications.invitees.delete') }}">
@csrf
<input type="hidden" name="invitee_id" value="{{ $share->id }}">
@if (
Expand Down Expand Up @@ -108,9 +107,8 @@
@endif
@foreach ($assistants as $assistant)
<li class="list-group-item">
<form method="POST" action="{{ route('applications.invitees.destroy') }}">
<form method="POST" action="{{ route('applications.invitees.delete') }}">
@if (config('convention.assistant_end_date')->isFuture())
@method('DELETE')
@csrf
<input type="hidden" name="invitee_id" value="{{ $assistant->id }}">
<button type="submit" class="btn btn-sm btn-danger d-inline">X</button>
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Route::delete('applications', [\App\Http\Controllers\Applications\ApplicationController::class, 'destroy'])->name('applications.destroy');

Route::get('applications/invitees', [\App\Http\Controllers\Applications\InviteesController::class, 'view'])->name('applications.invitees.view');
Route::post('applications/invitees/delete', [\App\Http\Controllers\Applications\InviteesController::class, 'delete'])->name('applications.invitees.delete');
Route::delete('applications/invitees', [\App\Http\Controllers\Applications\InviteesController::class, 'destroy'])->name('applications.invitees.destroy');
Route::post('applications/invitees/codes', [\App\Http\Controllers\Applications\InviteesController::class, 'codes'])->name('applications.invitees.codes');

Expand Down