Skip to content

Commit

Permalink
Merge branch 'main' into #156-add-sixt-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandraKozubal committed Nov 27, 2023
2 parents c015d92 + 40335dc commit db549ee
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 108 deletions.
2 changes: 1 addition & 1 deletion app/Http/Requests/CityOpinionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CityOpinionRequest extends FormRequest
public function rules(): array
{
return [
"rating" => ["required", "numeric", "max:5"],
"rating" => ["required", "numeric", "min:1", "max:5"],
"content" => ["required", "string", "max:250"],
"city_id" => ["required", "numeric", "exists:cities,id"],
];
Expand Down
1 change: 0 additions & 1 deletion app/Importers/BirdDataImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected function load(string $cityName, string $countryName, string $lat = "",
return strval($city->id);
}
$this->countryNotFound($cityName, $countryName);
$this->createImportInfoDetails("420", self::getProviderName());

return "";
}
Expand Down
26 changes: 13 additions & 13 deletions app/Importers/DataImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ public function translate(string $word, string $language): string

protected function countryNotFound(string $cityName, string $countryName): void
{
CityWithoutAssignedCountry::query()
->withTrashed()
->updateOrCreate(
[
"city_name" => $cityName,
"country_name" => $countryName,
],
[
"city_name" => $cityName,
"country_name" => $countryName,
],
);
$cityAttributes = [
"city_name" => $cityName,
"country_name" => $countryName,
];

$city = CityWithoutAssignedCountry::query()->withTrashed()->updateOrCreate(
$cityAttributes,
$cityAttributes,
);

if ($city->wasRecentlyCreated) {
$this->createImportInfoDetails("420", self::getProviderName());
}
}

protected function createProvider(int $cityId, string $providerName): void
Expand Down Expand Up @@ -149,7 +150,6 @@ protected function load(string $cityName, string $countryName, string $lat = "",
return strval($city->id);
}
$this->countryNotFound($cityName, $countryName);
$this->createImportInfoDetails("420", self::getProviderName());

return "";
}
Expand Down
1 change: 0 additions & 1 deletion app/Importers/LimeDataImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ protected function load(string $cityName, string $countryName, string $lat = "",
return strval($city->id);
}
$this->countryNotFound($cityName, $countryName);
$this->createImportInfoDetails("420", self::getProviderName());

return "";
}
Expand Down
1 change: 0 additions & 1 deletion app/Importers/SpinDataImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ protected function load(string $cityName, string $countryName, string $lat = "",
return strval($city->id);
}
$this->countryNotFound($cityName, $countryName);
$this->createImportInfoDetails("420", self::getProviderName());

