Show all schools on the choose school form. Warn not to create duplicate.

This commit is contained in:
Matt Young 2024-08-05 11:36:58 -05:00
parent 11236a253f
commit 9daa34dd26
2 changed files with 61 additions and 41 deletions

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\School;
use App\Services\Invoice\InvoiceDataService; use App\Services\Invoice\InvoiceDataService;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -35,8 +36,9 @@ class DashboardController extends Controller
if (count($possibilities) < 1) { if (count($possibilities) < 1) {
return view('schools.create'); return view('schools.create');
} }
$schools = School::orderBy('name')->get();
return view('dashboard.select_school', ['possibilities' => $possibilities]); return view('dashboard.select_school', ['possibilities' => $possibilities, 'schools' => $schools]);
} }
public function my_invoice() public function my_invoice()
@ -46,6 +48,7 @@ class DashboardController extends Controller
} }
$invoiceData = $this->invoiceService->allData(Auth::user()->school_id); $invoiceData = $this->invoiceService->allData(Auth::user()->school_id);
$school = Auth::user()->school; $school = Auth::user()->school;
return view('dashboard.invoice', compact('school', 'invoiceData')); return view('dashboard.invoice', compact('school', 'invoiceData'));
} }
} }

View File

@ -1,48 +1,65 @@
@php use Illuminate\Support\Facades\Auth; @endphp @php use Illuminate\Support\Facades\Auth; @endphp
@php $school = Auth::user()->school; @endphp @php $school = Auth::user()->school; @endphp
<x-layout.app> <x-layout.app>
<x-slot:page_title>Choose School</x-slot:page_title> <x-slot:page_title>Choose School</x-slot:page_title>
<div class="grid grid-cols-4">
{{-- <x-card.card class="mx-auto max-w-xl">--}}
<div class="mx-auto max-w-lg">
<x-card.card> <x-card.card>
<x-card.heading class=""> <x-card.heading>Existing Schools</x-card.heading>
Choose your school <ul class="ml-6 mb-3">
<x-slot:subheading> @foreach($schools as $school)
Based on your email address, one of these schools may be yours <li>{{ $school->name }}</li>
</x-slot:subheading>
</x-card.heading>
<x-card.list.body>
@foreach($possibilities as $possibility)
@php $school = $possibility->school; @endphp
<form method="POST" action="/users/{{ Auth::user()->id }}/set_school">
@csrf
@method('PATCH')
<input type="hidden" name="school_id" id="school_id" value="{{ $school->id }}">
<x-card.list.row right_link_button_type="button">
<x-card.list.row-image
src="{{ $school->initialLetterImageURL() }}"
alt=""/>
<x-card.list.row-text-subtext>
{{ $school->name }}
<x-slot:subtext>{{ $school->city }}, {{ $school->state }}</x-slot:subtext>
</x-card.list.row-text-subtext>
<x-slot:right_link_button
onclick="return confirm('Please confirm you are a director at {{ $school->name }}');"
>Choose</x-slot:right_link_button>
</x-card.list.row>
</form>
@endforeach @endforeach
<x-card.list.row> </ul>
<x-card.list.row-text-subtext>
Create new school
<x-slot:subtext>My school isn't listed</x-slot:subtext>
</x-card.list.row-text-subtext>
<x-slot:right_link_button href="/schools/create">Create new school</x-slot:right_link_button>
</x-card.list.row>
</x-card.list.body>
</x-card.card> </x-card.card>
<div class="mx-auto max-w-lg col-span-3">
<x-card.card>
<x-card.heading class="">
Choose your school
<x-slot:subheading>
Based on your email address, one of these schools may be yours
</x-slot:subheading>
</x-card.heading>
<x-card.list.body>
@foreach($possibilities as $possibility)
@php $school = $possibility->school; @endphp
<form method="POST" action="/users/{{ Auth::user()->id }}/set_school">
@csrf
@method('PATCH')
<input type="hidden" name="school_id" id="school_id" value="{{ $school->id }}">
<x-card.list.row right_link_button_type="button">
<x-card.list.row-image
src="{{ $school->initialLetterImageURL() }}"
alt=""/>
<x-card.list.row-text-subtext>
{{ $school->name }}
<x-slot:subtext>{{ $school->city }}, {{ $school->state }}</x-slot:subtext>
</x-card.list.row-text-subtext>
<x-slot:right_link_button
onclick="return confirm('Please confirm you are a director at {{ $school->name }}');"
>Choose</x-slot:right_link_button>
</x-card.list.row>
</form>
@endforeach
<x-card.list.row>
<x-card.list.row-text-subtext>
Create new school
<x-slot:subtext>
My school isn't listed<br>
</x-slot:subtext>
</x-card.list.row-text-subtext>
<x-slot:right_link_button href="/schools/create">Create new school</x-slot:right_link_button>
</x-card.list.row>
<x-card.list.row class="text-sm">
Please don't duplicate a school that exists in the system. If your school is listed to the left, but you don't have the option
to add it, please contact {{ auditionSetting('organizerName') }} and ask them to add you to that school.
</x-card.list.row>
</x-card.list.body>
</x-card.card>
</div>
</div> </div>
</x-layout.app> </x-layout.app>