@sanity/embeddings-index-ui 1.1.5 → 1.1.6

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": "@sanity/embeddings-index-ui",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Various Sanity Studio plugins for integrating with the embeddings index API",
5
5
  "keywords": [
6
6
  "sanity",
@@ -1,24 +1,23 @@
1
- import {useClient, useProjectId} from 'sanity'
1
+ import {useProjectId} from 'sanity'
2
2
  import {createContext, PropsWithChildren, useContext, useEffect, useState} from 'react'
3
3
  import {Card, Text} from '@sanity/ui'
4
-
5
- const featureName = 'embeddingsIndexApi'
4
+ import {useApiClient} from './embeddingsApiHooks'
6
5
 
7
6
  export type FeatureStatus = 'enabled' | 'disabled' | 'loading'
8
7
  export const FeatureEnabledContext = createContext<FeatureStatus>('loading')
9
8
 
10
9
  export function useIsFeatureEnabled() {
11
- const client = useClient({apiVersion: '2023-09-01'})
10
+ const client = useApiClient()
12
11
  const [status, setStatus] = useState<FeatureStatus>('loading')
13
12
 
14
13
  useEffect(() => {
15
14
  client
16
- .request<string | boolean>({
15
+ .request<{enabled: boolean}>({
17
16
  method: 'GET',
18
- url: `/projects/${client.config().projectId}/features/${featureName}`,
17
+ url: `/embeddings-index/status`,
19
18
  })
20
- .then((isEnabled) => {
21
- setStatus(isEnabled === 'true' || isEnabled === true ? 'enabled' : 'disabled')
19
+ .then((response) => {
20
+ setStatus(response.enabled ? 'enabled' : 'disabled')
22
21
  })
23
22
  .catch((err) => {
24
23
  console.error(err)