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