feat: add to workspace api
parent
c42ccdfc6f
commit
78fbbded1a
@ -0,0 +1,33 @@
|
|||||||
|
'use client'
|
||||||
|
import React, { FC } from 'react'
|
||||||
|
import ExploreContext from '@/context/explore-context'
|
||||||
|
import Sidebar from '@/app/components/explore/sidebar'
|
||||||
|
|
||||||
|
|
||||||
|
export interface IExploreProps {
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
const Explore: FC<IExploreProps> = ({
|
||||||
|
children
|
||||||
|
}) => {
|
||||||
|
const [controlUpdateInstalledApps, setControlUpdateInstalledApps] = React.useState(0)
|
||||||
|
return (
|
||||||
|
<div className='flex h-full bg-gray-100 border-t border-gray-200'>
|
||||||
|
<ExploreContext.Provider
|
||||||
|
value={
|
||||||
|
{
|
||||||
|
controlUpdateInstalledApps,
|
||||||
|
setControlUpdateInstalledApps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Sidebar controlUpdateInstalledApps={controlUpdateInstalledApps} />
|
||||||
|
<div className='grow'>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</ExploreContext.Provider>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(Explore)
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { createContext } from 'use-context-selector'
|
||||||
|
|
||||||
|
type IExplore = {
|
||||||
|
controlUpdateInstalledApps: number
|
||||||
|
setControlUpdateInstalledApps: (controlUpdateInstalledApps: number) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const ExploreContext = createContext<IExplore>({
|
||||||
|
controlUpdateInstalledApps: 0,
|
||||||
|
setControlUpdateInstalledApps: () => { },
|
||||||
|
})
|
||||||
|
|
||||||
|
export default ExploreContext
|
||||||
@ -1,5 +1,17 @@
|
|||||||
import { get } from './base'
|
import { get, post } from './base'
|
||||||
|
|
||||||
export const fetchAppList = () => {
|
export const fetchAppList = () => {
|
||||||
return get('/explore/apps')
|
return get('/explore/apps')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const fetchInstalledAppList = () => {
|
||||||
|
return get('/installed-apps')
|
||||||
|
}
|
||||||
|
|
||||||
|
export const installApp = (id: string) => {
|
||||||
|
return post('/installed-apps', {
|
||||||
|
body: {
|
||||||
|
app_id: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue