Files
supabase/studio/components/interfaces/ProjectAPIDocs/Content/EdgeFunction.tsx
T
Joshen LimandTerry Sutton 94f5fc5a61 Feat/api side panel (#17880)
* Demo api side panel

* Add docs for storage and edge functions

* Add content

* fix

* Add scroll to logic

* Add storage docs

* Add docs URLs

* Add connecting to project section in getting started

* Link back to docs site for product + resource specific docs

* Add entry points into API side panel for table editor, auth users and storage

* Add entry points into API side panel for edge functions

* Beef up feature preview modal with content

* Fix asset path

* Address several feedback

* Addressing more feedback

* Shift GraphiQL page to database if new api docs flag enabled

* Spelling

* Wording changes

* Spacing and wording

* Fix small issues

* Fix

* Update key showing toggle button

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>
2023-10-05 13:30:12 +08:00

42 lines
1.3 KiB
TypeScript

import { useParams } from 'common'
import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query'
import { useAppStateSnapshot } from 'state/app-state'
import { DOCS_RESOURCE_CONTENT } from '../ProjectAPIDocs.constants'
import ResourceContent from '../ResourceContent'
import { ContentProps } from './Content.types'
const Bucket = ({ language, apikey = 'API_KEY', endpoint }: ContentProps) => {
const { ref } = useParams()
const snap = useAppStateSnapshot()
const { data } = useEdgeFunctionsQuery({ projectRef: ref })
const resource = snap.activeDocsSection[1]
const edgeFunctions = data ?? []
const edgeFunction = edgeFunctions.find((fn) => fn.name === resource)
if (edgeFunction === undefined) return null
return (
<div className="divide-y">
<div className="space-y-1 px-4 py-6">
<div className="flex items-center space-x-2">
<h2 className="text-xl">{edgeFunction.name}</h2>
</div>
</div>
<ResourceContent
selectedLanguage={language}
snippet={DOCS_RESOURCE_CONTENT.invokeEdgeFunction}
codeSnippets={DOCS_RESOURCE_CONTENT.invokeEdgeFunction.code({
name: resource,
endpoint: `${endpoint}`,
apikey: apikey,
})}
/>
</div>
)
}
export default Bucket