Save user flights
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\UserFlight;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class FlightImportController extends Controller
|
||||
{
|
||||
@@ -168,7 +169,7 @@ class FlightImportController extends Controller
|
||||
$validated = $request->validate([
|
||||
'date' => 'required|date',
|
||||
'imported_flight_id' => 'required|exists:imported_flights,id',
|
||||
'flight_number' => 'required|string',
|
||||
'flight_number' => 'nullable|string',
|
||||
'from_id' => 'required|integer|exists:airports,id',
|
||||
'to_id' => 'required|integer|exists:airports,id',
|
||||
'dep_time' => 'nullable|date_format:H:i',
|
||||
@@ -238,15 +239,14 @@ class FlightImportController extends Controller
|
||||
'aircraft_id' => $validated['aircraft_id'] ?? null,
|
||||
'aircraft_registration' => $validated['registration'] ?? null,
|
||||
'seat_number' => $validated['seat_number'] ?? null,
|
||||
'seat_type_id' => $validated['seat_type_id'] ?? null,
|
||||
'flight_class_id' => $validated['flight_class_id'] ?? null,
|
||||
'flight_reason_id' => $validated['flight_reason_id'] ?? null,
|
||||
'seat_type_id' => $validated['seat_type_id'] ?? 0,
|
||||
'flight_class_id' => $validated['flight_class_id'] ?? 0,
|
||||
'flight_reason_id' => $validated['flight_reason_id'] ?? 0,
|
||||
'note' => $validated['note'] ?? null,
|
||||
]);
|
||||
|
||||
ImportedFlight::destroy($validated['imported_flight_id']);
|
||||
|
||||
return redirect()->route('reconcile');
|
||||
return to_route('reconcile');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class SearchController extends Controller
|
||||
->orWhere('IATA_code', 'ilike', "%{$q}%")
|
||||
->orWhere('ICAO_code', 'ilike', "%{$q}%");
|
||||
})
|
||||
->limit(15)
|
||||
->limit(50)
|
||||
->get(['id', 'name', 'IATA_code', 'ICAO_code', 'logo'])
|
||||
->map(fn($a) => [
|
||||
'value' => $a->id,
|
||||
@@ -33,7 +33,7 @@ class SearchController extends Controller
|
||||
|
||||
return Aircraft::where('designator', 'ilike', "%{$q}%")
|
||||
->orWhereRaw("CONCAT(manufacturer_code, ' ', model_full_name) ilike ?", ["%{$q}%"])
|
||||
->limit(15)
|
||||
->limit(200)
|
||||
->get(['id', 'manufacturer_code', 'model_full_name', 'designator'])
|
||||
->map(fn($a) => [
|
||||
'value' => $a->id,
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import {Link} from "@inertiajs/vue3";
|
||||
import MainHeader from "@/Components/FlightsGoneBy/MainHeader.vue";
|
||||
import MainFooter from "@/Components/FlightsGoneBy/MainFooter.vue";
|
||||
import Radar from "@/Components/FlightsGoneBy/Radar.vue";
|
||||
import { usePage } from "@inertiajs/vue3";
|
||||
const page = usePage();
|
||||
import { usePage, router } from "@inertiajs/vue3";
|
||||
import { ref } from "vue";
|
||||
|
||||
const page = usePage();
|
||||
const transitionKey = ref(0);
|
||||
|
||||
router.on('success', () => {
|
||||
transitionKey.value++;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -13,7 +18,7 @@ const page = usePage();
|
||||
<div class="layoutContainer">
|
||||
<MainHeader />
|
||||
<Transition name="fade" mode="out-in">
|
||||
<main id="pageContainer" :key="page.url" >
|
||||
<main id="pageContainer" :key="transitionKey">
|
||||
<slot />
|
||||
</main>
|
||||
</Transition>
|
||||
|
||||
@@ -17,7 +17,7 @@ const selectedFile = ref<File | null>(null);
|
||||
|
||||
const blurb = computed(() => {
|
||||
if (status.value === 'success') {
|
||||
return `Successfully imported ${importedCount} flight${importedCount.value !== 1 ? 's' : ''}. You will just need to reconcile some mismatched airlines and airports.`;
|
||||
return `Successfully imported ${importedCount.value} flight${importedCount.value !== 1 ? 's' : ''}. You will just need to reconcile some mismatched airlines and airports.`;
|
||||
}
|
||||
return 'Import a CSV export from MyFlightRadar24. You will then be guided to reconcile any data mismatches.';
|
||||
});
|
||||
@@ -64,45 +64,49 @@ async function onFileChange(e: Event) {
|
||||
|
||||
<template>
|
||||
<Head title="Import" />
|
||||
<GlassBox title="Import Your Flights">
|
||||
<p v-if="status !== 'success'">
|
||||
Import a CSV export from MyFlightRadar24. You will then be guided
|
||||
to reconcile any data mismatches.
|
||||
</p>
|
||||
<p v-else-if="status === 'success'" type="success" >
|
||||
Successfully imported {{ importedCount }} flight{{ importedCount !== 1 ? 's' : '' }}. You will just need to reconcile some mismatched airlines and airports.
|
||||
</p>
|
||||
<GlassBox title="Import Your Flights" :blurb="blurb">
|
||||
<v-row no-gutters class="ga-3">
|
||||
|
||||
<!-- File input / loading / success -->
|
||||
<v-col cols="12">
|
||||
<v-file-input
|
||||
style="flex:0;width:100%"
|
||||
prepend-icon=""
|
||||
v-if="status !== 'uploading' && status !== 'success'"
|
||||
prepend-icon=""
|
||||
label="Select CSV File"
|
||||
accept=".csv"
|
||||
@change="onFileChange"
|
||||
ref="fileInput"
|
||||
v-model="selectedFile"
|
||||
hide-details
|
||||
/>
|
||||
|
||||
<div v-else-if="status === 'uploading'" class="d-flex align-center ga-3 mt-2">
|
||||
<div
|
||||
v-else-if="status === 'uploading'"
|
||||
class="d-flex flex-column align-center justify-center ga-3 py-4"
|
||||
>
|
||||
<v-progress-circular indeterminate color="primary" />
|
||||
<span>Importing your flights…</span>
|
||||
</div>
|
||||
|
||||
<v-alert closable v-if="status === 'error'" type="error">
|
||||
<v-btn
|
||||
v-else-if="status === 'success'"
|
||||
:href="route('reconcile')"
|
||||
size="x-large"
|
||||
block
|
||||
>
|
||||
Reconcile Your Data
|
||||
</v-btn>
|
||||
</v-col>
|
||||
|
||||
<!-- Errors (independent of the above) -->
|
||||
<v-col v-if="status === 'error'" cols="12">
|
||||
<v-alert closable type="error">
|
||||
<div v-for="(err, i) in errors" :key="i">{{ err }}</div>
|
||||
</v-alert>
|
||||
</v-col>
|
||||
|
||||
<v-btn :href="route('reconcile')" v-if="status === 'success'" size="x-large" block >Reconcile Your Data</v-btn>
|
||||
</v-row>
|
||||
</GlassBox>
|
||||
</template>
|
||||
<style scoped>
|
||||
h2{
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
p{
|
||||
text-align: center;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -195,11 +195,17 @@ function submit() {
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Submit -->
|
||||
<v-row>
|
||||
<v-col cols="12" class="d-flex justify-end">
|
||||
<v-btn block size="large" :loading="form.processing" :disabled="form.processing" @click="submit">
|
||||
Save Flight
|
||||
<v-btn
|
||||
block
|
||||
size="large"
|
||||
:loading="submitForm.processing"
|
||||
:disabled="submitForm.processing"
|
||||
@click="submit"
|
||||
>
|
||||
<v-progress-circular v-if="submitForm.processing" indeterminate size="24" />
|
||||
<span v-else>Save Flight</span>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
+1
-4
@@ -34,12 +34,9 @@ Route::domain(config('app.domain'))->group(
|
||||
Route::get('/reconcile', function () {
|
||||
$flight = new FlightImportController()->reconcile(request());
|
||||
|
||||
if (!$flight) {
|
||||
return redirect('/import/fr24');
|
||||
}
|
||||
|
||||
return Inertia::render('ReconcileFlight', [
|
||||
'flight' => $flight,
|
||||
'key' => $flight['imported_flight_id'],
|
||||
]);
|
||||
})->name('reconcile');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user