Skip to content

Commit 47e0c2e

Browse files
committed
working login, logout, passedInProps table
1 parent d9e5a9e commit 47e0c2e

File tree

7 files changed

+168
-122
lines changed

7 files changed

+168
-122
lines changed

app/src/Dashboard/Project.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ const Project = ({
105105
setCommentVal(commentValue);
106106
}
107107
const recentComments = [];
108-
if (comments.length > 0) {
109-
const reversedCommentArray = comments.slice(0).reverse();
110-
const min = Math.min(6, reversedCommentArray.length)
111-
for (let i = 0; i < min ; i++) {
112-
recentComments.push(
113-
<p className='comment'>
114-
<b>{ reversedCommentArray[i].username }</b>:
115-
{ reversedCommentArray[i].text }
116-
</p>
117-
)}
118-
}
108+
// if (comments?.length > 0) {
109+
// const reversedCommentArray = comments.slice(0).reverse();
110+
// const min = Math.min(6, reversedCommentArray.length)
111+
// for (let i = 0; i < min ; i++) {
112+
// recentComments.push(
113+
// <p className='comment'>
114+
// <b>{ reversedCommentArray[i].username }</b>:
115+
// { reversedCommentArray[i].text }
116+
// </p>
117+
// )}
118+
// }
119119
// Closes out the open modal
120120
const closeModal = () => setModal('');
121121
// Creates modal that asks if user wants to delete project

app/src/Dashboard/ProjectContainer.tsx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,21 @@ const ProjectContainer = (): JSX.Element => {
103103
const [style, setStyle] = useState(initialStyle);
104104
// hook for sorting menu
105105
const [selectedOption, setSelectedOption] = useState('RATING');
106-
const sortByRating = projects => {
107-
// generate a sorted array of public projects based on likes
108-
const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
109-
return sortedRatings;
110-
};
111-
const sortByDate = projects => {
112-
// generate a sorted array of public projects based on date
113-
const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
114-
return sortedRatings;
115-
};
116-
const sortByUser = projects => {
117-
// generate a sorted array of public projects based on username
118-
const sortedRatings = projects.sort((a, b) => b.username - a.username);
119-
return sortedRatings;
120-
};
106+
// const sortByRating = projects => {
107+
// // generate a sorted array of public projects based on likes
108+
// const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
109+
// return sortedRatings;
110+
// };
111+
// const sortByDate = projects => {
112+
// // generate a sorted array of public projects based on date
113+
// const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
114+
// return sortedRatings;
115+
// };
116+
// const sortByUser = projects => {
117+
// // generate a sorted array of public projects based on username
118+
// const sortedRatings = projects.sort((a, b) => b.username - a.username);
119+
// return sortedRatings;
120+
// };
121121
// function for selecting drop down sorting menu
122122
const optionClicked = value => {
123123
setSelectedOption(value);
@@ -128,22 +128,36 @@ const ProjectContainer = (): JSX.Element => {
128128
variables: myVar
129129
});
130130
if (loading) return <p>Loading...</p>;
131-
if (error) return <p>Error :{error}</p>;
131+
// if (error) return <p>Error :{error}</p>;
132132
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
133-
const projects = data.getAllProjects;
133+
//const projects = data.getAllProjects;
134+
const projects = [
135+
{key: 1},
136+
{name: 'testproject'},
137+
{likes: 10},
138+
{published: true},
139+
{id: 10},
140+
{userId: 10},
141+
{username: 'arao7'},
142+
{createdAt: 'testDate'},
143+
{comments: []}
144+
]
134145
// create array to hold the data recieved in the public dashboard the will be conditionally rendered
135-
let sortedProjects = projects.filter(proj => {
136-
return proj.published;
137-
});
138-
const userProjects = projects.filter(proj => {
139-
return proj.username === username;
140-
});
146+
// let sortedProjects = projects.filter(proj => {
147+
// return proj.published;
148+
// });
149+
// const userProjects = projects.filter(proj => {
150+
// return proj.username === username;
151+
// });
152+
153+
let sortedProjects = projects;
154+
const userProjects = projects;
141155
// checking which sorting method was selected from drop down menu and invoking correct sorting function
142-
if (selectedOption === 'DATE') sortedProjects = sortByDate(sortedProjects);
143-
else if (selectedOption === 'USER')
144-
sortedProjects = sortByUser(sortedProjects);
145-
else if (selectedOption === 'RATING')
146-
sortedProjects = sortByRating(sortedProjects);
156+
// if (selectedOption === 'DATE') sortedProjects = sortByDate(sortedProjects);
157+
// else if (selectedOption === 'USER')
158+
// sortedProjects = sortByUser(sortedProjects);
159+
// else if (selectedOption === 'RATING')
160+
// sortedProjects = sortByRating(sortedProjects);
147161
// create array to hold the components Project of loggin-in users
148162
// generate an array of Project components based on queried data
149163
const userDisplay = arrToComponent(userProjects);

app/src/components/StateManagement/CreateTab/components/Table3.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Table3 = props => {
6060
deleteParentProps(params.row, params.id);
6161
}}
6262
>
63-
<AddIcon style={{ width: `${15}px` }} />
63+
<ClearIcon style={{ width: `${15}px` }} />
6464
</Button>
6565

6666
);
@@ -87,7 +87,7 @@ const Table3 = props => {
8787
});
8888
};
8989

