itube-specs 0.0.277 → 0.0.279

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,20 @@
1
+ import { EAsyncData, ELanguage } from '../runtime';
2
+ import type { ICategoryCard } from '../types';
3
+
4
+ export const useFetchCategoriesGroupByLetter = (
5
+ apiMethod: (...args: any[]) => Promise<Record<string, Array<ICategoryCard>>>
6
+ ) => {
7
+ const { locale } = useI18n();
8
+ const lang = locale.value as ELanguage;
9
+
10
+ const { data, error, refresh, status } = useAsyncData<Record<string, Array<ICategoryCard>>>(
11
+ EAsyncData.GroupsCategoriesByLetter,
12
+ () => useApiFetcher<Record<string, Array<ICategoryCard>>>(
13
+ EAsyncData.GroupsCategoriesByLetter,
14
+ apiMethod,
15
+ lang,
16
+ )(),
17
+ );
18
+
19
+ return { data, error, refresh, status };
20
+ };
@@ -0,0 +1,20 @@
1
+ import { EAsyncData, ELanguage } from '../runtime';
2
+ import type { IChipsItem } from '../types';
3
+
4
+ export const useFetchFooterCategories = (
5
+ apiMethod: (...args: any[]) => Promise<IChipsItem[]>
6
+ ) => {
7
+ const { locale } = useI18n();
8
+ const lang = locale.value as ELanguage;
9
+
10
+ const { data, status, error } = useAsyncData<IChipsItem[]>(
11
+ EAsyncData.CategoriesTopRandomFooter,
12
+ () => useApiFetcher<IChipsItem[]>(
13
+ EAsyncData.CategoriesTopRandomFooter,
14
+ apiMethod,
15
+ lang,
16
+ )(),
17
+ );
18
+
19
+ return { data, status };
20
+ };
@@ -0,0 +1,20 @@
1
+ import { EAsyncData, ELanguage } from '../runtime';
2
+ import type { IGroupCategories } from '../types';
3
+
4
+ export const useFetchGroupsCategories = async (
5
+ apiMethod: (...args: any[]) => Promise<IGroupCategories[]>
6
+ ) => {
7
+ const { locale } = useI18n();
8
+ const lang = locale.value as ELanguage;
9
+
10
+ const { data, pending: status, error } = await useAsyncData<IGroupCategories[]>(
11
+ EAsyncData.GroupsCategoriesFilter,
12
+ () => useApiFetcher<IGroupCategories[]>(
13
+ EAsyncData.Categories,
14
+ apiMethod,
15
+ lang,
16
+ )(),
17
+ );
18
+
19
+ return { data, status, error };
20
+ };
@@ -3,6 +3,7 @@ import type { IModelCard, PaginatedResponse } from '../types';
3
3
 
4
4
  export const useFetchTopModels = (apiMethod: (...args: any[]) => Promise<PaginatedResponse<IModelCard>>, limit: number, eName: EAsyncData | string, cacheId: string) => {
5
5
  const { locale } = useI18n();
6
+ const lang = locale.value as ELanguage;
6
7
 
7
8
  const { data, status, refresh } = useAsyncData(
8
9
  String(eName + cacheId),
@@ -11,7 +12,7 @@ export const useFetchTopModels = (apiMethod: (...args: any[]) => Promise<Paginat
11
12
  apiMethod,
12
13
  limit,
13
14
  0,
14
- locale.value as ELanguage,
15
+ lang,
15
16
  cacheId
16
17
  )(),
17
18
  );
@@ -3,13 +3,14 @@ import type { IChipsItem } from '../types';
3
3
 
4
4
  export const useFetchTopRandomCategories = (apiMethod: (...args: any[]) => Promise<Array<IChipsItem>>, cacheId: string) => {
5
5
  const { locale } = useI18n();
6
+ const lang = locale.value as ELanguage;
6
7
 
7
8
  const { data: topRandomCategories, refresh, error } = useAsyncData<Array<IChipsItem>>(
8
9
  String(EAsyncData.CategoriesTopRandom + cacheId),
9
10
  () => useApiFetcher<Array<IChipsItem>>(
10
11
  EAsyncData.CategoriesTopRandom,
11
12
  apiMethod,
12
- locale.value as ELanguage,
13
+ lang,
13
14
  cacheId
14
15
  )(),
15
16
  );
@@ -0,0 +1,28 @@
1
+ import type { IFilterScheme, IGroupCategories } from '../types';
2
+ import { convertString } from '../runtime';
3
+
4
+ export const useFilterScheme = (groupsCategories: IGroupCategories[] | null) => {
5
+ const { t } = useI18n();
6
+
7
+ const getFilterSchemeCategories = (): IFilterScheme[] => {
8
+ return groupsCategories?.map((item) => ({
9
+ label: item.title,
10
+ name: item.name,
11
+ title: item.title,
12
+ placeholder: t('choose_category'),
13
+ items: item.categories?.map((subItem) => ({
14
+ title: convertString().toCapitalize(subItem.title),
15
+ value: subItem.name,
16
+ })),
17
+ })) || [];
18
+ };
19
+
20
+ const filterScheme = computed((): IFilterScheme[] => {
21
+ if (!groupsCategories) {
22
+ return [];
23
+ }
24
+ return getFilterSchemeCategories().filter(item => item?.items.length > 0);
25
+ });
26
+
27
+ return { filterScheme };
28
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.277",
4
+ "version": "0.0.279",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {