chore: remove unused code (#1989)

This commit is contained in:
crazywoola
2024-01-11 11:08:32 +08:00
committed by GitHub
parent f7939c758f
commit eed5fdd768
12 changed files with 7 additions and 298 deletions

View File

@@ -9,20 +9,17 @@ import { fetchAppDetail } from '@/service/apps'
type IDevelopMainProps = {
appId: string
dictionary: any
}
const DevelopMain = ({ appId, dictionary }: IDevelopMainProps) => {
const DevelopMain = ({ appId }: IDevelopMainProps) => {
const commonParams = { url: '/apps', id: appId }
const { data: appDetail } = useSWR(commonParams, fetchAppDetail)
const { t } = useTranslation()
// const serverApi = `${appDetail?.site?.app_base_url}/api/${appDetail?.site?.access_token}`
return (
<div className='relative flex flex-col h-full overflow-hidden'>
<div className='flex items-center justify-between flex-shrink-0 px-6 border-b border-solid py-2 border-b-gray-100'>
<div className='text-lg font-medium text-gray-900'>{dictionary.app?.develop?.title}</div>
<div className='text-lg font-medium text-gray-900'></div>
<div className='flex items-center flex-wrap gap-y-1'>
<InputCopy className='flex-shrink-0 mr-1 w-52 sm:w-80' value={appDetail?.api_base_url}>
<div className={`ml-2 border border-gray-200 border-solid flex-shrink-0 px-2 py-0.5 rounded-[6px] text-gray-500 text-[0.625rem] ${s.customApi}`}>

View File

@@ -1,7 +1,7 @@
import React from 'react'
import I18N from './i18n'
import { ToastProvider } from './base/toast'
import { getDictionary, getLocaleOnServer } from '@/i18n/server'
import { getLocaleOnServer } from '@/i18n/server'
export type II18NServerProps = {
children: React.ReactNode
@@ -11,10 +11,9 @@ const I18NServer = async ({
children,
}: II18NServerProps) => {
const locale = getLocaleOnServer()
const dictionary = await getDictionary(locale)
return (
<I18N {...{ locale, dictionary }}>
<I18N {...{ locale }}>
<ToastProvider>{children}</ToastProvider>
</I18N>
)

View File

@@ -9,12 +9,10 @@ import { setLocaleOnClient } from '@/i18n/client'
export type II18nProps = {
locale: Locale
dictionary: Record<string, any>
children: React.ReactNode
}
const I18n: FC<II18nProps> = ({
locale,
dictionary,
children,
}) => {
useEffect(() => {
@@ -24,7 +22,7 @@ const I18n: FC<II18nProps> = ({
return (
<I18NContext.Provider value={{
locale,
i18n: dictionary,
i18n: {},
setLocaleOnClient,
}}>
{children}

View File

@@ -1,79 +0,0 @@
'use client'
import React, { useState } from 'react'
import useSWR from 'swr'
import {
ChevronDownIcon,
ChevronUpIcon,
} from '@heroicons/react/24/outline'
import { fetchHistories } from '@/models/history'
import type { History as HistoryItem } from '@/models/history'
import Loading from '@/app/components/base/loading'
import { mockAPI } from '@/test/test_util'
mockAPI()
export type IHistoryProps = {
dictionary: any
}
const HistoryCard = (
{ history }: { history: HistoryItem },
) => {
return (
<div className='p-4 h-32 bg-gray-50 border-gray-200 rounded-lg relative flex flex-col justify-between items-center cursor-pointer'>
<div className='text-gray-700 text-sm'>
{history.source}
</div>
<div className="absolute inset-0 flex items-center m-4" aria-hidden="true">
<div className="w-full border-t border-gray-100" />
</div>
<div className='text-gray-700 text-sm'>
{history.target}
</div>
</div>
)
}
const History = ({
dictionary,
}: IHistoryProps) => {
const { data, error } = useSWR('http://localhost:3000/api/histories', fetchHistories)
const [showHistory, setShowHistory] = useState(false)
const DivideLine = () => {
return <div className="mt-6 relative">
{/* divider line */}
<div className="absolute inset-0 flex items-center" aria-hidden="true">
<div className="w-full border-t border-gray-300" />
</div>
<div className="relative flex justify-center flex-col items-center">
{!showHistory ? <ChevronUpIcon className="h-3 w-3 text-gray-500" aria-hidden="true" /> : <div className='h-3 w-3' />}
<span className="px-2 bg-white text-sm font-medium text-gray-600 cursor-pointer">{dictionary.app.textGeneration.history}</span>
{!showHistory ? <div className='h-3 w-3' /> : <ChevronDownIcon className="h-3 w-3 text-gray-500" aria-hidden="true" />}
</div>
</div>
}
if (error)
return <div>failed to load</div>
if (!data)
return <Loading />
return showHistory
? <div className='w-1/2 block fixed bottom-0 right-0 px-10 py-4' onClick={
() => setShowHistory(v => !v)
}>
<DivideLine />
<div
className='mt-4 grid grid-cols-3 space-x-4 h-[400px] overflow-auto'
>
{data.histories.map((item: HistoryItem) =>
<HistoryCard key={item.id} history={item} />)}
</div>
</div>
: <div className='w-1/2 block fixed bottom-0 right-0 px-10 py-4' onClick={
() => setShowHistory(true)
}>
<DivideLine />
</div>
}
export default History