Skip to content

Commit

Permalink
Merge pull request #1311 from openworld-community/release/2024-08-18
Browse files Browse the repository at this point in the history
Release/2024 08 18
  • Loading branch information
il12 authored Aug 22, 2024
2 parents d31fde4 + 922b698 commit 0b65945
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- mongo
environment:
- MODE=dev
- FRONTEND_URL=https://localhost
- FRONTEND_URL=http://127.0.0.1
- MONGO_URI=mongodb://mongo:27017/dev
- VITE_GOOGLE_OAUTH_KEY=879620398496-7rtabia15rqav109uiq9olpcsbgk0562.apps.googleusercontent.com
ports:
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/event/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ const onSubmit = handleSubmit(

<div class="event-form__fields-wrapper">
<div class="event-form__fields">
<EventFormLocation />
<EventFormLocation
:cities-options="
locationStore.getCitiesByCountry(values['location']['country'])
"
/>

<EventFormMaininfo />
<EventFormDate />
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/event/FormLocation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ const addressField = useField<string>(() => 'location.address');
:error="cityField.errorMessage.value"
:touched="cityField.meta.touched"
>
<LibrarySelect
<CommonUiBaseSelect
v-model="cityField.value.value"
name="city"
:disabled="!countryField.value.value || isOnlineField.value.value"
:error="cityField.meta.touched && Boolean(cityField.errorMessage.value)"
:placeholder="$t('global.city')"
:options="citiesOptions"
:list="citiesOptions"
:required="!isOnlineField.value.value"
/>
</CommonFormField>
Expand Down
27 changes: 17 additions & 10 deletions frontend/stores/location.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ export const useLocationStore = defineStore('location', {
// return state._countries;

// Сейчас добавляем страны вручную
const countries = ['Montenegro', 'Serbia'];

state._countries = new Set(countries);
const { $i18n } = useNuxtApp();
const countriesEng = ['Montenegro', 'Serbia'];
const countriesRus = ['Черногория', 'Сербия'];
state._countries =
$i18n.locale.value !== 'en' ? new Set(countriesRus) : new Set(countriesEng);
return state._countries;
},
cities(state): LocationStore['_citiesByCountry'] {
return state._citiesByCountry;
},
currencies(state): LocationStore['_currencies'] {
state._currencies = ['USD', 'EUR', 'RSD', 'BTC', 'USDT', 'USDC', 'ETH'];
return state._currencies;
Expand Down Expand Up @@ -142,20 +147,22 @@ export const useLocationStore = defineStore('location', {
// forces Nuxt to await function calls if there are multiple of them(avoid duplication of requests)
await new Promise((r) => r(0));

const { $locationStoreForage } = useNuxtApp();
const localCities: City[] | null = await $locationStoreForage.getItem(country);
if (localCities) {
this._citiesByCountry.set(country, localCities);
return;
}
// const { $locationStoreForage } = useNuxtApp();

// const localCities: City[] | null = await $locationStoreForage.getItem(country);
// if (localCities) {
// this._citiesByCountry.set(country, localCities);
// return;
// }

const { data } = await apiRouter.location.country.getCities.useQuery({
data: { country }
});
if (!data.value) return;
console.log('CITIES', data.value);
this._citiesByCountry.set(country, data.value);
// data.value is Proxy which can't copied to storage directly - spread operator converts back to native object
$locationStoreForage.setItem(country, [...data.value]);
// $locationStoreForage.setItem(country, [...data.value]);
})();

return this._citiesByCountry.get(country) ?? [];
Expand Down
4 changes: 2 additions & 2 deletions frontend/utils/prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export const formatPrice = (price: EventPrice) => {

//TODO: выбирает валюту в зависимости от страны (пока валюты прибиты на фронте)
export const getCurrencyByCountry = (country: string) => {
if (country === 'Montenegro') return 'EUR';
if (country === 'Serbia') return 'RSD';
if (country === 'Montenegro' || country === 'Черногория') return 'EUR';
if (country === 'Serbia' || country === 'Сербия') return 'RSD';

return 'USD';
};
Expand Down

0 comments on commit 0b65945

Please sign in to comment.