From bf83bf99b3efea1fcab218345a23fcf96cb634d8 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 18 Apr 2024 17:01:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(app-impress)=20create=20Temp?= =?UTF-8?q?lateTools=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A component that will be used to display the tools for the template editor. --- .../template/components/TemplateEditor.tsx | 48 +++------------- .../template/components/TemplateTools.tsx | 56 +++++++++++++++++++ 2 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 src/frontend/apps/impress/src/features/templates/template/components/TemplateTools.tsx diff --git a/src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx b/src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx index 2757ab1d..45a72da1 100644 --- a/src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx +++ b/src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx @@ -1,35 +1,23 @@ import GjsEditor from '@grapesjs/react'; -import { - Alert, - Button, - VariantType, - useToastProvider, -} from '@openfun/cunningham-react'; +import { Alert, VariantType } from '@openfun/cunningham-react'; import grapesjs, { Editor, ProjectData } from 'grapesjs'; import 'grapesjs/dist/css/grapes.min.css'; import pluginBlocksBasic from 'grapesjs-blocks-basic'; import { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { Box, Text } from '@/components'; +import { Box } from '@/components'; -import { useUpdateTemplate } from '../api/useUpdateTemplate'; import { useUpdateTemplateCodeEditor } from '../api/useUpdateTemplateCodeEditor'; import { Template } from '../types'; +import { TemplateTools } from './TemplateTools'; + interface TemplateEditorProps { template: Template; } export const TemplateEditor = ({ template }: TemplateEditorProps) => { - const { t } = useTranslation(); - const { toast } = useToastProvider(); const { mutate: updateCodeEditor } = useUpdateTemplateCodeEditor(); - const { mutate: updateTemplate } = useUpdateTemplate({ - onSuccess: () => { - toast(t('Template save successfully'), VariantType.SUCCESS); - }, - }); const [editor, setEditor] = useState(); const html = editor?.getHtml(); @@ -83,29 +71,11 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => { return ( <> - - - {template.title} - - - + { + const { t } = useTranslation(); + const { toast } = useToastProvider(); + const { mutate: updateTemplate } = useUpdateTemplate({ + onSuccess: () => { + toast(t('Template save successfully'), VariantType.SUCCESS); + }, + }); + + return ( + + + {template.title} + + + + ); +};