mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 18:20:47 +01:00
Refactor into useLocalizedData
This commit is contained in:
@@ -5,10 +5,9 @@ const route = useRoute();
|
||||
const id = route.params.id as unknown;
|
||||
|
||||
const { client } = useClient();
|
||||
const { currentLocale } = useLocale();
|
||||
const getItems = async () => await client.items.listAsync({locale: currentLocale.value, version: "latest"});
|
||||
|
||||
const items = ref(await getItems());
|
||||
const { data: items } = await useLocalizedData(async (x) => await client.items.listAsync({locale: x, version: "latest"}));
|
||||
|
||||
const _default = new Item({});
|
||||
|
||||
const item = computed(() => items.value.find((x) => x.id == id) || _default);
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
const { client } = useClient();
|
||||
const { currentLocale } = useLocale();
|
||||
const getItems = async () => await client.items.listAsync({ locale: currentLocale.value, version: "latest"});
|
||||
|
||||
const items = ref(await getItems());
|
||||
watch(currentLocale, async () => {
|
||||
items.value = await getItems();
|
||||
});
|
||||
const { data: items } = await useLocalizedData(async (x) => await client.items.listAsync({ locale: x, version: "latest"}));
|
||||
|
||||
const { query, results } = useQueryable(items, (x) => x.id, (x) => x.name);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user