save logic
This commit is contained in:
parent
a00f7cb883
commit
746d3d4b10
|
|
@ -1,4 +1,8 @@
|
|||
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 { RenameChainButton } from "@/features/rename-chain";
|
||||
|
|
@ -6,12 +10,14 @@ import { DeleteChainButton } from "@/features/delete-chain";
|
|||
|
||||
import { Typography } from "@mui/material";
|
||||
import Breadcrumbs from "@mui/material/Breadcrumbs";
|
||||
|
||||
interface ChainEditorProps {
|
||||
chain: Chain;
|
||||
}
|
||||
|
||||
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)
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
|
|
@ -40,7 +46,13 @@ export default function ChainEditor({ chain }: ChainEditorProps) {
|
|||
</div>
|
||||
|
||||
<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>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user