Add tool edit page

This commit is contained in:
2024-01-31 18:07:16 +08:00
parent d6ff952596
commit 28140543c4
11 changed files with 254 additions and 22 deletions

View File

@@ -25,6 +25,7 @@ interface CommonCardProps
onOpen?: () => void
onEdit?: () => void
onPublish?: () => void
onCancelReview?: () => void
onDelete?: () => void
}
@@ -46,6 +47,7 @@ const CommonCard = ({
onOpen,
onEdit,
onPublish,
onCancelReview,
onDelete,
children,
...props
@@ -80,14 +82,19 @@ const CommonCard = ({
</AntdButton>
)}
{onEdit && (
{onEdit && onPublish && (
<div className={'edit'}>
<AntdButton.Group size={'small'}>
<AntdButton onClick={onEdit}></AntdButton>
{onPublish && <AntdButton onClick={onPublish}></AntdButton>}
<AntdButton onClick={onPublish}></AntdButton>
</AntdButton.Group>
</div>
)}
{onCancelReview && (
<AntdButton size={'small'} onClick={onCancelReview}>
</AntdButton>
)}
{onDelete && (
<AntdButton size={'small'} danger onClick={onDelete}>
@@ -119,13 +126,21 @@ const ToolCard = ({ tools, onDelete, onUpgrade }: ToolCardProps) => {
}
const handleOnEditTool = () => {
if (selectedTool.publish === '0') {
return () => {}
if (selectedTool.publish === '0' && ['NONE', 'REJECT'].includes(selectedTool.review)) {
return () => {
navigate(`/edit/${tools[0].toolId}`)
}
}
}
const handleOnPublishTool = () => {
if (selectedTool.publish === '0') {
if (selectedTool.publish === '0' && ['NONE', 'REJECT'].includes(selectedTool.review)) {
return () => {}
}
}
const handleOnCancelReview = () => {
if (selectedTool.publish === '0' && selectedTool.review === 'PROCESSING') {
return () => {}
}
}
@@ -146,6 +161,7 @@ const ToolCard = ({ tools, onDelete, onUpgrade }: ToolCardProps) => {
onOpen={handleOnOpenTool}
onEdit={handleOnEditTool()}
onPublish={handleOnPublishTool()}
onCancelReview={handleOnCancelReview()}
onDelete={handleOnDeleteTool}
>
<AntdSelect