Skip to content

Commit 4eb19d2

Browse files
Co-authored-by: BenCauffman <[email protected]>
Co-authored-by: Carly Jackson <[email protected]>
1 parent 2d1654d commit 4eb19d2

File tree

3 files changed

+18
-63
lines changed

3 files changed

+18
-63
lines changed

app/src/components/main/Canvas.tsx

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ function Canvas(props): JSX.Element {
1717

1818
useEffect(()=> {
1919
if (newComp) {
20-
console.log('inside use effect', {state});
21-
console.log('copiedComp', copiedComp.name)
2220
//find updated comp
2321
const copy = state.components.find(comp => comp.name === copiedComp.name)
24-
console.log({copy})
2522
// make a array of copied children from the copied component
2623
if (copy.children.length){
2724
const masterArr = [];
@@ -31,25 +28,19 @@ function Canvas(props): JSX.Element {
3128
const child = children[i];
3229
let id = (parentId) ? parentId : null;
3330
if (child.typeId < 1000){
34-
console.log({child})
3531
masterArr.push({
3632
type: "HTML Element",
3733
typeId: child.typeId,
3834
childId: id
3935
})
4036
if (child.children.length) {
41-
console.log('do a recursive call');
42-
console.log('child.childrean array in recursion', child.children)
43-
console.log('child.children.id', child.childId)
4437
deepChildCopy(child.children, child.childId);
4538
}
4639
}
4740
}
4841
}
4942
deepChildCopy(children, null);
50-
console.log({masterArr})
5143
setCopiedChildrenArr(masterArr);
52-
console.log('SADJBFSDJBFLJSHDBFJLDHS', copiedChildrenArr)
5344
}
5445

5546
const components = state.components
@@ -68,31 +59,6 @@ function Canvas(props): JSX.Element {
6859
setNewComp(false)
6960
}, [newComp])
7061

71-
// useEffect(()=>{
72-
// const lastComp = state.components[state.components.length - 1];
73-
// if (copiedChildrenArr.length) {
74-
// console.log('setCopiedChildrenArr use effect running')
75-
// // copiedChildrenArr.forEach(com => console.log(com))
76-
// // console.log(copiedChildrenArr[0])
77-
// // console.log(copiedChildrenArr[1])
78-
// for (let i = 0; i < copiedChildrenArr.length; i++) {
79-
// dispatch({
80-
// type: 'ADD CHILD',
81-
// payload: {...copiedChildrenArr[i], copyId: lastComp.id}
82-
// });
83-
// }
84-
// // dispatch({
85-
// // type: 'ADD CHILD',
86-
// // payload: {...copiedChildrenArr[1], copyId: lastComp.id}
87-
// // });
88-
// // setCopiedChildrenArr(copiedChildrenArr.slice(1))
89-
// setCopiedChildrenArr([])
90-
// }
91-
92-
// },[copiedChildrenArr])
93-
94-
95-
9662
// Caret start
9763
Arrow.deleteLines();
9864
// find the current component to render on the canvas
@@ -154,7 +120,6 @@ function Canvas(props): JSX.Element {
154120
if (child.name === 'seperator') continue;
155121
// check if the item.instanceTypeId matches and child ID
156122
if (item.instanceTypeId === child.typeId) {
157-
console.log('parent found', comp)
158123
// check if the name of the parent matches the canvas focus name
159124
// comp is the parent component
160125
// currentComponent is the canvas.focus component
@@ -163,7 +128,6 @@ function Canvas(props): JSX.Element {
163128
break;
164129
} else {
165130
// if false
166-
console.log('different parent');
167131
setCopiedComp(child);
168132
hasDiffParent = true;
169133
newChildName = child.name;
@@ -183,25 +147,23 @@ function Canvas(props): JSX.Element {
183147
}
184148
});
185149
} else {
150+
151+
// able to duplicate a component in dev only does not work for prod
186152
// create a new component
187-
let name = prompt("Component already has a parent. \nDo you want to create a new component and import its elements?", "Enter component name here");
188-
// console.log({newChildName}, 1)
189-
while (components.some(comp => comp.name === name)) {
190-
name = prompt(`${name} component already exists. \nPlease pick a new name.`);
191-
}
192-
if (name) {
193-
dispatch({
194-
type: 'ADD COMPONENT',
195-
payload: { componentName: name, root: false }
196-
});
153+
154+
// let name = prompt("Component already has a parent. \nDo you want to create a new component and import its elements?", "Enter component name here");
155+
// while (components.some(comp => comp.name === name)) {
156+
// name = prompt(`${name} component already exists. \nPlease pick a new name.`);
157+
// }
158+
// if (name) {
159+
// dispatch({
160+
// type: 'ADD COMPONENT',
161+
// payload: { componentName: name, root: false }
162+
// });
197163

198-
setNewComp(true);
199-
console.log({newComp})
200-
201-
// console.log({components})
202-
// console.log({newId})
203-
setNewComp(!newComp)
204-
}
164+
// setNewComp(true);
165+
// setNewComp(!newComp)
166+
// }
205167

206168
}
207169

app/src/reducers/componentReducer.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ const reducer = (state: State, action: Action) => {
7070
const findChild = (component: Component, childId: number) => {
7171
if (childId === null) return component;
7272
const nodeArr = [...component.children];
73-
console.log({nodeArr})
7473
// breadth first search through component tree to see if a child exists
7574
while (nodeArr.length > 0) {
7675
// shift off the first value and assign to an element
@@ -196,7 +195,6 @@ const reducer = (state: State, action: Action) => {
196195
};
197196
switch (action.type) {
198197
case 'ADD COMPONENT': {
199-
console.log('adding component payload', action.payload)
200198
if (
201199
typeof action.payload.componentName !== 'string' ||
202200
action.payload.componentName === ''
@@ -247,7 +245,6 @@ const reducer = (state: State, action: Action) => {
247245
}
248246
// Add child to a given root component
249247
case 'ADD CHILD': {
250-
console.log('add child started', action.payload)
251248
let parentComponentId: number;
252249
const {
253250
type,
@@ -263,7 +260,6 @@ const reducer = (state: State, action: Action) => {
263260
const components = [...state.components];
264261

265262
const parentComponent = findComponent(components, parentComponentId);
266-
console.log({parentComponent})
267263
let componentName: string = '';
268264
let componentChildren: Object[] = [];
269265
if (type === 'Component') {
@@ -327,15 +323,13 @@ const reducer = (state: State, action: Action) => {
327323
}
328324
// if there is a childId (childId here references the direct parent of the new child) find that child and a new child to its children array
329325
else {
330-
console.log({childId})
331-
console.log({directParent})
332326
directParent = findChild(parentComponent, childId);
327+
//disable nesting a component inside a HTML element
333328
if (directParent.type === "HTML Element" && type === "HTML Element") {
334329
directParent.children.push(topSeparator);
335330
directParent.children.push(newChild);
336331
} else {
337-
console.log('sorry cant drag comp into html bruh')
338-
return state;
332+
return { ...state };
339333
}
340334

341335
}
@@ -933,7 +927,7 @@ const reducer = (state: State, action: Action) => {
933927
state.HTMLTypes
934928
);
935929
}
936-
930+
937931
deletePassedInPropsChildren(parent);
938932
deletePassedInProps(currComponent);
939933

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@
229229
"jest-environment-jsdom": "^28.1.3",
230230
"mini-css-extract-plugin": "^0.9.0",
231231
"mongodb": "^3.5.9",
232-
233232
"node-sass": "^7.0.1",
234233
"nodemon": "^2.0.19",
235234
"react": "^17.0.2",

0 commit comments

Comments
 (0)