admin felület fejlesztése garázs, előfizeztési csomagok
This commit is contained in:
73
frontend_admin/.nuxt/dist/server/_nuxt/region-0mvXqaMM.js
vendored
Normal file
73
frontend_admin/.nuxt/dist/server/_nuxt/region-0mvXqaMM.js
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, computed } from "vue";
|
||||
const useRegionStore = defineStore("region", () => {
|
||||
const regions = ref([]);
|
||||
const activeRegion = ref(null);
|
||||
const isLoading = ref(false);
|
||||
const error = ref(null);
|
||||
const defaultRegion = computed(() => {
|
||||
return regions.value.find((r) => r.country_code === "DEFAULT") || null;
|
||||
});
|
||||
const regionMap = computed(() => {
|
||||
const map = /* @__PURE__ */ new Map();
|
||||
for (const r of regions.value) {
|
||||
map.set(r.country_code, r);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
const activeCurrency = computed(() => {
|
||||
return activeRegion.value?.currency || defaultRegion.value?.currency || "EUR";
|
||||
});
|
||||
const activeLocale = computed(() => {
|
||||
return activeRegion.value?.locale_code || defaultRegion.value?.locale_code || "en-EU";
|
||||
});
|
||||
const activeVatRate = computed(() => {
|
||||
return activeRegion.value?.default_vat_rate ?? defaultRegion.value?.default_vat_rate ?? 0;
|
||||
});
|
||||
const activeTimezone = computed(() => {
|
||||
return activeRegion.value?.timezone || defaultRegion.value?.timezone || "Europe/Brussels";
|
||||
});
|
||||
async function fetchRegions() {
|
||||
if (regions.value.length > 0) return;
|
||||
isLoading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
const data = await $fetch("/api/v1/system/regions");
|
||||
regions.value = data || [];
|
||||
} catch (err) {
|
||||
error.value = err?.data?.detail || err?.message || "Failed to load regions";
|
||||
console.error("[RegionStore] Fetch error:", err);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
function setActiveRegion(countryCode) {
|
||||
const found = regions.value.find((r) => r.country_code === countryCode);
|
||||
activeRegion.value = found || defaultRegion.value;
|
||||
}
|
||||
function getRegion(countryCode) {
|
||||
return regionMap.value.get(countryCode);
|
||||
}
|
||||
return {
|
||||
// State
|
||||
regions,
|
||||
activeRegion,
|
||||
isLoading,
|
||||
error,
|
||||
// Getters
|
||||
defaultRegion,
|
||||
regionMap,
|
||||
activeCurrency,
|
||||
activeLocale,
|
||||
activeVatRate,
|
||||
activeTimezone,
|
||||
// Actions
|
||||
fetchRegions,
|
||||
setActiveRegion,
|
||||
getRegion
|
||||
};
|
||||
});
|
||||
export {
|
||||
useRegionStore as u
|
||||
};
|
||||
//# sourceMappingURL=region-0mvXqaMM.js.map
|
||||
Reference in New Issue
Block a user