return "";
}
Expand Down
31 changes: 21 additions & 10 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Don`t have an account?": "Nie masz konta?",
"Already have an account?": "Masz już konto?",
"Looking for an e‑scooter?": "Szukasz hulajnogi elektrycznej?",
"Try it out": "Wypróbuj teraz!",
"Try it out": "Wypróbuj teraz",
"Create account": "Stwórz konto",
"Log in to add to favorites.": "Zaloguj się, aby dodać do ulubionych.",
"Sorry we couldn't find any cities.": "Przepraszamy, ale nie mogliśmy znaleźć żadnych miast.",
Expand All @@ -29,6 +29,7 @@
"advert2": "Ta aplikacja pomoże Ci z planowaniem Twoich wakacji, lub podróży biznesowych.",
"Edit": "Edytuj",
"Delete": "Usuń",
"Cancel": "Anuluj",
"Add": "Dodaj",
"Create city": "Utwórz miasto",
"Create country": "Utwórz kraj",
Expand Down Expand Up @@ -82,19 +83,19 @@
"Country created successfully.": "Kraj utworzony pomyślnie.",
"City deleted successfully.": "Miasto usunięte pomyślnie.",
"Cities deleted successfully.": "Miasta usunięte pomyślnie.",
"Country deleted successfully": "Kraj usunięty pomyślnie.",
"There was an error!": "Wystąpił błąd!",
"There was an error creating the city!": "Wystąpił błąd podczas tworzenia miasta!",
"There was an error deleting the city!": "Wystąpił błąd podczas usuwania miasta!",
"There was an error deleting cities!": "Wystąpił błąd podczas usuwania miast!",
"Country deleted successfully.": "Kraj usunięty pomyślnie.",
"There was an error.": "Wystąpił błąd.",
"There was an error creating the city.": "Wystąpił błąd podczas tworzenia miasta.",
"There was an error deleting the city.": "Wystąpił błąd podczas usuwania miasta.",
"There was an error deleting cities.": "Wystąpił błąd podczas usuwania miast.",

"There was an error creating the country.": "Wystąpił błąd podczas tworzenia kraju.",
"There was an error adding alternative city name.": "Wystąpił błąd podczas dodawania alternatywnej nazwy miasta.",
"Alternative city name added successfully.": "Alternatywna nazwa miasta dodana pomyślnie.",
"Alternative city name deleted successfully.": "Alternatywna nazwa miasta usunięta pomyślnie.",
"City providers updated successfully.": "Dostawcy dostępni w mieście zaktualizowani pomyślnie.",
"Use `.` instead of `,`": "Użyj `.` zamiast `,`",
"Importers started!": "Importerzy uruchomieni!",
"Importers started.": "Importerzy uruchomieni.",
"running": "Uruchomiony",
"stopped": "Zatrzymany",
"finished": "Zakończony",
Expand Down Expand Up @@ -126,12 +127,22 @@
"Cities with no country assigned": "Miasta bez przypisanego kraju",
"Cities with no coordinates assigned": "Miasta bez przypisanych współrzędnych",
"Delete all cities with no country assigned": "Usuń wszystkie miasta bez przypisanego kraju",

"Opinion added successfully!": "Opinia dodana pomyślnie!",
"There was an error adding your opinion!": "Wystąpił błąd podczas dodawania opinii!",
"Opinion added successfully.": "Opinia dodana pomyślnie.",
"There was an error adding your opinion.": "Wystąpił błąd podczas dodawania opinii.",
"Opinion edited successfully.": "Opinia zaktualizowana pomyślnie.",
"There was an error editing your opinion.": "Wystąpił błąd podczas edytowania opinii.",
"There was an error removing your opinion.": "Wystąpił błąd podczas usuwania opinii.",
"Add opinion": "Dodaj opinię",
"Edit opinion": "Edytuj opinię",
"Send": "Wyślij",
"Users' opinions": "Opinie użytkowników",
"Delete that opinion?": "Usunąć tę opinię?",
"Opinion removed successfully!": "Opinia usunięta pomyślnie.",
"Delete city": "Usunąć miasto",
"Delete country": "Usunąć kraj",
"Delete that opinion": "Usunąć opinię",
"That opinion": "Ta opinia",
"This operation cannot be undone.": "Ta operacja nie może zostać cofnięta.",

"You have logged in successfully.": "Zalogowano pomyślnie.",
"You have logged out successfully.": "Wylogowano pomyślnie.",
Expand Down
1 change: 1 addition & 0 deletions lang/pl/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@
"password" => "hasło",
"latitude" => "szerokość geograficzna",
"longitude" => "długość geograficzna",
"content" => "treść",
],
];
8 changes: 4 additions & 4 deletions resources/js/Pages/Cities/Index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import City from '../../Shared/Components/City.vue'
import City from '@/Shared/Components/City.vue'
import { useForm, usePage, router } from '@inertiajs/vue3'
import { computed, ref, watch } from 'vue'
import AdminNavigation from '@/Shared/Layout/AdminNavigation.vue'
Expand Down Expand Up @@ -40,7 +40,7 @@ function storeCity() {
},
onError: (errors) => {
storeErrors.value = errors
toast.error(__('There was an error creating the city!'))
toast.error(__('There was an error creating the city.'))
},
})
}
Expand Down Expand Up @@ -111,7 +111,7 @@ function deleteCityWithoutAssignedCountry(city) {
toast.success(__('City deleted successfully.'))
},
onError: () => {
toast.error(__('There was an error deleting the city!'))
toast.error(__('There was an error deleting the city.'))
},
})
}
Expand All @@ -122,7 +122,7 @@ function deleteAllCitiesWithoutCountry() {
toast.success(__('Cities deleted successfully.'))
},
onError: () => {
toast.error(__('There was an error deleting cities!'))
toast.error(__('There was an error deleting cities.'))
},
})
}
Expand Down
36 changes: 7 additions & 29 deletions resources/js/Pages/City/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { __ } from '@/translate'
import { useForm, usePage } from '@inertiajs/vue3'
import ErrorMessage from '@/Shared/Components/ErrorMessage.vue'
import { useToast } from 'vue-toastification'
import Pagination from '../../Shared/Components/Pagination.vue'
import InfoPopup from '../../Shared/Components/InfoPopup.vue'
import Pagination from '@/Shared/Components/Pagination.vue'
import InfoPopup from '@/Shared/Components/InfoPopup.vue'
import Opinion from '@/Shared/Components/Opinion.vue'
const toast = useToast()
Expand Down Expand Up @@ -66,25 +67,17 @@ function createOpinion() {
opinionForm.post('/opinions', {
onSuccess: () => {
opinionForm.reset()
toast.success(__('Opinion added successfully!'))
toast.success(__('Opinion added successfully.'))
emptyRatingError.value = ''
},
onError: () => {
toast.error(__('There was an error adding your opinion!'))
toast.error(__('There was an error adding your opinion.'))
emptyRatingError.value = ''
},
})
}
}
const dateOptions = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}
</script>

<template>
Expand Down Expand Up @@ -128,7 +121,7 @@ const dateOptions = {
@click="setRating(index)"
/>
</div>
<textarea v-model.trim="opinionForm.content" required class="h-32 w-full rounded-lg border border-gray-300" />
<textarea v-model.trim="opinionForm.content" required class="h-32 w-full rounded-lg border border-gray-300" @keydown.enter.prevent="createOpinion" />

<div class="mt-1 flex flex-col">
<ErrorMessage :message="emptyRatingError" />
Expand All @@ -149,22 +142,7 @@ const dateOptions = {
{{ __(`Users' opinions`) }}
</p>
<div v-for="opinion in props.cityOpinions.data" :key="opinion.id" class="mb-3 flex flex-col rounded-lg border border-gray-300 p-2">
<div class="flex items-center">
<p class="mr-1 text-xs font-medium text-blumilk-500">
{{ opinion.user.name }}
</p>
<StarIcon v-for="index in maxRating"
:key="index"
:class="{ 'fill-yellow-400': index <= opinion.rating }" class="h-4 w-4 text-yellow-400"
/>
</div>
<p class="mr-1 text-xs font-light text-blumilk-500">
{{ new Date(opinion.updated_at).toLocaleString("pl-PL", dateOptions) }}
</p>

