import type { FC } from 'react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiDeleteBinLine, } from '@remixicon/react' import { Edit02 } from '@/app/components/base/icons/src/vender/line/general' import type { ApiBasedExtension } from '@/models/common' import { useModalContext } from '@/context/modal-context' import { deleteApiBasedExtension } from '@/service/common' import Confirm from '@/app/components/base/confirm' type ItemProps = { data: ApiBasedExtension onUpdate: () => void } const Item: FC = ({ data, onUpdate, }) => { const { t } = useTranslation() const { setShowApiBasedExtensionModal } = useModalContext() const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) const handleOpenApiBasedExtensionModal = () => { setShowApiBasedExtensionModal({ payload: data, onSaveCallback: () => onUpdate(), }) } const handleDeleteApiBasedExtension = async () => { await deleteApiBasedExtension(`/api-based-extension/${data.id}`) setShowDeleteConfirm(false) onUpdate() } return (
{data.name}
{data.api_endpoint}
{t('common.operation.edit')}
setShowDeleteConfirm(true)} >
{ showDeleteConfirm && setShowDeleteConfirm(false)} title={`${t('common.operation.delete')} “${data.name}”?`} onConfirm={handleDeleteApiBasedExtension} confirmText={t('common.operation.delete') || ''} /> }
) } export default Item