'use client' import type { FC } from 'react' import React from 'react' import { useContext } from 'use-context-selector' import cn from 'classnames' import { useTranslation } from 'react-i18next' import type { Collection } from '../types' import { CollectionType, LOC } from '../types' import { Settings01 } from '../../base/icons/src/vender/line/general' import I18n from '@/context/i18n' import { getLanguage } from '@/i18n/language' type Props = { icon: JSX.Element collection: Collection loc: LOC onShowAuth: () => void onShowEditCustomCollection: () => void } const Header: FC = ({ icon, collection, loc, onShowAuth, onShowEditCustomCollection, }) => { const { locale } = useContext(I18n) const language = getLanguage(locale) const { t } = useTranslation() const isInToolsPage = loc === LOC.tools const isInDebugPage = !isInToolsPage const needAuth = collection?.allow_delete || collection?.type === CollectionType.model const isAuthed = collection.is_team_authorization return (
{icon}
{collection.label[language]}
ยท
{t('tools.author')} {collection.author}
{collection.description && (
{collection.description[language]}
)}
{(collection.type === CollectionType.builtIn || collection.type === CollectionType.model) && needAuth && (
{ if (collection.type === CollectionType.builtIn || collection.type === CollectionType.model) onShowAuth() }} >
{t(`tools.auth.${isAuthed ? 'authorized' : 'unauthorized'}`)}
)} {collection.type === CollectionType.custom && (
onShowEditCustomCollection()} >
{t('tools.createTool.editAction')}
)}
) } export default React.memo(Header)