itube-specs 0.0.256 → 0.0.257

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import type { ICountries } from '../types';
2
+ import { EAsyncData, ELanguage } from '../runtime';
3
+
4
+ export const useFetchDictionariesCountries = (
5
+ apiMethod: (...args: any[]) => Promise<ICountries>
6
+ ) => {
7
+ const lang = useI18n().locale.value as ELanguage;
8
+
9
+ const { data, status, error } = useAsyncData<ICountries>(
10
+ EAsyncData.Countries,
11
+ () => useApiFetcher<ICountries>(
12
+ EAsyncData.Countries,
13
+ apiMethod,
14
+ lang,
15
+ )(),
16
+ );
17
+
18
+ return { countriesData: data, status, error };
19
+ };
@@ -0,0 +1,19 @@
1
+ import type { IGenders } from '../types';
2
+ import { EAsyncData, ELanguage } from '../runtime';
3
+
4
+ export const useFetchDictionariesGenders = (
5
+ apiMethod: (...args: any[]) => Promise<IGenders>
6
+ ) => {
7
+ const lang = useI18n().locale.value as ELanguage;
8
+
9
+ const { data, status, error } = useAsyncData<IGenders>(
10
+ EAsyncData.Genders,
11
+ () => useApiFetcher<IGenders>(
12
+ EAsyncData.Genders,
13
+ apiMethod,
14
+ lang,
15
+ )(),
16
+ );
17
+
18
+ return { gendersData: data, status, error };
19
+ };
@@ -0,0 +1,26 @@
1
+ import { convertString, EAsyncData, ELanguage } from '../runtime';
2
+ import type { IModelCard, PaginatedResponse } from '../types';
3
+ import { useRoute } from 'vue-router';
4
+
5
+ export const useFetchModelsByPhrases = async (
6
+ apiMethod: (...args: any[]) => Promise<PaginatedResponse<IModelCard>>
7
+ ) => {
8
+ const route = useRoute();
9
+ const { locale } = useI18n();
10
+ const lang = locale.value as ELanguage;
11
+
12
+ const { data, status, error } = await useAsyncData<PaginatedResponse<IModelCard>>(
13
+ EAsyncData.ModelsByPhrases,
14
+ () => useApiFetcher<PaginatedResponse<IModelCard>>(
15
+ EAsyncData.ModelsByPhrases,
16
+ apiMethod,
17
+ {
18
+ 'per-page': 48,
19
+ },
20
+ lang,
21
+ convertString().fromSlug(String(useRoute().params.slug)),
22
+ )(),
23
+ );
24
+
25
+ return { data, status, error };
26
+ };
@@ -0,0 +1,29 @@
1
+ import { EAsyncData, ELanguage } from '../runtime';
2
+ import type { IModelCard, PaginatedResponse } from '../types';
3
+
4
+ export const useFetchRelatedModels = (
5
+ apiMethod: (...args: any[]) => Promise<PaginatedResponse<IModelCard>>,
6
+ limit: number,
7
+ cacheId: string
8
+ ) => {
9
+ const { locale } = useI18n();
10
+
11
+ const { data, status, refresh } = useAsyncData<PaginatedResponse<IModelCard>>(
12
+ `${EAsyncData.TopModelsMore} ${cacheId}`,
13
+ () => useApiFetcher<PaginatedResponse<IModelCard>>(
14
+ EAsyncData.TopModelsMore,
15
+ apiMethod,
16
+ useSlug().value,
17
+ limit,
18
+ 0,
19
+ locale.value as ELanguage,
20
+ cacheId
21
+ )(),
22
+ );
23
+
24
+ return {
25
+ data,
26
+ refresh,
27
+ status,
28
+ };
29
+ };
@@ -0,0 +1,39 @@
1
+ import { ELanguage, EAsyncData, getSelectedQuery } from '../runtime';
2
+ import { sortModels } from '../lib';
3
+ import { useRoute } from 'vue-router';
4
+ import type { IModelCard, PaginatedResponse } from '../types';
5
+
6
+ export const useFetchModels = async (
7
+ apiMethod: (...args: any[]) => Promise<PaginatedResponse<IModelCard>>
8
+ ) => {
9
+ const route = useRoute();
10
+ const lang = useI18n().locale.value as ELanguage;
11
+
12
+ const filters = computed(() => Object.entries(route.query)
13
+ .filter(([key]) => key.startsWith('filter_'))
14
+ .map(([key, value]) => ({
15
+ name: key.replace(/^filter_/, ''),
16
+ value: Array.isArray(value) ? value[ 0 ] : (value as string),
17
+ })));
18
+
19
+ const { data, status, refresh } = await useAsyncData<PaginatedResponse<IModelCard>>(
20
+ () => `${EAsyncData.Models}-${route.params.slug || ''}`,
21
+ () => useApiFetcher<PaginatedResponse<IModelCard>>(
22
+ EAsyncData.Models,
23
+ apiMethod,
24
+ lang,
25
+ {
26
+ page: Number(route.query.page) || 1,
27
+ 'per-page': 48,
28
+ },
29
+ getSelectedQuery(route, sortModels) || '-popularity',
30
+ filters.value,
31
+ route.params['slug'] ? useSlug().value : null,
32
+ )(),
33
+ {
34
+ watch: [() => route.params, () => route.query],
35
+ }
36
+ );
37
+
38
+ return { data, status, refresh };
39
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.256",
4
+ "version": "0.0.257",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {