fix(client): only template creator can edit

This commit is contained in:
fantasticit 2022-02-21 09:05:27 +08:00
parent 41558d6ca8
commit 004236e12f
1 changed files with 14 additions and 10 deletions

View File

@ -14,6 +14,7 @@ import {
import { IconEdit, IconUser, IconPlus } from "@douyinfe/semi-icons"; import { IconEdit, IconUser, IconPlus } from "@douyinfe/semi-icons";
import { IconDocument } from "components/icons/IconDocument"; import { IconDocument } from "components/icons/IconDocument";
import { TemplateReader } from "components/template/reader"; import { TemplateReader } from "components/template/reader";
import { useUser } from "data/user";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
@ -34,6 +35,7 @@ export const TemplateCard: React.FC<IProps> = ({
onOpenPreview, onOpenPreview,
onClosePreview, onClosePreview,
}) => { }) => {
const { user } = useUser();
const [visible, toggleVisible] = useToggle(false); const [visible, toggleVisible] = useToggle(false);
const gotoEdit = useCallback(() => { const gotoEdit = useCallback(() => {
@ -63,8 +65,9 @@ export const TemplateCard: React.FC<IProps> = ({
<header> <header>
<IconDocument /> <IconDocument />
<div className={styles.rightWrap}> <div className={styles.rightWrap}>
{template.createUser && user && template.createUser.id === user.id && (
<Space> <Space>
<Tooltip key="edit" content="编辑" position="bottom"> <Tooltip key="edit" content="编辑模板" position="bottom">
<Button <Button
type="tertiary" type="tertiary"
theme="borderless" theme="borderless"
@ -73,6 +76,7 @@ export const TemplateCard: React.FC<IProps> = ({
/> />
</Tooltip> </Tooltip>
</Space> </Space>
)}
</div> </div>
</header> </header>
<main> <main>