<x-app-layout><x-slot name="header"><h1 class="text-2xl font-bold">{{ $contribution->exists ? 'Edit contribution' : 'Record contribution' }}</h1></x-slot><div class="mx-auto max-w-3xl px-4 py-8"><form method="POST" action="{{ $contribution->exists ? route('contributions.update',$contribution) : route('contributions.store') }}" class="space-y-5 rounded-2xl border border-slate-200 bg-white p-6 dark:border-slate-800 dark:bg-slate-900">@csrf @if($contribution->exists)@method('PUT')@endif @php($input='mt-1 block w-full rounded-xl border-slate-300 bg-transparent dark:border-slate-700')<div class="grid gap-5 sm:grid-cols-2"><div><x-input-label value="Group"/><select class="{{ $input }}" name="ajo_group_id" required>@foreach($groups as $group)<option value="{{ $group->id }}" @selected(old('ajo_group_id',$contribution->ajo_group_id)===$group->id)>{{ $group->name }}</option>@endforeach</select></div><div><x-input-label value="Member"/><select class="{{ $input }}" name="member_id" required>@foreach($members as $member)<option value="{{ $member->id }}" @selected(old('member_id',$contribution->member_id)===$member->id)>{{ $member->full_name }} · {{ $member->member_number }}</option>@endforeach</select></div><div><x-input-label value="Amount due (NGN)"/><input class="{{ $input }}" type="number" step="0.01" name="amount_due" value="{{ old('amount_due',$contribution->exists?$contribution->amount_due/100:'') }}" required></div><div><x-input-label value="Amount paid (NGN)"/><input class="{{ $input }}" type="number" step="0.01" name="amount_paid" value="{{ old('amount_paid',$contribution->exists?$contribution->amount_paid/100:'') }}" required></div><div><x-input-label value="Due date"/><input class="{{ $input }}" type="date" name="due_date" value="{{ old('due_date',$contribution->due_date?->format('Y-m-d')) }}" required></div><div><x-input-label value="Payment date"/><input class="{{ $input }}" type="datetime-local" name="payment_date" value="{{ old('payment_date',$contribution->payment_date?->format('Y-m-d\TH:i')) }}"></div><div><x-input-label value="Payment method"/><select class="{{ $input }}" name="payment_method"><option value="">Select</option>@foreach(['cash','transfer','card','ussd','other'] as $method)<option value="{{ $method }}" @selected(old('payment_method',$contribution->payment_method)===$method)>{{ ucfirst($method) }}</option>@endforeach</select></div></div><div><x-input-label value="Notes"/><textarea class="{{ $input }}" name="notes">{{ old('notes',$contribution->notes) }}</textarea></div>@if($errors->any())<div class="rounded-xl bg-red-50 p-3 text-sm text-red-700">{{ $errors->first() }}</div>@endif<div class="flex justify-end gap-3"><a href="{{ route('contributions.index') }}" class="px-4 py-2">Cancel</a><button class="rounded-xl bg-emerald-600 px-5 py-2 font-semibold text-white">Save contribution</button></div></form></div></x-app-layout>
