diff --git a/app/Enums/FlightNotificationType.php b/app/Enums/FlightNotificationType.php index 7f935ed..58e3cf1 100644 --- a/app/Enums/FlightNotificationType.php +++ b/app/Enums/FlightNotificationType.php @@ -28,7 +28,7 @@ enum FlightNotificationType: string { return match ($this) { self::Booked => "{$user->name} booked a new flight", - self::Logged => "{$user->name} logged a new flight", + self::Logged => "{$user->name} logged a historic flight", self::Cancelled => "{$user->name} cancelled a flight", self::Departed => "{$user->name} is taking off!", self::Arrived => "{$user->name} has landed!", diff --git a/app/Models/User.php b/app/Models/User.php index ebd7748..ef310c7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -153,7 +153,26 @@ class User extends Authenticatable implements MustVerifyEmail ->toJson(); }); - $collection = collect(json_decode($json)); + $dateFormat = auth()->user()?->resolved_settings['date_format'] ?? 'j M Y'; + $timeFormat = auth()->user()?->resolved_settings['time_format'] === '24hr' ? 'Hi' : 'g:iA'; + + $collection = collect(json_decode($json)) + ->map(function ($flight) use ($dateFormat, $timeFormat) { + $departure = Carbon::parse($flight->departure_date) + ->setTimezone($flight->departure_airport->timezone); + + $arrival = Carbon::parse($flight->arrival_date) + ->setTimezone($flight->arrival_airport->timezone); + + $flight->departure_date_display = $departure->format($dateFormat); + $flight->departure_time_display = $departure->format($timeFormat); + + $flight->arrival_date_display = $arrival->format($dateFormat); + $flight->arrival_time_display = $arrival->format($timeFormat); + + return $flight; + }); + $today = now('UTC')->toDateString(); return match ($filter) { diff --git a/app/Settings/SettingsRegistry.php b/app/Settings/SettingsRegistry.php index 413ba8a..f6120a1 100644 --- a/app/Settings/SettingsRegistry.php +++ b/app/Settings/SettingsRegistry.php @@ -13,24 +13,13 @@ class SettingsRegistry 'AI Generated Content' => 'Airline tail logos and liveries are AI generated with human cleanup. If you would rather not see any AI, then our blank aircraft templates are human created.', 'Account & Privacy' => 'Everything to do with your account.', 'Notifications' => 'What you want to hear about (or not!)', + 'Localization' => 'Units of measurement, date and time preferences.', ]; } public static function schema(): array { return [ - [ - 'key' => 'distance_unit', - 'type' => 'select', - 'label' => 'Distance Units', - 'category' => 'FlightsGoneBy Settings', - 'default' => 'km', - 'options' => [ - ['value' => 'km', 'label' => 'Kilometres (km)'], - ['value' => 'mi', 'label' => 'Miles (mi)'], - ['value' => 'nm', 'label' => 'Nautical miles (nm)'], - ], - ], [ 'category' => 'Account & Privacy', 'key' => 'profile_privacy', @@ -42,6 +31,42 @@ class SettingsRegistry ['value' => 'private', 'label' => 'Private Profile Viewable Only By You and Your Approved Followers'], ] ], + [ + 'key' => 'distance_unit', + 'type' => 'select', + 'label' => 'Distance Units', + 'category' => 'Localization', + 'default' => 'km', + 'options' => [ + ['value' => 'km', 'label' => 'Kilometres (km)'], + ['value' => 'mi', 'label' => 'Miles (mi)'], + ['value' => 'nm', 'label' => 'Nautical miles (nm)'], + ], + ], + [ + 'key' => 'time_format', + 'type' => 'select', + 'label' => 'Time Format', + 'category' => 'Localization', + 'default' => 'ampm', + 'options' => [ + ['value' => 'ampm', 'label' => 'AM/PM'], + ['value' => '24hr', 'label' => '24-Hour'], + ], + ], + [ + 'key' => 'date_format', + 'type' => 'select', + 'label' => 'Date Format', + 'category' => 'Localization', + 'default' => 'j M Y', + 'options' => [ + ['value' => 'j M Y', 'label' => '20 Feb 2015'], + ['value' => 'Y-m-d', 'label' => '2015-02-20'], + ['value' => 'd/m/Y', 'label' => '20/02/2015'], + ['value' => 'm/d/Y', 'label' => '02/20/2015'], + ], + ], [ 'key' => 'default_login_page', 'type' => 'select', diff --git a/resources/js/Components/FlightsGoneBy/DepartureBoardTableRow.vue b/resources/js/Components/FlightsGoneBy/DepartureBoardTableRow.vue index eacde6e..504f4c5 100644 --- a/resources/js/Components/FlightsGoneBy/DepartureBoardTableRow.vue +++ b/resources/js/Components/FlightsGoneBy/DepartureBoardTableRow.vue @@ -98,12 +98,12 @@ const showColumn = (column: string) => props.columnsToShow.includes(column)