@axcode/axcloud-sdk 0.1.4 → 0.1.5
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/LICENSE.md +9 -0
- package/README.md +19 -1
- package/dist/index.d.mts +57 -7
- package/dist/index.d.ts +57 -7
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -704,6 +704,7 @@ function useNews(options = {}) {
|
|
|
704
704
|
};
|
|
705
705
|
}
|
|
706
706
|
var MEMBER_ENDPOINT_TYPES = ["news", "pages", "events"];
|
|
707
|
+
var PAGE_CONTENT_TYPES = ["page", "pages"];
|
|
707
708
|
function useContent(contentType, options = {}) {
|
|
708
709
|
const { client, orgId, isPublicMode } = useAxCloudContext();
|
|
709
710
|
const {
|
|
@@ -715,7 +716,8 @@ function useContent(contentType, options = {}) {
|
|
|
715
716
|
sectionId,
|
|
716
717
|
search,
|
|
717
718
|
sortBy = "createdAt",
|
|
718
|
-
sortOrder = "desc"
|
|
719
|
+
sortOrder = "desc",
|
|
720
|
+
lang
|
|
719
721
|
} = options;
|
|
720
722
|
const query = useQuery({
|
|
721
723
|
queryKey: [
|
|
@@ -732,7 +734,8 @@ function useContent(contentType, options = {}) {
|
|
|
732
734
|
sectionId,
|
|
733
735
|
search,
|
|
734
736
|
sortBy,
|
|
735
|
-
sortOrder
|
|
737
|
+
sortOrder,
|
|
738
|
+
lang
|
|
736
739
|
],
|
|
737
740
|
queryFn: async () => {
|
|
738
741
|
const useMemberEndpoint = !isPublicMode && !publicOnly && MEMBER_ENDPOINT_TYPES.includes(contentType);
|
|
@@ -745,7 +748,8 @@ function useContent(contentType, options = {}) {
|
|
|
745
748
|
sectionId,
|
|
746
749
|
search,
|
|
747
750
|
sortBy,
|
|
748
|
-
sortOrder
|
|
751
|
+
sortOrder,
|
|
752
|
+
lang
|
|
749
753
|
});
|
|
750
754
|
},
|
|
751
755
|
staleTime: 1e3 * 60 * 5
|
|
@@ -763,13 +767,15 @@ function useContent(contentType, options = {}) {
|
|
|
763
767
|
}
|
|
764
768
|
function useContentItem(contentType, idOrSlug, options = {}) {
|
|
765
769
|
const { client, orgId, isPublicMode } = useAxCloudContext();
|
|
766
|
-
const { publicOnly = false } = options;
|
|
767
|
-
const useMemberEndpoint = !isPublicMode && !publicOnly && MEMBER_ENDPOINT_TYPES.includes(contentType);
|
|
770
|
+
const { publicOnly = false, lang } = options;
|
|
771
|
+
const useMemberEndpoint = !isPublicMode && !publicOnly && (MEMBER_ENDPOINT_TYPES.includes(contentType) || PAGE_CONTENT_TYPES.includes(contentType));
|
|
768
772
|
const query = useQuery({
|
|
769
|
-
queryKey: ["axcloud", "content", orgId, contentType, idOrSlug, useMemberEndpoint],
|
|
773
|
+
queryKey: ["axcloud", "content", orgId, contentType, idOrSlug, useMemberEndpoint, lang],
|
|
770
774
|
queryFn: async () => {
|
|
771
775
|
const basePath = useMemberEndpoint ? "members" : "public";
|
|
772
|
-
|
|
776
|
+
const encodedIdOrSlug = encodeURIComponent(idOrSlug);
|
|
777
|
+
const endpoint = PAGE_CONTENT_TYPES.includes(contentType) ? `/content/${basePath}/${orgId}/page/${encodedIdOrSlug}` : `/content/${basePath}/${orgId}/${contentType}/${encodedIdOrSlug}`;
|
|
778
|
+
return lang ? client.get(endpoint, { lang }) : client.get(endpoint);
|
|
773
779
|
},
|
|
774
780
|
enabled: !!idOrSlug,
|
|
775
781
|
staleTime: 1e3 * 60 * 5
|
|
@@ -798,7 +804,7 @@ function useMySection(options = {}) {
|
|
|
798
804
|
`/orgs/api/organizations/${orgId}/sections/${sectionId}`,
|
|
799
805
|
{ includeMembers: includeMembers ? "true" : void 0 }
|
|
800
806
|
);
|
|
801
|
-
return "success" in response && response.data ? response.data : response;
|
|
807
|
+
return "success" in response && response.success === true && response.data ? response.data : response;
|
|
802
808
|
},
|
|
803
809
|
enabled: isAuthenticated && !isUserLoading && !!sectionId,
|
|
804
810
|
staleTime: 1e3 * 60 * 5
|
|
@@ -825,7 +831,7 @@ function useSections() {
|
|
|
825
831
|
queryKey: ["axcloud", "sections", orgId, stage],
|
|
826
832
|
queryFn: async () => {
|
|
827
833
|
const response = await client.get(`/orgs/api/organizations/${orgId}/sections`);
|
|
828
|
-
return "success" in response && response.data ? response.data : response;
|
|
834
|
+
return "success" in response && response.success === true && response.data ? response.data : response;
|
|
829
835
|
},
|
|
830
836
|
staleTime: 1e3 * 60 * 10
|
|
831
837
|
// 10 minutes
|