增加修改Scheme描述的功能。
This commit is contained in:
parent
24786d5542
commit
59bb1352d7
|
@ -1,6 +1,7 @@
|
|||
import { isNil, set } from 'lodash-es';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { EditableDescription } from '../components/EditableDescription';
|
||||
import { EditableTitle } from '../components/EditableTitle';
|
||||
import { useScheme, useUpdateScheme } from '../stores/schemes';
|
||||
import styles from './SchemeDetail.module.css';
|
||||
|
@ -20,6 +21,15 @@ export function SchemeDetail() {
|
|||
},
|
||||
[id],
|
||||
);
|
||||
const updateDescription = useCallback(
|
||||
(newDescription: string | null) => {
|
||||
updateScheme((prev) => {
|
||||
set(prev, 'description', newDescription);
|
||||
return prev;
|
||||
});
|
||||
},
|
||||
[id],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isNil(scheme)) {
|
||||
|
@ -30,7 +40,7 @@ export function SchemeDetail() {
|
|||
return (
|
||||
<div className={styles.scheme_detail_layout}>
|
||||
<EditableTitle title={scheme?.name} onChange={updateTitle} />
|
||||
<p>{scheme?.description}</p>
|
||||
<EditableDescription content={scheme?.description} onChange={updateDescription} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user