2023-05-25 16:59:47 +08:00
|
|
|
'use client'
|
2023-06-01 23:19:36 +08:00
|
|
|
import type { FC } from 'react'
|
|
|
|
import React from 'react'
|
2023-05-25 16:59:47 +08:00
|
|
|
import { useContext } from 'use-context-selector'
|
|
|
|
import ExploreContext from '@/context/explore-context'
|
|
|
|
import ChatApp from '@/app/components/share/chat'
|
|
|
|
import TextGenerationApp from '@/app/components/share/text-generation'
|
|
|
|
import Loading from '@/app/components/base/loading'
|
|
|
|
|
2023-06-01 23:19:36 +08:00
|
|
|
export type IInstalledAppProps = {
|
2023-05-25 16:59:47 +08:00
|
|
|
id: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const InstalledApp: FC<IInstalledAppProps> = ({
|
|
|
|
id,
|
|
|
|
}) => {
|
|
|
|
const { installedApps } = useContext(ExploreContext)
|
2023-06-01 23:19:36 +08:00
|
|
|
const installedApp = installedApps.find(item => item.id === id)
|
|
|
|
|
|
|
|
if (!installedApp) {
|
2023-05-25 16:59:47 +08:00
|
|
|
return (
|
|
|
|
<div className='flex h-full items-center'>
|
|
|
|
<Loading type='area' />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-06-01 23:19:36 +08:00
|
|
|
|
2023-05-25 16:59:47 +08:00
|
|
|
return (
|
2023-11-27 11:47:48 +08:00
|
|
|
<div className='h-full py-2 pl-0 pr-2 sm:p-2'>
|
2023-06-01 23:19:36 +08:00
|
|
|
{installedApp?.app.mode === 'chat'
|
|
|
|
? (
|
2023-07-07 17:50:42 +08:00
|
|
|
<ChatApp isInstalledApp installedAppInfo={installedApp} />
|
2023-06-01 23:19:36 +08:00
|
|
|
)
|
|
|
|
: (
|
|
|
|
<TextGenerationApp isInstalledApp installedAppInfo={installedApp}/>
|
|
|
|
)}
|
2023-05-25 16:59:47 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
export default React.memo(InstalledApp)
|