diff --git a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts
deleted file mode 100644
index 0a8f95dc..00000000
--- a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts
+++ /dev/null
@@ -1,174 +0,0 @@
-import { expect, test } from '@playwright/test';
-
-import { createTemplate, keyCloakSignIn } from './common';
-
-test.beforeEach(async ({ page, browserName }) => {
- await page.goto('/');
- await keyCloakSignIn(page, browserName);
-});
-
-test.describe('Template Editor', () => {
- test('checks the template editor interact correctly', async ({
- page,
- browserName,
- }) => {
- const randomTemplate = await createTemplate(
- page,
- 'template-editor',
- browserName,
- 1,
- );
-
- await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible();
-
- await page.getByTitle('Open Blocks').click();
- await expect(
- page.locator('.gjs-editor .gjs-block[title="Text"]'),
- ).toBeVisible();
- });
-
- test('checks the template editor save on changed', async ({
- page,
- browserName,
- }) => {
- // eslint-disable-next-line playwright/no-skipped-test
- test.skip(
- browserName !== 'chromium',
- 'This test failed with safary because of the dragNdrop',
- );
-
- const randomTemplate = await createTemplate(
- page,
- 'template-editor',
- browserName,
- 1,
- );
-
- await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible();
-
- const iframe = page.frameLocator('iFrame.gjs-frame');
-
- await page.getByTitle('Open Blocks').click();
- await page
- .locator('.gjs-editor .gjs-block[title="Text"]')
- .dragTo(iframe.locator('body.gjs-dashed'));
-
- await iframe.getByText('Insert your text here').fill('Hello World');
- await iframe.locator('body.gjs-dashed').click();
-
- // Come on the page again to check the changes are saved
- await page.locator('menu').first().getByLabel(`Template button`).click();
- const panel = page.getByLabel('Templates panel').first();
- await panel.locator('li').getByText(randomTemplate[0]).click();
-
- await expect(iframe.getByText('Hello World')).toBeVisible({
- timeout: 5000,
- });
- });
-
- test('it saves the html generated by the template', async ({
- page,
- browserName,
- }) => {
- // eslint-disable-next-line playwright/no-skipped-test
- test.skip(
- browserName !== 'chromium',
- 'This test failed with safary because of the dragNdrop',
- );
-
- const randomTemplate = await createTemplate(
- page,
- 'template-html',
- browserName,
- 1,
- );
-
- await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible();
-
- const iframe = page.frameLocator('iFrame.gjs-frame');
-
- await page.getByTitle('Open Blocks').click();
- await page
- .locator('.gjs-editor .gjs-block[title="Text"]')
- .dragTo(iframe.locator('body.gjs-dashed'));
-
- await iframe.getByText('Insert your text here').fill('Hello World');
- await iframe.locator('body.gjs-dashed').click();
-
- await page.getByText('Save template').click();
- await expect(page.getByText('Template save successfully')).toBeVisible();
- });
-
- test('it shows a warning if body tag not present', async ({
- page,
- browserName,
- }) => {
- // eslint-disable-next-line playwright/no-skipped-test
- test.skip(
- browserName !== 'chromium',
- 'This test failed with safary because of the dragNdrop',
- );
-
- const randomTemplate = await createTemplate(
- page,
- 'template-html',
- browserName,
- 1,
- );
-
- await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible();
-
- await expect(
- page.getByText('The {{body}} tag is necessary to works with the pads.'),
- ).toBeVisible();
-
- const iframe = page.frameLocator('iFrame.gjs-frame');
-
- await page.getByTitle('Open Blocks').click();
- await page
- .locator('.gjs-editor .gjs-block[title="Text"]')
- .dragTo(iframe.locator('body.gjs-dashed'));
-
- await iframe.getByText('Insert your text here').fill('{{body}}');
- await iframe.locator('body.gjs-dashed').click();
-
- await expect(
- page.getByText('The {{body}} tag is necessary to works with the pads.'),
- ).toBeHidden();
- });
-
- test('it duplicates the template', async ({ page, browserName }) => {
- // eslint-disable-next-line playwright/no-skipped-test
- test.skip(
- browserName !== 'chromium',
- 'This test failed with safary because of the dragNdrop',
- );
-
- const randomTemplate = await createTemplate(
- page,
- 'template-duplicate',
- browserName,
- 1,
- );
-
- await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible();
-
- const iframe = page.frameLocator('iFrame.gjs-frame');
-
- await page.getByTitle('Open Blocks').click();
- await page
- .locator('.gjs-editor .gjs-block[title="Text"]')
- .dragTo(iframe.locator('body.gjs-dashed'));
-
- await iframe.getByText('Insert your text here').fill('Hello World');
- await iframe.locator('body.gjs-dashed').click();
-
- await page.getByText('Duplicate template').click();
-
- await expect(
- page.getByText('Template duplicated successfully'),
- ).toBeVisible();
- const panel = page.getByLabel('Templates panel').first();
- await expect(panel.getByText(`${randomTemplate[0]} - Copy`)).toBeVisible();
- });
-});
diff --git a/src/frontend/apps/impress/package.json b/src/frontend/apps/impress/package.json
index 6d49825c..7fdb1990 100644
--- a/src/frontend/apps/impress/package.json
+++ b/src/frontend/apps/impress/package.json
@@ -35,7 +35,6 @@
"zustand": "4.5.2"
},
"devDependencies": {
- "@grapesjs/react": "1.0.0",
"@svgr/webpack": "8.1.0",
"@tanstack/react-query-devtools": "5.32.0",
"@testing-library/jest-dom": "6.4.2",
diff --git a/src/frontend/apps/impress/src/features/menu/Menu.tsx b/src/frontend/apps/impress/src/features/menu/Menu.tsx
index ffa42004..8ab3ed03 100644
--- a/src/frontend/apps/impress/src/features/menu/Menu.tsx
+++ b/src/frontend/apps/impress/src/features/menu/Menu.tsx
@@ -6,7 +6,6 @@ import useCunninghamTheme from '@/cunningham/useCunninghamTheme';
import MenuItem from './MenuItems';
import IconPad from './assets/icon-pad.svg';
-import IconTemplate from './assets/icon-template.svg';
export const Menu = () => {
const { colorsTokens } = useCunninghamTheme();
@@ -22,11 +21,6 @@ export const Menu = () => {
>
-
);
diff --git a/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg b/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg
deleted file mode 100644
index f7b184d7..00000000
--- a/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg
+++ /dev/null
@@ -1,20 +0,0 @@
-
diff --git a/src/frontend/apps/impress/src/features/templates/index.ts b/src/frontend/apps/impress/src/features/templates/index.ts
deleted file mode 100644
index 2abeb7e5..00000000
--- a/src/frontend/apps/impress/src/features/templates/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './template';
-export * from './template-create';
-export * from './template-panel';
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts b/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts
deleted file mode 100644
index f0040687..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './useCreateTemplate';
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx
deleted file mode 100644
index 4bccc8ea..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useMutation, useQueryClient } from '@tanstack/react-query';
-
-import { APIError, errorCauses, fetchAPI } from '@/api';
-import { KEY_LIST_TEMPLATE, Template } from '@/features/templates';
-
-type CreateTemplateParam = Partial;
-
-export const createTemplate = async (
- props: CreateTemplateParam,
-): Promise => {
- const response = await fetchAPI(`templates/`, {
- method: 'POST',
- body: JSON.stringify(props),
- });
-
- if (!response.ok) {
- throw new APIError(
- 'Failed to create the template',
- await errorCauses(response),
- );
- }
-
- return response.json() as Promise;
-};
-
-interface CreateTemplateProps {
- onSuccess: (data: Template) => void;
-}
-
-export function useCreateTemplate({ onSuccess }: CreateTemplateProps) {
- const queryClient = useQueryClient();
- return useMutation({
- mutationFn: createTemplate,
- onSuccess: (data) => {
- void queryClient.invalidateQueries({
- queryKey: [KEY_LIST_TEMPLATE],
- });
- onSuccess(data);
- },
- });
-}
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/components/CardCreateTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template-create/components/CardCreateTemplate.tsx
deleted file mode 100644
index 17e3b336..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/components/CardCreateTemplate.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { Button, Switch } from '@openfun/cunningham-react';
-import { useRouter } from 'next/navigation';
-import { useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import IconGroup from '@/assets/icons/icon-group2.svg';
-import { Box, Card, StyledLink, Text } from '@/components';
-import { useCunninghamTheme } from '@/cunningham';
-
-import { useCreateTemplate } from '../api/useCreateTemplate';
-
-import { InputTemplateName } from './InputTemplateName';
-
-export const CardCreateTemplate = () => {
- const { t } = useTranslation();
- const router = useRouter();
- const {
- mutate: createTemplate,
- isError,
- isPending,
- error,
- } = useCreateTemplate({
- onSuccess: (pad) => {
- router.push(`/templates/${pad.id}`);
- },
- });
- const [templateName, setTemplateName] = useState('');
- const [templatePublic, setTemplatePublic] = useState(false);
- const { colorsTokens } = useCunninghamTheme();
-
- return (
-
-
-
-
-
- {t('Name the template')}
-
-
-
- setTemplatePublic(!templatePublic)}
- />
-
-
-
-
-
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/components/InputTemplateName.tsx b/src/frontend/apps/impress/src/features/templates/template-create/components/InputTemplateName.tsx
deleted file mode 100644
index 71d80b38..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/components/InputTemplateName.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Input, Loader } from '@openfun/cunningham-react';
-import { useEffect, useState } from 'react';
-
-import { APIError } from '@/api';
-import { Box, TextErrors } from '@/components';
-
-interface InputTemplateNameProps {
- error: APIError | null;
- isError: boolean;
- isPending: boolean;
- label: string;
- setTemplateName: (newTemplateName: string) => void;
- defaultValue?: string;
-}
-
-export const InputTemplateName = ({
- defaultValue,
- error,
- isError,
- isPending,
- label,
- setTemplateName,
-}: InputTemplateNameProps) => {
- const [isInputError, setIsInputError] = useState(isError);
-
- useEffect(() => {
- if (isError) {
- setIsInputError(true);
- }
- }, [isError]);
-
- return (
- <>
- {
- setTemplateName(e.target.value);
- setIsInputError(false);
- }}
- rightIcon={edit}
- state={isInputError ? 'error' : 'default'}
- />
- {isError && error && }
- {isPending && (
-
-
-
- )}
- >
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/components/index.ts b/src/frontend/apps/impress/src/features/templates/template-create/components/index.ts
deleted file mode 100644
index 8a738338..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './CardCreateTemplate';
diff --git a/src/frontend/apps/impress/src/features/templates/template-create/index.ts b/src/frontend/apps/impress/src/features/templates/template-create/index.ts
deleted file mode 100644
index 3d5bec67..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-create/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './components';
-export * from './api';
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/__tests__/PanelTemplates.test.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/__tests__/PanelTemplates.test.tsx
deleted file mode 100644
index 443449d1..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/__tests__/PanelTemplates.test.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import '@testing-library/jest-dom';
-import { render, screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import fetchMock from 'fetch-mock';
-
-import { AppWrapper } from '@/tests/utils';
-
-import { Panel } from '../components/Panel';
-import { TemplateList } from '../components/TemplateList';
-
-window.HTMLElement.prototype.scroll = function () {};
-
-jest.mock('next/router', () => ({
- ...jest.requireActual('next/router'),
- useRouter: () => ({
- query: {},
- }),
-}));
-
-describe('PanelTemplates', () => {
- afterEach(() => {
- fetchMock.restore();
- });
-
- it('renders with no template to display', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 0,
- results: [],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(screen.getByRole('status')).toBeInTheDocument();
-
- expect(
- await screen.findByText(
- 'Create your first template by clicking on the "Create a new template" button.',
- ),
- ).toBeInTheDocument();
- });
-
- it('renders an empty template', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 1,
- results: [
- {
- id: '1',
- name: 'Template 1',
- accesses: [],
- },
- ],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(screen.getByRole('status')).toBeInTheDocument();
-
- expect(
- await screen.findByLabelText('Empty templates icon'),
- ).toBeInTheDocument();
- });
-
- it('renders a template with only 1 member', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 1,
- results: [
- {
- id: '1',
- name: 'Template 1',
- accesses: [
- {
- id: '1',
- role: 'owner',
- },
- ],
- },
- ],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(screen.getByRole('status')).toBeInTheDocument();
-
- expect(
- await screen.findByLabelText('Empty templates icon'),
- ).toBeInTheDocument();
- });
-
- it('renders a non-empty template', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 1,
- results: [
- {
- id: '1',
- name: 'Template 1',
- accesses: [
- {
- id: '1',
- role: 'admin',
- },
- {
- id: '2',
- role: 'member',
- },
- ],
- },
- ],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(screen.getByRole('status')).toBeInTheDocument();
-
- expect(await screen.findByLabelText('Templates icon')).toBeInTheDocument();
- });
-
- it('renders the error', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- status: 500,
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(screen.getByRole('status')).toBeInTheDocument();
-
- expect(
- await screen.findByText(
- 'Something bad happens, please refresh the page.',
- ),
- ).toBeInTheDocument();
- });
-
- it('renders with template panel open', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 1,
- results: [],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(
- screen.getByRole('button', { name: 'Close the templates panel' }),
- ).toBeVisible();
-
- expect(await screen.findByText('Recents')).toBeVisible();
- });
-
- it('closes and opens the template panel', async () => {
- fetchMock.mock(`/api/templates/?page=1&ordering=-created_at`, {
- count: 1,
- results: [],
- });
-
- render(, { wrapper: AppWrapper });
-
- expect(await screen.findByText('Recents')).toBeVisible();
-
- await userEvent.click(
- screen.getByRole('button', {
- name: 'Close the templates panel',
- }),
- );
-
- expect(await screen.findByText('Recents')).not.toBeVisible();
-
- await userEvent.click(
- screen.getByRole('button', {
- name: 'Open the templates panel',
- }),
- );
-
- expect(await screen.findByText('Recents')).toBeVisible();
- });
-});
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/api/index.ts b/src/frontend/apps/impress/src/features/templates/template-panel/api/index.ts
deleted file mode 100644
index ba0d606e..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/api/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './useTemplates';
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-add.svg b/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-add.svg
deleted file mode 100644
index a198da2b..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-add.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-none.svg b/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-none.svg
deleted file mode 100644
index 9f80850e..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-none.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-open-close.svg b/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-open-close.svg
deleted file mode 100644
index b894e495..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-open-close.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-sort.svg b/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-sort.svg
deleted file mode 100644
index ac4565d3..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-sort.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/components/Panel.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/components/Panel.tsx
deleted file mode 100644
index 0b88a280..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/components/Panel.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import React, { useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { Box, BoxButton, Text } from '@/components';
-import { useCunninghamTheme } from '@/cunningham';
-
-import IconOpenClose from '../assets/icon-open-close.svg';
-
-import { PanelActions } from './PanelActions';
-import { TemplateList } from './TemplateList';
-
-export const Panel = () => {
- const { t } = useTranslation();
- const { colorsTokens } = useCunninghamTheme();
-
- const [isOpen, setIsOpen] = useState(true);
-
- const closedOverridingStyles = !isOpen && {
- $width: '0',
- $maxWidth: '0',
- $minWidth: '0',
- };
-
- const transition = 'all 0.5s ease-in-out';
-
- return (
-
- setIsOpen(!isOpen)}
- >
-
-
-
-
-
- {t('Recents')}
-
-
-
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/components/PanelActions.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/components/PanelActions.tsx
deleted file mode 100644
index fe24234b..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/components/PanelActions.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import React from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { Box, BoxButton, StyledLink } from '@/components';
-import { useCunninghamTheme } from '@/cunningham';
-
-import { TemplatesOrdering } from '../api';
-import IconAdd from '../assets/icon-add.svg';
-import IconSort from '../assets/icon-sort.svg';
-import { useTemplatePanelStore } from '../store';
-
-export const PanelActions = () => {
- const { t } = useTranslation();
- const { changeOrdering, ordering } = useTemplatePanelStore();
- const { colorsTokens } = useCunninghamTheme();
-
- const isSortAsc = ordering === TemplatesOrdering.BY_CREATED_ON;
-
- return (
-
-
-
-
-
-
-
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateItem.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateItem.tsx
deleted file mode 100644
index 048650a1..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateItem.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { useRouter } from 'next/router';
-import React from 'react';
-import { useTranslation } from 'react-i18next';
-
-import IconGroup from '@/assets/icons/icon-group.svg';
-import { Box, StyledLink, Text } from '@/components';
-import { useCunninghamTheme } from '@/cunningham';
-import { Template } from '@/features/templates/template';
-
-import IconNone from '../assets/icon-none.svg';
-
-interface TemplateItemProps {
- template: Template;
-}
-
-export const TemplateItem = ({ template }: TemplateItemProps) => {
- const { t } = useTranslation();
- const { colorsTokens } = useCunninghamTheme();
- const {
- query: { id },
- } = useRouter();
-
- // There is at least 1 owner in the team
- const hasMembers = template.accesses.length > 1;
- const isActive = template.id === id;
-
- const commonProps = {
- className: 'p-t',
- width: 52,
- style: {
- borderRadius: '10px',
- flexShrink: 0,
- background: '#fff',
- },
- };
-
- const activeStyle = `
- border-right: 4px solid ${colorsTokens()['primary-600']};
- background: ${colorsTokens()['primary-400']};
- span{
- color: ${colorsTokens()['primary-text']};
- }
- `;
-
- const hoverStyle = `
- &:hover{
- border-right: 4px solid ${colorsTokens()['primary-400']};
- background: ${colorsTokens()['primary-300']};
-
- span{
- color: ${colorsTokens()['primary-text']};
- }
- }
- `;
-
- return (
-
-
-
- {hasMembers ? (
-
- ) : (
-
- )}
-
- {template.title}
-
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateList.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateList.tsx
deleted file mode 100644
index 05e51224..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateList.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import { Loader } from '@openfun/cunningham-react';
-import React, { useMemo, useRef } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { Box, Text } from '@/components';
-import { InfiniteScroll } from '@/components/InfiniteScroll';
-import { Template } from '@/features/templates/template';
-
-import { useTemplates } from '../api';
-import { useTemplatePanelStore } from '../store';
-
-import { TemplateItem } from './TemplateItem';
-
-interface PanelTeamsStateProps {
- isLoading: boolean;
- isError: boolean;
- templates?: Template[];
-}
-
-const TemplateListState = ({
- isLoading,
- isError,
- templates,
-}: PanelTeamsStateProps) => {
- const { t } = useTranslation();
-
- if (isError) {
- return (
-
-
- {t('Something bad happens, please refresh the page.')}
-
-
- );
- }
-
- if (isLoading) {
- return (
-
-
-
- );
- }
-
- if (!templates?.length) {
- return (
-
-
- {t('0 group to display.')}
-
-
- {t(
- 'Create your first template by clicking on the "Create a new template" button.',
- )}
-
-
- );
- }
-
- return templates.map((template) => (
-
- ));
-};
-
-export const TemplateList = () => {
- const ordering = useTemplatePanelStore((state) => state.ordering);
- const {
- data,
- isError,
- isLoading,
- fetchNextPage,
- hasNextPage,
- isFetchingNextPage,
- } = useTemplates({
- ordering,
- });
- const containerRef = useRef(null);
- const templates = useMemo(() => {
- return data?.pages.reduce((acc, page) => {
- return acc.concat(page.results);
- }, [] as Template[]);
- }, [data?.pages]);
-
- return (
-
- {
- void fetchNextPage();
- }}
- scrollContainer={containerRef.current}
- as="ul"
- className="p-0 mt-0"
- role="listbox"
- >
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/components/index.ts b/src/frontend/apps/impress/src/features/templates/template-panel/components/index.ts
deleted file mode 100644
index 8960d84f..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Panel';
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/index.ts b/src/frontend/apps/impress/src/features/templates/template-panel/index.ts
deleted file mode 100644
index 0ef46430..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './api';
-export * from './components';
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/store/index.ts b/src/frontend/apps/impress/src/features/templates/template-panel/store/index.ts
deleted file mode 100644
index 6763d4de..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/store/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './useTemplatePanelStore';
diff --git a/src/frontend/apps/impress/src/features/templates/template-panel/store/useTemplatePanelStore.tsx b/src/frontend/apps/impress/src/features/templates/template-panel/store/useTemplatePanelStore.tsx
deleted file mode 100644
index 93bca4bd..00000000
--- a/src/frontend/apps/impress/src/features/templates/template-panel/store/useTemplatePanelStore.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { create } from 'zustand';
-
-import { TemplatesOrdering } from '../api/useTemplates';
-
-interface TemplatePanelStore {
- ordering: TemplatesOrdering;
- changeOrdering: () => void;
-}
-
-export const useTemplatePanelStore = create((set) => ({
- ordering: TemplatesOrdering.BY_CREATED_ON_DESC,
- changeOrdering: () =>
- set(({ ordering }) => ({
- ordering:
- ordering === TemplatesOrdering.BY_CREATED_ON
- ? TemplatesOrdering.BY_CREATED_ON_DESC
- : TemplatesOrdering.BY_CREATED_ON,
- })),
-}));
diff --git a/src/frontend/apps/impress/src/features/templates/template/api/index.ts b/src/frontend/apps/impress/src/features/templates/template/api/index.ts
deleted file mode 100644
index a46362ff..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/api/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './useTemplate';
diff --git a/src/frontend/apps/impress/src/features/templates/template/api/useTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template/api/useTemplate.tsx
deleted file mode 100644
index 79434d4f..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/api/useTemplate.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { UseQueryOptions, useQuery } from '@tanstack/react-query';
-
-import { APIError, errorCauses, fetchAPI } from '@/api';
-
-import { Template } from '../types';
-
-export type TemplateParams = {
- id: string;
-};
-
-export const getTemplate = async ({
- id,
-}: TemplateParams): Promise => {
- const response = await fetchAPI(`templates/${id}`);
-
- if (!response.ok) {
- throw new APIError(
- 'Failed to get the template',
- await errorCauses(response),
- );
- }
-
- return response.json() as Promise;
-};
-
-export const KEY_TEMPLATE = 'template';
-
-export function useTemplate(
- param: TemplateParams,
- queryConfig?: UseQueryOptions,
-) {
- return useQuery({
- queryKey: [KEY_TEMPLATE, param],
- queryFn: () => getTemplate(param),
- ...queryConfig,
- });
-}
diff --git a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx
deleted file mode 100644
index 8e833410..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { useMutation, useQueryClient } from '@tanstack/react-query';
-
-import { APIError, errorCauses, fetchAPI } from '@/api';
-
-import { KEY_LIST_TEMPLATE } from '../../template-panel';
-import { Template } from '../types';
-
-import { KEY_TEMPLATE } from './useTemplate';
-
-type UpdateTemplateProps = {
- id: Template['id'];
- css?: string;
- html?: string;
- title?: Template['title'];
-};
-
-export const updateTemplate = async ({
- id,
- title,
- css,
- html,
-}: UpdateTemplateProps): Promise => {
- const response = await fetchAPI(`templates/${id}/`, {
- method: 'PATCH',
- body: JSON.stringify({
- title,
- css,
- code: html,
- }),
- });
-
- if (!response.ok) {
- throw new APIError(
- 'Failed to update the template',
- await errorCauses(response),
- );
- }
-
- return response.json() as Promise;
-};
-
-interface UseUpdateTemplateProps {
- onSuccess: (data: Template) => void;
-}
-
-export function useUpdateTemplate({ onSuccess }: UseUpdateTemplateProps) {
- const queryClient = useQueryClient();
- return useMutation({
- mutationFn: updateTemplate,
- onSuccess: (data) => {
- void queryClient.invalidateQueries({
- queryKey: [KEY_LIST_TEMPLATE],
- });
- void queryClient.invalidateQueries({
- queryKey: [KEY_TEMPLATE],
- });
- onSuccess(data);
- },
- });
-}
diff --git a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplateCodeEditor.tsx b/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplateCodeEditor.tsx
deleted file mode 100644
index 520ae8eb..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplateCodeEditor.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useMutation } from '@tanstack/react-query';
-
-import { APIError, errorCauses, fetchAPI } from '@/api';
-
-import { Template } from '../types';
-
-type UpdateTemplateProps = Pick;
-
-export const updateTemplateCodeEditor = async ({
- code_editor,
- id,
-}: UpdateTemplateProps): Promise => {
- const response = await fetchAPI(`templates/${id}/`, {
- method: 'PATCH',
- body: JSON.stringify({
- code_editor,
- }),
- });
-
- if (!response.ok) {
- throw new APIError(
- 'Failed to update the template',
- await errorCauses(response),
- );
- }
-
- return response.json() as Promise;
-};
-
-export function useUpdateTemplateCodeEditor(
- onSuccess?: (data: Template) => void,
-) {
- return useMutation({
- mutationFn: updateTemplateCodeEditor,
- onSuccess: (data) => {
- onSuccess?.(data);
- },
- });
-}
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
deleted file mode 100644
index 45a72da1..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import GjsEditor from '@grapesjs/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 { Box } from '@/components';
-
-import { useUpdateTemplateCodeEditor } from '../api/useUpdateTemplateCodeEditor';
-import { Template } from '../types';
-
-import { TemplateTools } from './TemplateTools';
-
-interface TemplateEditorProps {
- template: Template;
-}
-
-export const TemplateEditor = ({ template }: TemplateEditorProps) => {
- const { mutate: updateCodeEditor } = useUpdateTemplateCodeEditor();
- const [editor, setEditor] = useState();
- const html = editor?.getHtml();
-
- const [showWarning, setShowWarning] = useState(!!html);
-
- useEffect(() => {
- if (!html) {
- return;
- }
-
- setShowWarning(!html.includes('{{body}}'));
- }, [html]);
-
- useEffect(() => {
- if (!editor?.loadProjectData || !editor?.Storage) {
- return;
- }
-
- const projectData = Object.keys(template.code_editor).length
- ? template.code_editor
- : editor.getProjectData();
-
- editor?.loadProjectData(projectData);
-
- editor.Storage.add('remote', {
- load() {
- return Promise.resolve(projectData);
- },
- store(data: ProjectData) {
- updateCodeEditor({
- code_editor: data,
- id: template.id,
- });
- return Promise.resolve();
- },
- });
- }, [editor, template.code_editor, template.id, updateCodeEditor]);
-
- const onEditor = (editor: Editor) => {
- setEditor(editor);
-
- editor?.Storage.add('remote', {
- load() {
- return Promise.resolve(editor.getProjectData());
- },
- store() {
- return Promise.resolve();
- },
- });
- };
-
- return (
- <>
-
-
- {`The {{body}} tag is necessary to works with the pads.`}
-
-
- {!template.abilities.partial_update && (
-
- {`Read only, you don't have the right to update this template.`}
-
- )}
-
-
- pluginBlocksBasic(editor, {})]}
- onEditor={onEditor}
- />
-
- >
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template/components/TemplateTools.tsx b/src/frontend/apps/impress/src/features/templates/template/components/TemplateTools.tsx
deleted file mode 100644
index 31fc3c22..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/components/TemplateTools.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import {
- Button,
- VariantType,
- useToastProvider,
-} from '@openfun/cunningham-react';
-import { useTranslation } from 'react-i18next';
-
-import { Box, Text } from '@/components';
-import { useCreateTemplate } from '@/features/templates/template-create';
-
-import { useUpdateTemplate } from '../api/useUpdateTemplate';
-import { Template } from '../types';
-
-interface TemplateToolsProps {
- template: Template;
- html?: string;
- cssStyle?: string;
-}
-
-export const TemplateTools = ({
- template,
- html,
- cssStyle,
-}: TemplateToolsProps) => {
- const { t } = useTranslation();
- const { toast } = useToastProvider();
- const { mutate: updateTemplate } = useUpdateTemplate({
- onSuccess: () => {
- toast(t('Template save successfully'), VariantType.SUCCESS);
- },
- });
-
- const { mutate: duplicateTemplate } = useCreateTemplate({
- onSuccess: () => {
- toast(t('Template duplicated successfully'), VariantType.SUCCESS);
- },
- });
-
- return (
-
-
- {template.title}
-
-
-
-
-
-
- );
-};
diff --git a/src/frontend/apps/impress/src/features/templates/template/components/index.ts b/src/frontend/apps/impress/src/features/templates/template/components/index.ts
deleted file mode 100644
index 7159c1e3..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './TemplateEditor';
diff --git a/src/frontend/apps/impress/src/features/templates/template/index.tsx b/src/frontend/apps/impress/src/features/templates/template/index.tsx
deleted file mode 100644
index 314dad0c..00000000
--- a/src/frontend/apps/impress/src/features/templates/template/index.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './api';
-export * from './components';
-export * from './types';
diff --git a/src/frontend/apps/impress/src/layouts/TemplateLayout.tsx b/src/frontend/apps/impress/src/layouts/TemplateLayout.tsx
deleted file mode 100644
index 30a0215c..00000000
--- a/src/frontend/apps/impress/src/layouts/TemplateLayout.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { PropsWithChildren } from 'react';
-
-import { Box } from '@/components';
-import { useCunninghamTheme } from '@/cunningham';
-import { Panel } from '@/features/templates/template-panel';
-
-import { MainLayout } from './MainLayout';
-
-export function TemplateLayout({ children }: PropsWithChildren) {
- const { colorsTokens } = useCunninghamTheme();
-
- return (
-
-
-
-
- {children}
-
-
-
- );
-}
diff --git a/src/frontend/apps/impress/src/layouts/index.ts b/src/frontend/apps/impress/src/layouts/index.ts
index 6b909bd6..456e8e9e 100644
--- a/src/frontend/apps/impress/src/layouts/index.ts
+++ b/src/frontend/apps/impress/src/layouts/index.ts
@@ -1,3 +1,2 @@
export * from './MainLayout';
export * from './PadLayout';
-export * from './TemplateLayout';
diff --git a/src/frontend/apps/impress/src/pages/templates/[id].tsx b/src/frontend/apps/impress/src/pages/templates/[id].tsx
deleted file mode 100644
index 65adab07..00000000
--- a/src/frontend/apps/impress/src/pages/templates/[id].tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { Loader } from '@openfun/cunningham-react';
-import { useRouter as useNavigate } from 'next/navigation';
-import { useRouter } from 'next/router';
-import { ReactElement } from 'react';
-
-import { Box } from '@/components';
-import { TextErrors } from '@/components/TextErrors';
-import { TemplateEditor, useTemplate } from '@/features/templates/template';
-import { TemplateLayout } from '@/layouts';
-import { NextPageWithLayout } from '@/types/next';
-
-const Page: NextPageWithLayout = () => {
- const {
- query: { id },
- } = useRouter();
-
- if (typeof id !== 'string') {
- throw new Error('Invalid template id');
- }
-
- return ;
-};
-
-interface TemplateProps {
- id: string;
-}
-
-const Template = ({ id }: TemplateProps) => {
- const {
- data: template,
- isLoading,
- isError,
- error,
- } = useTemplate(
- { id },
- {
- queryKey: ['template', { id }],
- staleTime: 0,
- },
- );
- const navigate = useNavigate();
-
- if (isError && error) {
- if (error.status === 404) {
- navigate.replace(`/404`);
- return null;
- }
-
- return ;
- }
-
- if (isLoading || !template) {
- return (
-
-
-
- );
- }
-
- return ;
-};
-
-Page.getLayout = function getLayout(page: ReactElement) {
- return {page};
-};
-
-export default Page;
diff --git a/src/frontend/apps/impress/src/pages/templates/create.tsx b/src/frontend/apps/impress/src/pages/templates/create.tsx
deleted file mode 100644
index 3797b600..00000000
--- a/src/frontend/apps/impress/src/pages/templates/create.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { ReactElement } from 'react';
-
-import { Box } from '@/components';
-import { CardCreateTemplate } from '@/features/templates/';
-import { TemplateLayout } from '@/layouts';
-import { NextPageWithLayout } from '@/types/next';
-
-const Page: NextPageWithLayout = () => {
- return (
-
-
-
- );
-};
-
-Page.getLayout = function getLayout(page: ReactElement) {
- return {page};
-};
-
-export default Page;
diff --git a/src/frontend/apps/impress/src/pages/templates/index.tsx b/src/frontend/apps/impress/src/pages/templates/index.tsx
deleted file mode 100644
index a0f64ebb..00000000
--- a/src/frontend/apps/impress/src/pages/templates/index.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Button } from '@openfun/cunningham-react';
-import type { ReactElement } from 'react';
-import { useTranslation } from 'react-i18next';
-import styled from 'styled-components';
-
-import { Box, StyledLink } from '@/components';
-import { TemplateLayout } from '@/layouts';
-import { NextPageWithLayout } from '@/types/next';
-
-const StyledButton = styled(Button)`
- width: fit-content;
-`;
-
-const Page: NextPageWithLayout = () => {
- const { t } = useTranslation();
-
- return (
-
-
- {t('Create a new template')}
-
-
- );
-};
-
-Page.getLayout = function getLayout(page: ReactElement) {
- return {page};
-};
-
-export default Page;
diff --git a/src/frontend/yarn.lock b/src/frontend/yarn.lock
index 9eda694e..c13214ce 100644
--- a/src/frontend/yarn.lock
+++ b/src/frontend/yarn.lock
@@ -1482,11 +1482,6 @@
dependencies:
tslib "^2.4.0"
-"@grapesjs/react@1.0.0":
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/@grapesjs/react/-/react-1.0.0.tgz#bfa938128db7b69ca1c23439b66decf4eaa0ca9a"
- integrity sha512-HHttzxwgvhbxQqqsiiQzb+OJtKFl8yWI9Yp3IgPgiKXqwY19lEJWSkCukvfqxugbYRxi0M1uERLAt209AmY5vQ==
-
"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"