90-
90+
console.log('passed in props after delete', currentComponent.passedInProps);
9191

9292
useEffect(() => {
9393
setGridColumns(columnTabs);
@@ -105,7 +105,8 @@ const Table3 = props => {
105105
}
106106

107107
}, [state.canvasFocus.componentId]);
108-
let rows = passedInProps;
108+
109+
let rows = passedInProps?.slice();
109110
// rows to show are either from current component or from a given provider
110111
// legacy pd convert parent props into a row array
111112
// if (!props.providerId) {
@@ -130,7 +131,6 @@ const Table3 = props => {
130131
// }
131132
// }
132133

133-
134134
return (
135135
<div className={'state-prop-grid'}>
136136
({rows.length &&

app/src/components/main/DirectChildComponent.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ function DirectChildComponent({ childId, type, typeId, style, name }: ChildEleme
5151
state.canvasFocus.childId === childId ? '1px 1px 3px #a7cced' : ''
5252
};
5353

54-
const combinedStyle = combineStyles(
55-
combineStyles(
56-
combineStyles(globalDefaultStyle, referencedComponent.style),
57-
style
58-
),
59-
interactiveStyle
60-
);
54+
// const combinedStyle = combineStyles(
55+
// combineStyles(
56+
// combineStyles(globalDefaultStyle, referencedComponent.style),
57+
// style
58+
// ),
59+
// interactiveStyle
60+
// );
6161
// Renders name and not children of subcomponents to clean up Canvas view when dragging components
6262
// into the main canvas. To render html elements on canvas, import and invoke renderChildren
6363
return (
6464
<div
6565
onClick={onClickHandler}
66-
style={combinedStyle}
66+
//style={combinedStyle}
6767
ref={drag}
6868
>
6969
<strong>{name}</strong>

app/src/components/right/LoginButton.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ import StateContext from '../../context/context';
88
export default function LoginButton() {
99
const history = useHistory();
1010
const [state,] = useContext(StateContext);
11-
const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
12-
e.preventDefault();
13-
// clear local storage
14-
window.localStorage.clear();
15-
// destroy cookie in production via electron main process
16-
window.api.delCookie();
17-
// destroys cookie by backdating expiration time
18-
// document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
19-
// uses useHistory to return to the login page
20-
history.push('/login');
21-
};
11+
// const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
12+
// e.preventDefault();
13+
// // clear local storage
14+
// window.localStorage.clear();
15+
// // destroy cookie in production via electron main process
16+
// window.api.delCookie();
17+
// // destroys cookie by backdating expiration time
18+
// // document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
19+
// // uses useHistory to return to the login page
20+
// history.push('/login');
21+
// };
22+
23+
const handleLogout = () => {
24+
console.log('in handlelogout')
25+
document.cookie = "SSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"
26+
//const navigate = useNavigate();
27+
//navigate('/');
28+
window.location.href = 'http://localhost:8080/#/login';
29+
// window.location.reload();
30+
}
2231
if (state.isLoggedIn) {
2332
return (
2433
<Button

app/src/reducers/componentReducer.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,29 @@ const reducer = (state: State, action: Action) => {
789789
);
790790
return { ...state, components};
791791
}
792+
793+
case 'DELETE PARENTPROPS' : {
794+
const components = [...state.components];
795+
let currComponent = findComponent(
796+
components,
797+
state.canvasFocus.componentId
798+
);
799+
currComponent.passedInProps = action.payload.passedInProps;
800+
console.log('in delete reducer', currComponent)
801+
console.log('in delete reducer 2', action.payload.rowId)
802+
const toDelete = currComponent.passedInProps[0]
803+
console.log('in delete reducer', {toDelete})
804+
delete currComponent.passedInProps[0];
805+
currComponent.code = generateCode(
806+
components,
807+
state.canvasFocus.componentId,
808+
[...state.rootComponents],
809+
state.projectType,
810+
state.HTMLTypes
811+
);
812+
return { ...state, components};
813+
}
814+
792815
case 'DELETE STATE' : {
793816
const components = [...state.components];
794817
let currComponent = findComponent(

0 commit comments

Comments
 (0)