Skip to content

Commit c7c8107

Browse files
anaisbergSimonClo
authored andcommitted
✨ add column to table
1 parent f4f7136 commit c7c8107

File tree

1 file changed

+14
-2
lines changed
  • src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock

1 file changed

+14
-2
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock/AddColumnButton.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { Button, Input } from '@openfun/cunningham-react';
2+
import { useState } from 'react';
23

34
import { Box, DropButton, Text } from '@/components';
45

56
export const AddButtonComponent = ({
7+
addColumn,
68
isOpen,
79
setIsOpen,
810
}: {
11+
addColumn: (columnName: string) => void;
912
isOpen: boolean;
1013
setIsOpen: (open: boolean) => void;
1114
}) => {
1215
const onOpenChange = (isOpen: boolean) => {
1316
setIsOpen(isOpen);
1417
};
18+
const [columnName, setColumnName] = useState('');
1519

1620
return (
1721
<DropButton
@@ -28,11 +32,19 @@ export const AddButtonComponent = ({
2832
<Text $variation="600" $size="s" $weight="bold" $theme="greyscale">
2933
Ajouter une colonne
3034
</Text>
31-
<Input label="Column label"></Input>
35+
<Input
36+
label="Column label"
37+
onChange={(event) => {
38+
setColumnName(event.target.value);
39+
}}
40+
></Input>
3241
<Button
3342
size="small"
3443
onClick={() => {
35-
setIsOpen(false);
44+
if (columnName.trim() === '') {
45+
return;
46+
}
47+
addColumn(columnName);
3648
}}
3749
style={{ alignSelf: 'end', width: 'fit-content' }}
3850
>

0 commit comments

Comments
 (0)