Skip to content

Commit

Permalink
🚸 Add errors on linerun page (#2683)
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin authored Jun 11, 2024
1 parent 5c77391 commit c4efa42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/Http/Controllers/API/v1/TransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public function getTrip(Request $request): JsonResponse {
return $this->sendResponse(data: new TripResource($trip));
} catch (StationNotOnTripException) {
return $this->sendError(__('controller.transport.not-in-stopovers', [], 'en'), 400);
} catch (HafasException) {
return $this->sendError(__('messages.exception.hafas.502', [], 'en'), 503);
}
}

Expand Down
18 changes: 17 additions & 1 deletion resources/vue/components/CheckinLineRun.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import {DateTime} from "luxon";
import {trans} from "laravel-vue-i18n";
import Spinner from "./Spinner.vue";
export default {
Expand Down Expand Up @@ -34,20 +35,29 @@ export default {
return {
lineRun: [],
loading: false,
error: false,
errorMessage: ""
};
},
methods: {
handleSetDestination(selected) {
this.$emit('update:destination', selected);
},
getLineRun() {
this.error = false;
this.loading = true;
const params = new URLSearchParams({
hafasTripId: this.$props.selectedTrain.tripId,
lineName: this.$props.selectedTrain.line.name,
start: this.$props.selectedTrain.stop.id
});
fetch(`/api/v1/trains/trip?${params.toString()}`).then((response) => {
this.loading = false;
if (!response.ok) {
this.error = true;
this.errorMessage = trans("messages.exception.hafas.502");
}
response.json().then((result) => {
this.lineRun = result.data;
let remove = true;
Expand All @@ -59,11 +69,13 @@ export default {
}
return !remove;
});
this.loading = false;
if (this.$props.fastCheckinIbnr) {
this.fastCheckin();
}
});
}).catch(() => {
this.error = true;
this.errorMessage = trans("messages.exception.hafas.502");
});
},
fastCheckin() {
Expand Down Expand Up @@ -92,6 +104,10 @@ export default {
</script>

<template>

<div v-if="error" class="text-trwl mx-auto p-2">
<p>{{ this.errorMessage }}</p>
</div>
<Spinner v-if="loading" />
<ul class="timeline" v-else>
<li v-for="item in lineRun.stopovers" :key="item" @click.prevent="handleSetDestination(item)">
Expand Down

0 comments on commit c4efa42

Please sign in to comment.