<div class="mt-1 text-sm text-gray-700">
{{ opinion.content }}
</div>
<Opinion :opinion="opinion" :city-id="props.city.id" />
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Countries/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function storeCountry() {
toast.success(__('Country created successfully.'))
},
onError: () => {
toast.error(__('There was an error creating the country!'))
toast.error(__('There was an error creating the country.'))
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Dashboard/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const chartOptions = {
<div class="mt-8 flex w-full flex-col lg:mt-6 lg:flex-row lg:justify-end">
<div class="w-full px-3 lg:w-1/2">
<h1 class="mx-2 mb-2 text-2xl font-bold text-gray-700">
{{ __('Cities by provider') }}
{{ __('Number of cities where the provider is available') }}
</h1>

<div class="flex flex-wrap">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Importers/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defineProps({
function runImporters() {
router.post('/run-importers', [])
toast.success(__('Importers started!'))
toast.success(__('Importers started.'))
}
</script>

Expand Down
10 changes: 5 additions & 5 deletions resources/js/Shared/Components/City.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ function toggleProvidersForm() {
</div>
<div class="hidden items-center lg:flex">
<div class="items-top flex h-1/2 flex-wrap items-center">
<div v-for="provider in filteredSelectedCityProviders.slice(0, 4)" :key="provider.name"
<div v-for="provider in filteredSelectedCityProviders.slice(0, 3)" :key="provider.name"
:style="{ 'background-color': selectedCityProviders.includes(provider.name) ? provider.color : '' }"
:class="selectedCityProviders.includes(provider.name) ? 'border-zinc-600 drop-shadow-lg' : 'hidden'"
class="m-1 flex h-5 w-fit items-center justify-center rounded border border-zinc-300 bg-zinc-300 p-1 "
class="m-1 mr-5 flex h-5 w-fit scale-[1.75] items-center justify-center rounded bg-zinc-300 p-1"
>
<img class="w-5" :src="'/providers/' + provider.name.toLowerCase() + '.png'" alt="">
<img class="w-5" :src="'/providers/' + provider.name.toLowerCase() + '.png'" :title="provider.name" alt="">
</div>

<div v-if="selectedCityProviders.length > 4"
<div v-if="selectedCityProviders.length > 3"
class="m-1 flex h-5 w-fit items-center justify-center rounded border border-zinc-300 bg-zinc-300 p-1"
>
<div class="flex h-5 w-5 items-center justify-center text-xs text-gray-500">
+{{ selectedCityProviders.length - 4 }}
+{{ selectedCityProviders.length - 3 }}
</div>
</div>
<div v-else-if="selectedCityProviders.length === 0" class="m-1 flex h-5 w-fit items-center justify-center p-1">
Expand Down
Loading

0 comments on commit db549ee

Please sign in to comment.