@creopse/react 0.0.22 → 0.0.25

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.
@@ -6791,6 +6791,9 @@ var ProfileType;
6791
6791
  var ResponseErrorCode;
6792
6792
  (function(ResponseErrorCode2) {
6793
6793
  ResponseErrorCode2["FORM_INVALID_DATA"] = "form/invalid_data";
6794
+ ResponseErrorCode2["REQUEST_PARAMS_MISSING"] = "request/params_missing";
6795
+ ResponseErrorCode2["REQUEST_DATA_RETRIEVAL_FAILED"] = "request/data_retrieval_failed";
6796
+ ResponseErrorCode2["REQUEST_DATA_ALREADY_EXISTS"] = "request/data_already_exists";
6794
6797
  ResponseErrorCode2["AUTH_LOGIN_FAILED"] = "auth/login_failed";
6795
6798
  ResponseErrorCode2["AUTH_REGISTRATION_FAILED"] = "auth/registration_failed";
6796
6799
  ResponseErrorCode2["AUTH_MISSING_DATA"] = "auth/missing_data";
@@ -7943,9 +7946,25 @@ const useContent = () => {
7943
7946
  [request, formatContentModelItemData]
7944
7947
  );
7945
7948
  const getPaginatedContentModelItems = React.useCallback(
7946
- async (name, pageSize, filterByIsActive = true) => {
7949
+ async (name, page2, pageSize, filterByIsActive = true, query, dataFilters) => {
7950
+ const params = new URLSearchParams({
7951
+ page: String(page2),
7952
+ pageSize: String(pageSize),
7953
+ contentModelName: name
7954
+ });
7955
+ if (filterByIsActive) params.append("isActive", "true");
7956
+ if (query) params.append("query", query);
7957
+ if (dataFilters?.length) {
7958
+ dataFilters.forEach((filter2, index) => {
7959
+ params.append(`dataFilters[${index}][key]`, filter2.key);
7960
+ params.append(`dataFilters[${index}][value]`, filter2.value);
7961
+ if (filter2.operator) {
7962
+ params.append(`dataFilters[${index}][operator]`, filter2.operator);
7963
+ }
7964
+ });
7965
+ }
7947
7966
  const task = await request({
7948
- url: `content-model/items?pageSize=${pageSize}&contentModelName=${name}${filterByIsActive ? "&isActive=true" : ""}`
7967
+ url: `content-model/items?${params.toString()}`
7949
7968
  });
7950
7969
  if (task.success && task.result) {
7951
7970
  const items = (task.result.data?.items || []).map(
@@ -7953,20 +7972,35 @@ const useContent = () => {
7953
7972
  );
7954
7973
  const total = task.result.data?.meta?.total || 0;
7955
7974
  const currentPage = task.result.data?.meta?.currentPage || 1;
7956
- return {
7957
- items,
7958
- total,
7959
- currentPage
7960
- };
7975
+ return { items, total, currentPage };
7961
7976
  }
7962
- return {
7963
- items: [],
7964
- total: 0,
7965
- currentPage: 1
7966
- };
7977
+ return { items: [], total: 0, currentPage: 1 };
7967
7978
  },
7968
7979
  [request, formatContentModelItemData]
7969
7980
  );
7981
+ const submitUserContentModelItem = React.useCallback(
7982
+ async (title, contentModelId, singletonsData = {}, collectionsData = {}, successCallback, errorCallback) => {
7983
+ const task = await request({
7984
+ url: `/content-model/user-items`,
7985
+ method: "post",
7986
+ data: {
7987
+ title,
7988
+ contentModelId,
7989
+ contentModelData: {
7990
+ index: { ...singletonsData },
7991
+ ...collectionsData
7992
+ }
7993
+ }
7994
+ });
7995
+ if (task.failure && task.error) {
7996
+ if (errorCallback) errorCallback(task.error?.response?.data);
7997
+ } else {
7998
+ if (successCallback) successCallback();
7999
+ }
8000
+ return task;
8001
+ },
8002
+ [request]
8003
+ );
7970
8004
  const getMenu = React.useCallback(
7971
8005
  (name, filterByIsActive = true) => {
7972
8006
  const menu = cloneDeep(props?.menus?.find((menu2) => menu2.name === name));
@@ -8144,6 +8178,8 @@ const useContent = () => {
8144
8178
  getContentModelItems,
8145
8179
  getPaginatedContentModelItems,
8146
8180
  getAppInformationValue,
8181
+ submitUserContentModelItem,
8182
+ formatContentModelItemData,
8147
8183
  appAccentColor,
8148
8184
  appPrimaryColor,
8149
8185
  appSecondaryColor
@@ -6790,6 +6790,9 @@ var ProfileType;
6790
6790
  var ResponseErrorCode;
6791
6791
  (function(ResponseErrorCode2) {
6792
6792
  ResponseErrorCode2["FORM_INVALID_DATA"] = "form/invalid_data";
6793
+ ResponseErrorCode2["REQUEST_PARAMS_MISSING"] = "request/params_missing";
6794
+ ResponseErrorCode2["REQUEST_DATA_RETRIEVAL_FAILED"] = "request/data_retrieval_failed";
6795
+ ResponseErrorCode2["REQUEST_DATA_ALREADY_EXISTS"] = "request/data_already_exists";
6793
6796
  ResponseErrorCode2["AUTH_LOGIN_FAILED"] = "auth/login_failed";
6794
6797
  ResponseErrorCode2["AUTH_REGISTRATION_FAILED"] = "auth/registration_failed";
6795
6798
  ResponseErrorCode2["AUTH_MISSING_DATA"] = "auth/missing_data";
@@ -7942,9 +7945,25 @@ const useContent = () => {
7942
7945
  [request, formatContentModelItemData]
7943
7946
  );
7944
7947
  const getPaginatedContentModelItems = useCallback(
7945
- async (name, pageSize, filterByIsActive = true) => {
7948
+ async (name, page2, pageSize, filterByIsActive = true, query, dataFilters) => {
7949
+ const params = new URLSearchParams({
7950
+ page: String(page2),
7951
+ pageSize: String(pageSize),
7952
+ contentModelName: name
7953
+ });
7954
+ if (filterByIsActive) params.append("isActive", "true");
7955
+ if (query) params.append("query", query);
7956
+ if (dataFilters?.length) {
7957
+ dataFilters.forEach((filter2, index) => {
7958
+ params.append(`dataFilters[${index}][key]`, filter2.key);
7959
+ params.append(`dataFilters[${index}][value]`, filter2.value);
7960
+ if (filter2.operator) {
7961
+ params.append(`dataFilters[${index}][operator]`, filter2.operator);
7962
+ }
7963
+ });
7964
+ }
7946
7965
  const task = await request({
7947
- url: `content-model/items?pageSize=${pageSize}&contentModelName=${name}${filterByIsActive ? "&isActive=true" : ""}`
7966
+ url: `content-model/items?${params.toString()}`
7948
7967
  });
7949
7968
  if (task.success && task.result) {
7950
7969
  const items = (task.result.data?.items || []).map(
@@ -7952,20 +7971,35 @@ const useContent = () => {
7952
7971
  );
7953
7972
  const total = task.result.data?.meta?.total || 0;
7954
7973
  const currentPage = task.result.data?.meta?.currentPage || 1;
7955
- return {
7956
- items,
7957
- total,
7958
- currentPage
7959
- };
7974
+ return { items, total, currentPage };
7960
7975
  }
7961
- return {
7962
- items: [],
7963
- total: 0,
7964
- currentPage: 1
7965
- };
7976
+ return { items: [], total: 0, currentPage: 1 };
7966
7977
  },
7967
7978
  [request, formatContentModelItemData]
7968
7979
  );
7980
+ const submitUserContentModelItem = useCallback(
7981
+ async (title, contentModelId, singletonsData = {}, collectionsData = {}, successCallback, errorCallback) => {
7982
+ const task = await request({
7983
+ url: `/content-model/user-items`,
7984
+ method: "post",
7985
+ data: {
7986
+ title,
7987
+ contentModelId,
7988
+ contentModelData: {
7989
+ index: { ...singletonsData },
7990
+ ...collectionsData
7991
+ }
7992
+ }
7993
+ });
7994
+ if (task.failure && task.error) {
7995
+ if (errorCallback) errorCallback(task.error?.response?.data);
7996
+ } else {
7997
+ if (successCallback) successCallback();
7998
+ }
7999
+ return task;
8000
+ },
8001
+ [request]
8002
+ );
7969
8003
  const getMenu = useCallback(
7970
8004
  (name, filterByIsActive = true) => {
7971
8005
  const menu = cloneDeep(props?.menus?.find((menu2) => menu2.name === name));
@@ -8143,6 +8177,8 @@ const useContent = () => {
8143
8177
  getContentModelItems,
8144
8178
  getPaginatedContentModelItems,
8145
8179
  getAppInformationValue,
8180
+ submitUserContentModelItem,
8181
+ formatContentModelItemData,
8146
8182
  appAccentColor,
8147
8183
  appPrimaryColor,
8148
8184
  appSecondaryColor
@@ -1,7 +1,234 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const content = require("../content-BpVMJ1wf.cjs");
3
+ const content = require("../content-DeoXIM_L.cjs");
4
4
  const React = require("react");
5
+ const articlesUrlBuilder = (p) => {
6
+ const searchParams = new URLSearchParams();
7
+ searchParams.set("pageSize", String(p.pageSize));
8
+ if (p.query) searchParams.set("query", p.query);
9
+ if (p.page) searchParams.set("page", String(p.page));
10
+ if (p.status) searchParams.set("status", String(p.status));
11
+ if (p.categories?.length) {
12
+ p.categories.forEach(
13
+ (cat) => searchParams.append("categories[]", String(cat))
14
+ );
15
+ }
16
+ if (p.tags?.length) {
17
+ p.tags.forEach((tag) => searchParams.append("tags[]", String(tag)));
18
+ }
19
+ if (p.months?.length) {
20
+ p.months.forEach((month) => searchParams.append("months[]", month));
21
+ }
22
+ return `/news-articles?${searchParams.toString()}`;
23
+ };
24
+ const commentsUrlBuilder = (p) => {
25
+ const searchParams = new URLSearchParams();
26
+ Object.entries(p).forEach(([key, value]) => {
27
+ if (value !== void 0) searchParams.set(key, String(value));
28
+ });
29
+ return `/news-comments?${searchParams.toString()}`;
30
+ };
31
+ const useNews = () => {
32
+ const { request } = content.useApi();
33
+ const [isLoading, setIsLoading] = React.useState(false);
34
+ const loadCategories = React.useCallback(
35
+ async (filterByIsVisible = true) => {
36
+ setIsLoading(true);
37
+ const task = await request({ url: "/news-categories" });
38
+ setIsLoading(false);
39
+ if (task.success && task.result.data) {
40
+ return task.result.data.filter(
41
+ (p) => !filterByIsVisible || p.isActive
42
+ );
43
+ }
44
+ return [];
45
+ },
46
+ [request]
47
+ );
48
+ const loadTags = React.useCallback(
49
+ async (filterByIsVisible = true) => {
50
+ setIsLoading(true);
51
+ const task = await request({ url: "/news-tags" });
52
+ setIsLoading(false);
53
+ if (task.success && task.result.data) {
54
+ return task.result.data.filter(
55
+ (p) => !filterByIsVisible || p.isActive
56
+ );
57
+ }
58
+ return [];
59
+ },
60
+ [request]
61
+ );
62
+ const loadArticles = React.useCallback(
63
+ async (params) => {
64
+ setIsLoading(true);
65
+ const task = await request({ url: articlesUrlBuilder(params) });
66
+ setIsLoading(false);
67
+ if (task.success && task.result.data) {
68
+ return task.result.data;
69
+ }
70
+ return {
71
+ articles: [],
72
+ meta: { total: 0, currentPage: 1, perPage: 1, lastPage: 1 }
73
+ };
74
+ },
75
+ [request]
76
+ );
77
+ const loadArticlesMonths = React.useCallback(async () => {
78
+ setIsLoading(true);
79
+ const task = await request({ url: "/news-articles/list/months" });
80
+ setIsLoading(false);
81
+ if (task.success && task.result.data) {
82
+ return task.result.data;
83
+ }
84
+ return [];
85
+ }, [request]);
86
+ const loadArticlesCount = React.useCallback(async () => {
87
+ setIsLoading(true);
88
+ const task = await request({ url: "/count/news-articles" });
89
+ setIsLoading(false);
90
+ if (task.success) {
91
+ return task.result.data;
92
+ }
93
+ return 0;
94
+ }, [request]);
95
+ const loadArticlesCountByStatus = React.useCallback(
96
+ async (status) => {
97
+ setIsLoading(true);
98
+ const task = await request({
99
+ url: `/count/news-articles/status/${status}`
100
+ });
101
+ setIsLoading(false);
102
+ if (task.success) {
103
+ return task.result.data;
104
+ }
105
+ return 0;
106
+ },
107
+ [request]
108
+ );
109
+ const loadArticlesCountByAuthor = React.useCallback(
110
+ async (id) => {
111
+ setIsLoading(true);
112
+ const task = await request({
113
+ url: `/count/news-articles/author/${id}`
114
+ });
115
+ setIsLoading(false);
116
+ if (task.success) {
117
+ return task.result.data;
118
+ }
119
+ return 0;
120
+ },
121
+ [request]
122
+ );
123
+ const loadComments = React.useCallback(
124
+ async (params) => {
125
+ setIsLoading(true);
126
+ const task = await request({ url: commentsUrlBuilder(params) });
127
+ setIsLoading(false);
128
+ if (task.success && task.result.data) {
129
+ return task.result.data;
130
+ }
131
+ return {
132
+ comments: [],
133
+ meta: { total: 0, currentPage: 1, perPage: 1, lastPage: 1 }
134
+ };
135
+ },
136
+ [request]
137
+ );
138
+ const addComment = React.useCallback(
139
+ async (comment, successCallback, errorCallback) => {
140
+ setIsLoading(true);
141
+ const task = await request({
142
+ url: "/news-comments",
143
+ method: "post",
144
+ data: comment
145
+ });
146
+ setIsLoading(false);
147
+ if (task.failure && task.error) {
148
+ if (errorCallback) errorCallback(task.error?.response?.data);
149
+ } else {
150
+ if (successCallback) successCallback();
151
+ }
152
+ return task;
153
+ },
154
+ [request]
155
+ );
156
+ return {
157
+ isLoading,
158
+ loadTags,
159
+ loadComments,
160
+ loadArticles,
161
+ loadCategories,
162
+ loadArticlesCount,
163
+ loadArticlesMonths,
164
+ loadArticlesCountByStatus,
165
+ loadArticlesCountByAuthor,
166
+ addComment
167
+ };
168
+ };
169
+ const videoItemsUrlBuilder = (p) => {
170
+ const searchParams = new URLSearchParams();
171
+ searchParams.set("pageSize", String(p.pageSize));
172
+ if (p.query) searchParams.set("query", p.query);
173
+ if (p.page) searchParams.set("page", String(p.page));
174
+ if (p.source) searchParams.set("source", p.source);
175
+ if (p.visible !== void 0) searchParams.set("visible", String(p.visible));
176
+ if (p.orderByPublishedAt !== void 0)
177
+ searchParams.set("orderByPublishedAt", String(p.orderByPublishedAt));
178
+ if (p.categories?.length) {
179
+ p.categories.forEach(
180
+ (cat) => searchParams.append("categories[]", String(cat))
181
+ );
182
+ }
183
+ return `/video-items?${searchParams.toString()}`;
184
+ };
185
+ const useVideo = () => {
186
+ const { request } = content.useApi();
187
+ const [isLoading, setIsLoading] = React.useState(false);
188
+ const loadCategories = React.useCallback(
189
+ async (filterByIsVisible = true) => {
190
+ setIsLoading(true);
191
+ const task = await request({
192
+ url: "/video-categories"
193
+ });
194
+ setIsLoading(false);
195
+ if (task.success && task.result.data) {
196
+ return task.result.data.filter(
197
+ (p) => !filterByIsVisible || p.isActive
198
+ );
199
+ }
200
+ return [];
201
+ },
202
+ [request]
203
+ );
204
+ const loadVideoItems = React.useCallback(
205
+ async (params) => {
206
+ setIsLoading(true);
207
+ const task = await request({
208
+ url: videoItemsUrlBuilder(params)
209
+ });
210
+ setIsLoading(false);
211
+ if (task.success && task.result.data) {
212
+ return task.result.data;
213
+ }
214
+ return {
215
+ videoItems: [],
216
+ meta: {
217
+ total: 0,
218
+ currentPage: 1,
219
+ perPage: 1,
220
+ lastPage: 1
221
+ }
222
+ };
223
+ },
224
+ [request]
225
+ );
226
+ return {
227
+ isLoading,
228
+ loadCategories,
229
+ loadVideoItems
230
+ };
231
+ };
5
232
  const useNewsletter = () => {
6
233
  const { request } = content.useApi();
7
234
  const [isLoading, setIsLoading] = React.useState(false);
@@ -50,4 +277,6 @@ exports.useConfig = content.useConfig;
50
277
  exports.useContent = content.useContent;
51
278
  exports.useHelper = content.useHelper;
52
279
  exports.useProps = content.useProps;
280
+ exports.useNews = useNews;
53
281
  exports.useNewsletter = useNewsletter;
282
+ exports.useVideo = useVideo;
@@ -1,6 +1,233 @@
1
- import { e as useApi } from "../content-CSFJStkb.js";
2
- import { f, a, u, b } from "../content-CSFJStkb.js";
1
+ import { e as useApi } from "../content-SRtqarhC.js";
2
+ import { f, a, u, b } from "../content-SRtqarhC.js";
3
3
  import { useState, useCallback } from "react";
4
+ const articlesUrlBuilder = (p) => {
5
+ const searchParams = new URLSearchParams();
6
+ searchParams.set("pageSize", String(p.pageSize));
7
+ if (p.query) searchParams.set("query", p.query);
8
+ if (p.page) searchParams.set("page", String(p.page));
9
+ if (p.status) searchParams.set("status", String(p.status));
10
+ if (p.categories?.length) {
11
+ p.categories.forEach(
12
+ (cat) => searchParams.append("categories[]", String(cat))
13
+ );
14
+ }
15
+ if (p.tags?.length) {
16
+ p.tags.forEach((tag) => searchParams.append("tags[]", String(tag)));
17
+ }
18
+ if (p.months?.length) {
19
+ p.months.forEach((month) => searchParams.append("months[]", month));
20
+ }
21
+ return `/news-articles?${searchParams.toString()}`;
22
+ };
23
+ const commentsUrlBuilder = (p) => {
24
+ const searchParams = new URLSearchParams();
25
+ Object.entries(p).forEach(([key, value]) => {
26
+ if (value !== void 0) searchParams.set(key, String(value));
27
+ });
28
+ return `/news-comments?${searchParams.toString()}`;
29
+ };
30
+ const useNews = () => {
31
+ const { request } = useApi();
32
+ const [isLoading, setIsLoading] = useState(false);
33
+ const loadCategories = useCallback(
34
+ async (filterByIsVisible = true) => {
35
+ setIsLoading(true);
36
+ const task = await request({ url: "/news-categories" });
37
+ setIsLoading(false);
38
+ if (task.success && task.result.data) {
39
+ return task.result.data.filter(
40
+ (p) => !filterByIsVisible || p.isActive
41
+ );
42
+ }
43
+ return [];
44
+ },
45
+ [request]
46
+ );
47
+ const loadTags = useCallback(
48
+ async (filterByIsVisible = true) => {
49
+ setIsLoading(true);
50
+ const task = await request({ url: "/news-tags" });
51
+ setIsLoading(false);
52
+ if (task.success && task.result.data) {
53
+ return task.result.data.filter(
54
+ (p) => !filterByIsVisible || p.isActive
55
+ );
56
+ }
57
+ return [];
58
+ },
59
+ [request]
60
+ );
61
+ const loadArticles = useCallback(
62
+ async (params) => {
63
+ setIsLoading(true);
64
+ const task = await request({ url: articlesUrlBuilder(params) });
65
+ setIsLoading(false);
66
+ if (task.success && task.result.data) {
67
+ return task.result.data;
68
+ }
69
+ return {
70
+ articles: [],
71
+ meta: { total: 0, currentPage: 1, perPage: 1, lastPage: 1 }
72
+ };
73
+ },
74
+ [request]
75
+ );
76
+ const loadArticlesMonths = useCallback(async () => {
77
+ setIsLoading(true);
78
+ const task = await request({ url: "/news-articles/list/months" });
79
+ setIsLoading(false);
80
+ if (task.success && task.result.data) {
81
+ return task.result.data;
82
+ }
83
+ return [];
84
+ }, [request]);
85
+ const loadArticlesCount = useCallback(async () => {
86
+ setIsLoading(true);
87
+ const task = await request({ url: "/count/news-articles" });
88
+ setIsLoading(false);
89
+ if (task.success) {
90
+ return task.result.data;
91
+ }
92
+ return 0;
93
+ }, [request]);
94
+ const loadArticlesCountByStatus = useCallback(
95
+ async (status) => {
96
+ setIsLoading(true);
97
+ const task = await request({
98
+ url: `/count/news-articles/status/${status}`
99
+ });
100
+ setIsLoading(false);
101
+ if (task.success) {
102
+ return task.result.data;
103
+ }
104
+ return 0;
105
+ },
106
+ [request]
107
+ );
108
+ const loadArticlesCountByAuthor = useCallback(
109
+ async (id) => {
110
+ setIsLoading(true);
111
+ const task = await request({
112
+ url: `/count/news-articles/author/${id}`
113
+ });
114
+ setIsLoading(false);
115
+ if (task.success) {
116
+ return task.result.data;
117
+ }
118
+ return 0;
119
+ },
120
+ [request]
121
+ );
122
+ const loadComments = useCallback(
123
+ async (params) => {
124
+ setIsLoading(true);
125
+ const task = await request({ url: commentsUrlBuilder(params) });
126
+ setIsLoading(false);
127
+ if (task.success && task.result.data) {
128
+ return task.result.data;
129
+ }
130
+ return {
131
+ comments: [],
132
+ meta: { total: 0, currentPage: 1, perPage: 1, lastPage: 1 }
133
+ };
134
+ },
135
+ [request]
136
+ );
137
+ const addComment = useCallback(
138
+ async (comment, successCallback, errorCallback) => {
139
+ setIsLoading(true);
140
+ const task = await request({
141
+ url: "/news-comments",
142
+ method: "post",
143
+ data: comment
144
+ });
145
+ setIsLoading(false);
146
+ if (task.failure && task.error) {
147
+ if (errorCallback) errorCallback(task.error?.response?.data);
148
+ } else {
149
+ if (successCallback) successCallback();
150
+ }
151
+ return task;
152
+ },
153
+ [request]
154
+ );
155
+ return {
156
+ isLoading,
157
+ loadTags,
158
+ loadComments,
159
+ loadArticles,
160
+ loadCategories,
161
+ loadArticlesCount,
162
+ loadArticlesMonths,
163
+ loadArticlesCountByStatus,
164
+ loadArticlesCountByAuthor,
165
+ addComment
166
+ };
167
+ };
168
+ const videoItemsUrlBuilder = (p) => {
169
+ const searchParams = new URLSearchParams();
170
+ searchParams.set("pageSize", String(p.pageSize));
171
+ if (p.query) searchParams.set("query", p.query);
172
+ if (p.page) searchParams.set("page", String(p.page));
173
+ if (p.source) searchParams.set("source", p.source);
174
+ if (p.visible !== void 0) searchParams.set("visible", String(p.visible));
175
+ if (p.orderByPublishedAt !== void 0)
176
+ searchParams.set("orderByPublishedAt", String(p.orderByPublishedAt));
177
+ if (p.categories?.length) {
178
+ p.categories.forEach(
179
+ (cat) => searchParams.append("categories[]", String(cat))
180
+ );
181
+ }
182
+ return `/video-items?${searchParams.toString()}`;
183
+ };
184
+ const useVideo = () => {
185
+ const { request } = useApi();
186
+ const [isLoading, setIsLoading] = useState(false);
187
+ const loadCategories = useCallback(
188
+ async (filterByIsVisible = true) => {
189
+ setIsLoading(true);
190
+ const task = await request({
191
+ url: "/video-categories"
192
+ });
193
+ setIsLoading(false);
194
+ if (task.success && task.result.data) {
195
+ return task.result.data.filter(
196
+ (p) => !filterByIsVisible || p.isActive
197
+ );
198
+ }
199
+ return [];
200
+ },
201
+ [request]
202
+ );
203
+ const loadVideoItems = useCallback(
204
+ async (params) => {
205
+ setIsLoading(true);
206
+ const task = await request({
207
+ url: videoItemsUrlBuilder(params)
208
+ });
209
+ setIsLoading(false);
210
+ if (task.success && task.result.data) {
211
+ return task.result.data;
212
+ }
213
+ return {
214
+ videoItems: [],
215
+ meta: {
216
+ total: 0,
217
+ currentPage: 1,
218
+ perPage: 1,
219
+ lastPage: 1
220
+ }
221
+ };
222
+ },
223
+ [request]
224
+ );
225
+ return {
226
+ isLoading,
227
+ loadCategories,
228
+ loadVideoItems
229
+ };
230
+ };
4
231
  const useNewsletter = () => {
5
232
  const { request } = useApi();
6
233
  const [isLoading, setIsLoading] = useState(false);
@@ -49,6 +276,8 @@ export {
49
276
  f as useConfig,
50
277
  a as useContent,
51
278
  u as useHelper,
279
+ useNews,
52
280
  useNewsletter,
53
- b as useProps
281
+ b as useProps,
282
+ useVideo
54
283
  };
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
- const content = require("./content-BpVMJ1wf.cjs");
4
+ const content = require("./content-DeoXIM_L.cjs");
5
5
  const react = require("@inertiajs/react");
6
6
  const reactDom = require("react-dom");
7
7
  function _interopNamespaceDefault(e) {
@@ -8247,6 +8247,11 @@ const RootContainer$1 = () => {
8247
8247
  true
8248
8248
  );
8249
8249
  ["assign", "replace"].forEach((method) => {
8250
+ const descriptor = Object.getOwnPropertyDescriptor(
8251
+ window.location,
8252
+ method
8253
+ );
8254
+ if (descriptor?.configurable === false) return;
8250
8255
  Object.defineProperty(window.location, method, {
8251
8256
  value: function() {
8252
8257
  console.debug(`🚫 location.${method}() blocked`);
@@ -8255,14 +8260,20 @@ const RootContainer$1 = () => {
8255
8260
  configurable: false
8256
8261
  });
8257
8262
  });
8258
- const currentHref = window.location.href;
8259
- Object.defineProperty(window.location, "href", {
8260
- get: () => currentHref,
8261
- set: (value) => {
8262
- console.debug("🚫 location.href = blocked:", value);
8263
- },
8264
- configurable: false
8265
- });
8263
+ const hrefDescriptor = Object.getOwnPropertyDescriptor(
8264
+ window.location,
8265
+ "href"
8266
+ );
8267
+ if (hrefDescriptor?.configurable !== false) {
8268
+ const currentHref = window.location.href;
8269
+ Object.defineProperty(window.location, "href", {
8270
+ get: () => currentHref,
8271
+ set: (value) => {
8272
+ console.debug("🚫 location.href = blocked:", value);
8273
+ },
8274
+ configurable: false
8275
+ });
8276
+ }
8266
8277
  window.open = function() {
8267
8278
  console.debug("🚫 window.open() blocked");
8268
8279
  return null;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import React__default, { useState, useEffect, createContext, useRef, useLayoutEffect, useId, useContext, useInsertionEffect, useMemo, useCallback, Children, isValidElement, Fragment, createElement, forwardRef, Component } from "react";
3
- import { u as useHelper, a as useContent, b as useProps, P as PropsContext, R as ResolveSectionsContext, c as cloneDeep, s as slideToId, E as EditorMessageType, d as RouterContext, C as ConfigContext } from "./content-CSFJStkb.js";
3
+ import { u as useHelper, a as useContent, b as useProps, P as PropsContext, R as ResolveSectionsContext, c as cloneDeep, s as slideToId, E as EditorMessageType, d as RouterContext, C as ConfigContext } from "./content-SRtqarhC.js";
4
4
  import { router } from "@inertiajs/react";
5
5
  import { createPortal } from "react-dom";
6
6
  var jsxRuntime = { exports: {} };
@@ -8229,6 +8229,11 @@ const RootContainer$1 = () => {
8229
8229
  true
8230
8230
  );
8231
8231
  ["assign", "replace"].forEach((method) => {
8232
+ const descriptor = Object.getOwnPropertyDescriptor(
8233
+ window.location,
8234
+ method
8235
+ );
8236
+ if (descriptor?.configurable === false) return;
8232
8237
  Object.defineProperty(window.location, method, {
8233
8238
  value: function() {
8234
8239
  console.debug(`🚫 location.${method}() blocked`);
@@ -8237,14 +8242,20 @@ const RootContainer$1 = () => {
8237
8242
  configurable: false
8238
8243
  });
8239
8244
  });
8240
- const currentHref = window.location.href;
8241
- Object.defineProperty(window.location, "href", {
8242
- get: () => currentHref,
8243
- set: (value) => {
8244
- console.debug("🚫 location.href = blocked:", value);
8245
- },
8246
- configurable: false
8247
- });
8245
+ const hrefDescriptor = Object.getOwnPropertyDescriptor(
8246
+ window.location,
8247
+ "href"
8248
+ );
8249
+ if (hrefDescriptor?.configurable !== false) {
8250
+ const currentHref = window.location.href;
8251
+ Object.defineProperty(window.location, "href", {
8252
+ get: () => currentHref,
8253
+ set: (value) => {
8254
+ console.debug("🚫 location.href = blocked:", value);
8255
+ },
8256
+ configurable: false
8257
+ });
8258
+ }
8248
8259
  window.open = function() {
8249
8260
  console.debug("🚫 window.open() blocked");
8250
8261
  return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creopse/react",
3
3
  "description": "Creopse React Toolkit",
4
- "version": "0.0.22",
4
+ "version": "0.0.25",
5
5
  "private": false,
6
6
  "author": "Noé Gnanih <noegnanih@gmail.com>",
7
7
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "react-dom": "^19.1.0"
44
44
  },
45
45
  "dependencies": {
46
- "@creopse/utils": "^0.0.13",
46
+ "@creopse/utils": "^0.0.14",
47
47
  "@vueuse/core": "^14.1.0",
48
48
  "axios": "^1.13.2",
49
49
  "framer-motion": "^12.23.9",
@@ -1,3 +1,5 @@
1
+ import type { Response } from '@/types/api';
2
+ import type { DataFilter, PaginatedContentModelItems } from '@/types/content';
1
3
  import type { AppInformationKey, ContentModelItemModel, ContentModelModel, MenuItemGroupModel, MenuItemModel, MenuModel, NewsArticleModel, NewsCategoryModel, NewsTagModel, PageModel, SettingType, SharedProps } from '@creopse/utils';
2
4
  /**
3
5
  * A hook that provides a set of functions and properties for
@@ -35,12 +37,10 @@ export declare const useContent: () => {
35
37
  getSectionRootData: (key?: string) => any;
36
38
  getContentModel: (name: string) => ContentModelModel | undefined;
37
39
  getContentModelItems: (name: string, filterByIsActive?: boolean) => Promise<ContentModelItemModel[]>;
38
- getPaginatedContentModelItems: (name: string, pageSize: number, filterByIsActive?: boolean) => Promise<{
39
- items: ContentModelItemModel[];
40
- total: number;
41
- currentPage: number;
42
- }>;
40
+ getPaginatedContentModelItems: (name: string, page: number, pageSize: number, filterByIsActive?: boolean, query?: string, dataFilters?: DataFilter[]) => Promise<PaginatedContentModelItems>;
43
41
  getAppInformationValue: (key: AppInformationKey, type?: SettingType) => any;
42
+ submitUserContentModelItem: (title: string, contentModelId: string, singletonsData?: any, collectionsData?: any, successCallback?: () => void, errorCallback?: (errorData: any) => void) => Promise<Response<any>>;
43
+ formatContentModelItemData: (item: ContentModelItemModel) => object;
44
44
  appAccentColor: string;
45
45
  appPrimaryColor: string;
46
46
  appSecondaryColor: string;
@@ -1,5 +1,7 @@
1
1
  export { useApi } from './api';
2
+ export { useNews } from './news';
2
3
  export { useProps } from './props';
4
+ export { useVideo } from './video';
3
5
  export { useConfig } from './config';
4
6
  export { useHelper } from './helper';
5
7
  export { useContent } from './content';
@@ -0,0 +1,31 @@
1
+ import type { Response } from '@/types/api';
2
+ import type { ArticlesQueryParams, CommentsQueryParams, PaginatedArticles, PaginatedComments } from '@/types/news';
3
+ import type { NewsArticleStatus, NewsCategoryModel, NewsCommentModel, NewsTagModel } from '@creopse/utils';
4
+ /**
5
+ * A hook that provides a set of functions and properties for
6
+ * easily accessing and manipulating news articles, categories, tags, and comments.
7
+ *
8
+ * @returns {Object}
9
+ * @property {boolean} isLoading - A boolean that indicates whether a request is being processed.
10
+ * @property {function} loadTags - A function that loads news tags from the server.
11
+ * @property {function} loadComments - A function that loads news comments from the server.
12
+ * @property {function} loadArticles - A function that loads news articles from the server.
13
+ * @property {function} loadCategories - A function that loads news categories from the server.
14
+ * @property {function} loadArticlesCount - A function that loads the total count of news articles.
15
+ * @property {function} loadArticlesMonths - A function that loads months having at least one article.
16
+ * @property {function} loadArticlesCountByStatus - A function that loads the article count by status.
17
+ * @property {function} loadArticlesCountByAuthor - A function that loads the article count by author.
18
+ * @property {function} addComment - A function that adds a new news comment to the server.
19
+ */
20
+ export declare const useNews: () => {
21
+ isLoading: boolean;
22
+ loadTags: (filterByIsVisible?: boolean) => Promise<NewsTagModel[]>;
23
+ loadComments: (params: CommentsQueryParams) => Promise<PaginatedComments>;
24
+ loadArticles: (params: ArticlesQueryParams) => Promise<PaginatedArticles>;
25
+ loadCategories: (filterByIsVisible?: boolean) => Promise<NewsCategoryModel[]>;
26
+ loadArticlesCount: () => Promise<number>;
27
+ loadArticlesMonths: () => Promise<string[]>;
28
+ loadArticlesCountByStatus: (status: NewsArticleStatus) => Promise<number>;
29
+ loadArticlesCountByAuthor: (id: number) => Promise<number>;
30
+ addComment: (comment: NewsCommentModel, successCallback?: () => void, errorCallback?: (errorData: any) => void) => Promise<Response<any>>;
31
+ };
@@ -0,0 +1,16 @@
1
+ import type { PaginatedVideoItems, VideoItemsQueryParams } from '@/types/video';
2
+ import type { VideoCategoryModel } from '@creopse/utils';
3
+ /**
4
+ * A hook that provides a set of functions and properties for
5
+ * easily accessing and manipulating video categories and video items.
6
+ *
7
+ * @returns {Object}
8
+ * @property {boolean} isLoading - A boolean that indicates whether a request is being processed.
9
+ * @property {function} loadCategories - A function that loads video categories from the server.
10
+ * @property {function} loadVideoItems - A function that loads video items from the server.
11
+ */
12
+ export declare const useVideo: () => {
13
+ isLoading: boolean;
14
+ loadCategories: (filterByIsVisible?: boolean) => Promise<VideoCategoryModel[]>;
15
+ loadVideoItems: (params: VideoItemsQueryParams) => Promise<PaginatedVideoItems>;
16
+ };
@@ -0,0 +1,11 @@
1
+ import type { ContentModelItemModel } from '@creopse/utils';
2
+ export type DataFilter = {
3
+ key: string;
4
+ value: string;
5
+ operator?: '=' | '!=' | '>' | '>=' | '<' | '<=' | 'like';
6
+ };
7
+ export interface PaginatedContentModelItems {
8
+ items: ContentModelItemModel[];
9
+ total: number;
10
+ currentPage: number;
11
+ }
@@ -0,0 +1,35 @@
1
+ import type { NewsArticleModel, NewsCommentModel } from '@creopse/utils';
2
+ export interface PaginatedResponseMeta {
3
+ links?: {
4
+ first: string;
5
+ last: string;
6
+ prev: string;
7
+ next: string;
8
+ };
9
+ currentPage: number;
10
+ perPage: number;
11
+ total: number;
12
+ lastPage: number;
13
+ }
14
+ export interface ArticlesQueryParams {
15
+ pageSize: number;
16
+ query?: string;
17
+ page?: number;
18
+ status?: number;
19
+ categories?: number[];
20
+ tags?: number[];
21
+ months?: string[];
22
+ }
23
+ export interface PaginatedArticles {
24
+ articles: NewsArticleModel[];
25
+ meta: PaginatedResponseMeta;
26
+ }
27
+ export interface CommentsQueryParams {
28
+ pageSize: number;
29
+ query?: string;
30
+ page?: number;
31
+ }
32
+ export interface PaginatedComments {
33
+ comments: NewsCommentModel[];
34
+ meta: PaginatedResponseMeta;
35
+ }
@@ -0,0 +1,25 @@
1
+ import type { VideoItemModel } from '@creopse/utils';
2
+ export interface VideoItemsQueryParams {
3
+ pageSize: number;
4
+ source?: string;
5
+ query?: string;
6
+ page?: number;
7
+ visible?: boolean;
8
+ orderByPublishedAt?: boolean;
9
+ categories?: (string | number)[];
10
+ }
11
+ export interface PaginatedVideoItems {
12
+ videoItems: VideoItemModel[];
13
+ meta: {
14
+ links?: {
15
+ first: string;
16
+ last: string;
17
+ prev: string;
18
+ next: string;
19
+ };
20
+ currentPage: number;
21
+ perPage: number;
22
+ total: number;
23
+ lastPage: number;
24
+ };
25
+ }