mirror of
https://github.com/outline/outline.git
synced 2026-11-29 16:40:27 +03:00
31 lines
686 B
TypeScript
31 lines
686 B
TypeScript
import { observer } from "mobx-react";
|
|
import { useCallback } from "react";
|
|
import { toast } from "sonner";
|
|
import { TemplateForm } from "./TemplateForm";
|
|
import type Template from "~/models/Template";
|
|
|
|
type Props = {
|
|
template: Template;
|
|
onSubmit: () => void;
|
|
};
|
|
|
|
export const TemplateEdit = observer(function TemplateEdit_({
|
|
template,
|
|
onSubmit,
|
|
}: Props) {
|
|
const handleSubmit = useCallback(async () => {
|
|
try {
|
|
await template?.save();
|
|
onSubmit?.();
|
|
} catch (error) {
|
|
toast.error(error.message);
|
|
}
|
|
}, [template, onSubmit]);
|
|
|
|
if (!template) {
|
|
return null;
|
|
}
|
|
|
|
return <TemplateForm template={template} handleSubmit={handleSubmit} />;
|
|
});
|