'use client' import { RiCloseLine } from '@remixicon/react' import { noop } from 'es-toolkit/function' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import Button from '@/app/components/base/button' import Input from '@/app/components/base/input' import Modal from '@/app/components/base/modal' import { ToastContext } from '@/app/components/base/toast' import { useAppContext } from '@/context/app-context' import { updateWorkspaceInfo } from '@/service/common' import { cn } from '@/utils/classnames' import s from './index.module.css' type IEditWorkspaceModalProps = { onCancel: () => void } const EditWorkspaceModal = ({ onCancel, }: IEditWorkspaceModalProps) => { const { t } = useTranslation() const { notify } = useContext(ToastContext) const { currentWorkspace, isCurrentWorkspaceOwner } = useAppContext() const [name, setName] = useState(currentWorkspace.name) const changeWorkspaceInfo = async (name: string) => { try { await updateWorkspaceInfo({ url: '/workspaces/info', body: { name, }, }) notify({ type: 'success', message: t('actionMsg.modifiedSuccessfully', { ns: 'common' }) }) location.assign(`${location.origin}`) } catch { notify({ type: 'error', message: t('actionMsg.modifiedUnsuccessfully', { ns: 'common' }) }) } } return (
{t('account.editWorkspaceInfo', { ns: 'common' })}
{t('account.workspaceName', { ns: 'common' })}
{ setName(e.target.value) }} onClear={() => { setName(currentWorkspace.name) }} />
) } export default EditWorkspaceModal