Fetch customization settings

This commit is contained in:
Samy Pessé
2023-11-03 21:36:40 -04:00
parent df84dda36a
commit 47cc664b4f
2 changed files with 29 additions and 2 deletions
+9 -2
View File
@@ -1,4 +1,4 @@
import { getSpace, getCurrentRevision } from '@/lib/api';
import { getSpace, getCurrentRevision, getSpaceCustomization } from '@/lib/api';
import { resolvePagePath, resolvePageId } from '@/lib/pages';
@@ -20,7 +20,13 @@ export interface PageIdParams extends SpaceParams {
export async function fetchPageData(params: PagePathParams | PageIdParams) {
const { spaceId } = params;
const [space, revision] = await Promise.all([getSpace(spaceId), getCurrentRevision(spaceId)]);
const [space, revision, customization] = await Promise.all([
getSpace(spaceId),
getCurrentRevision(spaceId),
getSpaceCustomization(spaceId),
]);
console.log(customization);
const page =
'pageId' in params && params.pageId
@@ -30,6 +36,7 @@ export async function fetchPageData(params: PagePathParams | PageIdParams) {
return {
space,
revision,
customization,
ancestors: [],
...page,
};
+20
View File
@@ -61,3 +61,23 @@ export const getPageDocument = unstable_cache(
tags: ['api', 'documents'],
},
);
/**
* Get the customization settings for a space.
*/
export const getSpaceCustomization = unstable_cache(
async (spaceId: string) => {
// TODO: use function from API client once updated
const { data } = await api().request({
method: 'GET',
path: `/spaces/${spaceId}/publishing/customization`,
secure: true,
format: 'json',
});
return data;
},
['api', 'customization'],
{
tags: ['api', 'customization'],
},
);