save logic
This commit is contained in:
parent
a00f7cb883
commit
746d3d4b10
|
|
@ -1,4 +1,8 @@
|
||||||
import type { Chain } from "@/entities/chain/schema";
|
import type { Chain } from "@/entities/chain/schema";
|
||||||
|
import { useChainState } from "@/entities/chain/model";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
import { upsertChain } from "@/entities/chain/api/upsert";
|
||||||
|
|
||||||
import { ActionEditor } from "@/widgets/action-editor";
|
import { ActionEditor } from "@/widgets/action-editor";
|
||||||
import { RenameChainButton } from "@/features/rename-chain";
|
import { RenameChainButton } from "@/features/rename-chain";
|
||||||
|
|
@ -6,12 +10,14 @@ import { DeleteChainButton } from "@/features/delete-chain";
|
||||||
|
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
import Breadcrumbs from "@mui/material/Breadcrumbs";
|
import Breadcrumbs from "@mui/material/Breadcrumbs";
|
||||||
|
|
||||||
interface ChainEditorProps {
|
interface ChainEditorProps {
|
||||||
chain: Chain;
|
chain: Chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ChainEditor({ chain }: ChainEditorProps) {
|
export default function ChainEditor({ chain }: ChainEditorProps) {
|
||||||
|
const navigate = useNavigate({ from: "/$namespace/$chainId" });
|
||||||
|
const addCommentAction = useChainState((state) => state.addCommentAction);
|
||||||
|
|
||||||
if (!chain.actions || chain.actions.length === 0)
|
if (!chain.actions || chain.actions.length === 0)
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col">
|
<div className="flex h-full flex-col">
|
||||||
|
|
@ -40,7 +46,13 @@ export default function ChainEditor({ chain }: ChainEditorProps) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex grow flex-col items-center justify-center">
|
<div className="flex grow flex-col items-center justify-center">
|
||||||
<ActionEditor />
|
<ActionEditor
|
||||||
|
onSave={async (_, action) => {
|
||||||
|
addCommentAction(chain._id!, action);
|
||||||
|
await upsertChain(chain);
|
||||||
|
navigate({ to: "/$namespace/$chainId" });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user