@ludo.ninja/components 1.3.0 → 1.3.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "next dev -p 4000",
@@ -0,0 +1,2 @@
1
+ export * from './useGetUserFevoritesCreations';
2
+ export * from './useGetFavoriteGallaryCreations';
@@ -2,18 +2,7 @@ import { useEffect, useState } from 'react';
2
2
 
3
3
  import { useLazyQuery, useQuery } from '@apollo/client';
4
4
 
5
- import { hosts } from '@ludo.ninja/api';
6
- import { IAsset } from '@ludo.ninja/api/build/graphql_tools/__generated__/assetsHost/schema';
7
- import { ICollectionAsset } from '@ludo.ninja/api/build/graphql_tools/__generated__/collectionsHost/schema';
8
- import {
9
- FetchGalleryV2Document,
10
- IQueryFetchGalleryV2Args,
11
- } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
12
- import {
13
- FetchAssetsDocument,
14
- FetchCollectionsByIdsDocument,
15
- ICreation,
16
- } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
5
+ import { hosts, assetSchema, collectionsSchema, galleriesSchema, searchSchema } from '@ludo.ninja/api';
17
6
  import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
18
7
 
19
8
  import { useUiStore } from '@/store/ui';
@@ -47,7 +36,7 @@ const useGetFavoriteGallaryCreations = ({
47
36
  error: galleryError,
48
37
  loading: galleryLoading,
49
38
  refetch,
50
- } = useQuery(FetchGalleryV2Document, {
39
+ } = useQuery(galleriesSchema.FetchGalleryV2Document, {
51
40
  variables: { galleryId },
52
41
  context: {
53
42
  uri: hosts.galleriesHost,
@@ -67,19 +56,19 @@ const useGetFavoriteGallaryCreations = ({
67
56
  });
68
57
 
69
58
  const [fetchAssets, { loading: assetsLoading, error: assetsError }] =
70
- useLazyQuery(FetchAssetsDocument, {
59
+ useLazyQuery(searchSchema.FetchAssetsDocument, {
71
60
  context: { uri: hosts.searchHost },
72
61
  fetchPolicy: 'no-cache',
73
62
  onCompleted: ({ fetchAssets: data }) => {
74
63
  setAssets((prevAssets) => [
75
64
  ...(prevAssets || []),
76
65
  ...data.map(
77
- (asset: IAsset) =>
66
+ (asset: assetSchema.IAsset) =>
78
67
  new CreationEntity({
79
68
  ...asset,
80
69
  itemType: 'asset',
81
70
  itemId: asset.assetId,
82
- } as unknown as ICreation)
71
+ } as unknown as searchSchema.ICreation)
83
72
  ),
84
73
  ]);
85
74
  },
@@ -97,14 +86,14 @@ const useGetFavoriteGallaryCreations = ({
97
86
  const [
98
87
  fetchCollections,
99
88
  { loading: collectionsLoading, error: collectionsError },
100
- ] = useLazyQuery(FetchCollectionsByIdsDocument, {
89
+ ] = useLazyQuery(searchSchema.FetchCollectionsByIdsDocument, {
101
90
  context: { uri: hosts.searchHost },
102
91
  fetchPolicy: 'no-cache',
103
92
  onCompleted: ({ fetchCollectionsByIds: data }) => {
104
93
  setCollections((prevCollections) => [
105
94
  ...(prevCollections || []),
106
95
  ...data.map(
107
- (collection: ICollectionAsset) =>
96
+ (collection: collectionsSchema.ICollectionAsset) =>
108
97
  new CollectionCreationEntity(collection, 'collection')
109
98
  ),
110
99
  ]);
@@ -151,7 +140,7 @@ const useGetFavoriteGallaryCreations = ({
151
140
 
152
141
  async function refetchQueryGalleryCreation({
153
142
  galleryId,
154
- }: IQueryFetchGalleryV2Args) {
143
+ }: galleriesSchema.IQueryFetchGalleryV2Args) {
155
144
  await refetch({ galleryId });
156
145
  }
157
146
 
@@ -2,19 +2,8 @@ import { useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { useLazyQuery, useQuery } from '@apollo/client';
4
4
 
5
- import { hosts } from '@ludo.ninja/api';
6
- import { IAsset } from '@ludo.ninja/api/build/graphql_tools/__generated__/assetsHost/schema';
7
- import { ICollectionAsset } from '@ludo.ninja/api/build/graphql_tools/__generated__/collectionsHost/schema';
8
- import {
9
- FetchUserFavoritesV2Document,
10
- IGalleryV2,
11
- IQueryFetchUserFavoritesV2Args,
12
- } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
13
- import {
14
- FetchAssetsDocument,
15
- FetchCollectionsByIdsDocument,
16
- ICreation,
17
- } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
5
+ import { hosts, assetSchema, collectionsSchema, galleriesSchema, searchSchema } from '@ludo.ninja/api';
6
+
18
7
  import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
19
8
 
20
9
  import { useUiStore } from '@/store/ui';
@@ -29,7 +18,7 @@ const useGetUserFevoritesCreations = ({
29
18
  userId,
30
19
  pageSize,
31
20
  pageToken,
32
- }: IQueryFetchUserFavoritesV2Args) => {
21
+ }: galleriesSchema.IQueryFetchUserFavoritesV2Args) => {
33
22
  const [assets, setAsset] = useState<CreationEntity[] | null>(null);
34
23
  const [collections, setCollections] = useState<
35
24
  CollectionCreationEntity[] | null
@@ -48,7 +37,7 @@ const useGetUserFevoritesCreations = ({
48
37
  error: favoritesError,
49
38
  refetch,
50
39
  fetchMore,
51
- } = useQuery(FetchUserFavoritesV2Document, {
40
+ } = useQuery(galleriesSchema.FetchUserFavoritesV2Document, {
52
41
  context: { uri: hosts.galleriesHost }, //todo : update variables to object page
53
42
  variables: { pageSize, userId, pageToken },
54
43
  fetchPolicy: 'no-cache',
@@ -59,7 +48,7 @@ const useGetUserFevoritesCreations = ({
59
48
  nextPageToken.current = token || null;
60
49
 
61
50
  setFavorites(
62
- galleries.map((gallery: IGalleryV2) => new GalleryEntityV2(gallery))
51
+ galleries.map((gallery: galleriesSchema.IGalleryV2) => new GalleryEntityV2(gallery))
63
52
  );
64
53
  setLoading(false);
65
54
  },
@@ -75,18 +64,18 @@ const useGetUserFevoritesCreations = ({
75
64
  });
76
65
 
77
66
  const [fetchAssets, { loading: assetsLoading, error: assetsError }] =
78
- useLazyQuery(FetchAssetsDocument, {
67
+ useLazyQuery(searchSchema.FetchAssetsDocument, {
79
68
  context: { uri: hosts.searchHost },
80
69
  fetchPolicy: 'no-cache',
81
70
  onCompleted: ({ fetchAssets: data }) => {
82
71
  setAsset(
83
72
  data.map(
84
- (asset: IAsset) =>
73
+ (asset: assetSchema.IAsset) =>
85
74
  new CreationEntity({
86
75
  ...asset,
87
76
  itemType: 'asset',
88
77
  itemId: asset.assetId,
89
- } as unknown as ICreation)
78
+ } as unknown as searchSchema.ICreation)
90
79
  )
91
80
  );
92
81
  setLoading(false);
@@ -105,13 +94,13 @@ const useGetUserFevoritesCreations = ({
105
94
  const [
106
95
  fetchCollections,
107
96
  { loading: collectionsLoading, error: collectionsError },
108
- ] = useLazyQuery(FetchCollectionsByIdsDocument, {
97
+ ] = useLazyQuery(searchSchema.FetchCollectionsByIdsDocument, {
109
98
  context: { uri: hosts.searchHost },
110
99
  fetchPolicy: 'no-cache',
111
100
  onCompleted: ({ fetchCollectionsByIds: data }) => {
112
101
  setCollections(
113
102
  data.map(
114
- (collection: ICollectionAsset) =>
103
+ (collection: collectionsSchema.ICollectionAsset) =>
115
104
  new CollectionCreationEntity(collection)
116
105
  )
117
106
  );
@@ -1,3 +1,5 @@
1
1
  export * from './likes/useGetLikesAsset';
2
2
  export * from './apollo';
3
+ export * from './favorites';
4
+
3
5