Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/components/Editor/FlowEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ReactFlow, {
useStoreApi,
} from 'reactflow';
import 'reactflow/dist/style.css';
import { v4 as UUIDv4 } from 'uuid';
import useStore from '../../store';
import {
polyglotEdgeComponentMapping,
Expand All @@ -34,6 +35,7 @@ import ContextMenu, {
ContextMenuTypes,
} from '../ContextMenu/ContextMenu';

import { platform } from 'os';
import { createNewDefaultPolyglotNode } from '../../utils/utils';
import LateralMenu from '../LateralMenu/LateralMenu';
import EditorNav from '../NavBars/EditorNav';
Expand Down Expand Up @@ -63,6 +65,7 @@ const FlowEditor = ({
setSelectedElement,
getSelectedElement,
clearSelection,
flow,
} = useStore((store) => ({
getNodes: store.reactFlowNodes,
getEdges: store.reactFlowEdges,
Expand All @@ -74,6 +77,7 @@ const FlowEditor = ({
setSelectedElement: store.setSelectedElement,
clearSelection: store.clearSelection,
setLastSavedAction: store.setLastSavedAction,
flow: store.getFlow(),
}));
const { resetSelectedElements } = useStoreApi().getState();
const { project } = useReactFlow();
Expand Down Expand Up @@ -133,6 +137,37 @@ const FlowEditor = ({
x: event.clientX - rect.left,
y: event.clientY - rect.top,
});

if (type == 'abstractNode') {
console.log('abstractNode creation');

const id = UUIDv4();
const nodeToAdd = {
_id: id,
type: type,
title: 'New Node',
description: '',
difficulty: 1,
platform: 'Library',
data: {
useFlowData: true,
sourceMaterial: flow?.sourceMaterial,
learning_outcome: flow?.learning_outcome,
education_level: flow?.education_level,
topicsAI: flow?.topicsAI,
language: flow?.language,
macro_subject: flow?.macro_subject,
},
reactFlow: {
id: id,
type: type,
position: pos,
data: undefined,
},
};
useStore.getState().addNode(nodeToAdd);
return;
}
console.log(pos);
const nodeToAdd = createNewDefaultPolyglotNode(pos, type);
console.log(nodeToAdd);
Expand Down
8 changes: 7 additions & 1 deletion src/components/Forms/Fields/EnumField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type EnumFieldProps = {
options: JSX.Element;
constraints?: RegisterOptions;
hidden?: boolean;
defaultValue?: any;
};

const EnumField = ({
Expand All @@ -24,14 +25,19 @@ const EnumField = ({
options,
constraints,
width,
defaultValue,
}: EnumFieldProps) => {
const { register, getFieldState } = useFormContext();
const { error } = getFieldState(name);

return (
<Box p={2} width={width} hidden={hidden}>
<FormControl isInvalid={error !== undefined}>
<Select {...register(name, constraints)} borderColor={'grey'}>
<Select
{...register(name, constraints)}
borderColor={'grey'}
defaultValue={defaultValue}
>
{options}
</Select>
<FormLabel
Expand Down
1 change: 1 addition & 0 deletions src/components/LateralMenu/LateralMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const configAssessment = [
];

const listImplementedNodes = [
'abstractNode',
'multipleChoiceQuestionNode',
'closeEndedQuestionNode',
'OpenQuestionNode',
Expand Down
20 changes: 14 additions & 6 deletions src/components/Modals/CreateAILPModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,12 @@ const CreateAILPModal = ({ isOpen, onClose, action }: ModaTemplateProps) => {
duration: analysedMaterial.estimated_duration.toString(),
topics: topics,
tags: tags,
sourceMaterial: sourceMaterial,
learning_outcome: learningOutcome,
education_level: eduLevel,
topicsAI: selectedTopic,
language: analysedMaterial.language,
macro_subject: analysedMaterial.macro_subject,
nodes: generatedNodes,
edges: generatedEdges,
};
Expand All @@ -1031,16 +1037,18 @@ const CreateAILPModal = ({ isOpen, onClose, action }: ModaTemplateProps) => {
isClosable: true,
});
}
router.push('/flows/' + flowResponse.data.id);
} catch (error) {
toast({
title: 'Generic Error',
description: 'Try later: ' + (error as Error).message,
status: 'error',
duration: 5000,
title: 'Flow created',
description:
'Flow created successfully, you will be redirected soon.',
status: 'success',
duration: 3000,
position: 'bottom-left',
isClosable: true,
});
router.push('/flows/' + flowResponse.data.id);
} catch (error) {
console.log((error as Error).message);
} finally {
setGeneratingLoading(false);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Modals/CreateFlowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const CreateFlowModal = ({ isOpen, onClose, API }: CreateFlowModalProps) => {
duration: duration,
learningContext: learningContext,
topics: topics,
topicsAI: [],
};
response = await API.createNewFlow(base_Flow);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Modals/EditFlowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ const EditFlowModal = ({
onClick={() => {
if (!title || !description || !tags) return;
updateInfo({
//aggiorna con material... ai data
title: title,
description: description,
tags: tags,
publish: publish,
learningContext: learningContext,
duration: duration,
topics: topics,
topicsAI: [],
});
onClose();
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Properties/Edges/EdgeProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config = [
'CreateKeywordsListNode',
'MemoriseKeywordsListNode',
'PromptEngineeringNode',
'ProblemSolvingNode',
'ProblemSolvingNode',
],
},
{
Expand Down
Loading
Loading