-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(atomic-hosted-page): refactor common files into atomic-hoste…
…d-ui (#4898) https://coveord.atlassian.net/browse/KIT-3900 Small refactor after playing in this project. It's only 1 component so there should not be 'utils' or 'common' files.
- Loading branch information
1 parent
dd6e5e4
commit 6c74af7
Showing
4 changed files
with
77 additions
and
90 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
packages/atomic-hosted-page/src/components/atomic-hosted-ui/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {getOrganizationEndpoint} from '@coveo/headless'; | ||
import type {InitializationOptions} from './atomic-hosted-ui.js'; | ||
|
||
export async function getHostedPage( | ||
options: InitializationOptions, | ||
hostedType: 'trial' | 'builder' | 'code' | ||
) { | ||
const platformUrl = getOrganizationEndpoint( | ||
options.organizationId, | ||
options.environment, | ||
'admin' | ||
); | ||
|
||
const paths = { | ||
builder: { | ||
pagePathPrefix: 'searchpage/v1/interfaces', | ||
pagePath: '/json', | ||
}, | ||
trial: { | ||
pagePathPrefix: 'searchinterfaces', | ||
pagePath: '/hostedpage/v1', | ||
}, | ||
code: { | ||
pagePathPrefix: 'hostedpages', | ||
pagePath: '', | ||
}, | ||
} as const; | ||
|
||
const {pagePathPrefix, pagePath} = paths[hostedType]; | ||
|
||
const pageResponse = await fetch( | ||
`${platformUrl}/rest/organizations/${options.organizationId}/${pagePathPrefix}/${options.pageId}${pagePath}`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${options.accessToken}`, | ||
}, | ||
} | ||
); | ||
|
||
return await pageResponse.json(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
packages/atomic-hosted-page/src/components/utils/options-utils.ts
This file was deleted.
Oops, something went wrong.