Skip to content

Commit 67991ea

Browse files
committed
Resolved merge conflicts and made final UI tweaks
2 parents fa6342c + e86e72c commit 67991ea

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

app/electron/main.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ app.on('web-contents-created', (event, contents) => {
214214
const parsedUrl = new URL(navigationUrl);
215215
const validOrigins = [
216216
selfHost,
217-
'https://localhost:8081',
217+
'http://localhost:8081',
218+
'http://reactype.heroku.com',
218219
'https://github.com/'
219220
];
220221
// Log and prevent the app from navigating to a new page if that page's origin is not whitelisted
@@ -234,7 +235,9 @@ app.on('web-contents-created', (event, contents) => {
234235
//console.log('parsedUrl.origin is', parsedUrl.origin);
235236
const validOrigins = [
236237
selfHost,
237-
'https://localhost:8081',
238+
'http://localhost:8081',
239+
'http://localhost:5000',
240+
'http://reactype.heroku.com',
238241
'https://github.com',
239242
'app://rse/'
240243
];
@@ -323,7 +326,7 @@ ipcMain.on('choose_app_dir', event => {
323326
// for github oauth login in production, since cookies are not accessible through document.cookie on local filesystem, we need electron to grab the cookie that is set from oauth, this listens for an set cookie event from the renderer process then sends back the cookie
324327
ipcMain.on('set_cookie', event => {
325328
session.defaultSession.cookies
326-
.get({ url: 'https://localhost:8081' })
329+
.get({ url: 'https://reactype.heroku.com' })
327330
.then(cookie => {
328331
console.log(cookie);
329332
event.reply('give_cookie', cookie);
@@ -336,7 +339,7 @@ ipcMain.on('set_cookie', event => {
336339
// again for production, document.cookie is not accessible so we need this listener on main to delete the cookie on logout
337340
ipcMain.on('delete_cookie', event => {
338341
session.defaultSession.cookies
339-
.remove('https://localhost:8081', 'ssid')
342+
.remove('https://reactype.heroku.com', 'ssid')
340343
.then(removed => {
341344
console.log('Cookies deleted', removed);
342345
})

app/src/components/login/SignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
208208
variant="contained"
209209
color="default"
210210
className={classes.submit}
211-
href="https://localhost:8081/github"
211+
href="https://reactype.heroku.com/github"
212212
onClick={() => {
213213
console.log('Inside onclick of github');
214214
setTimeout(() => {

app/src/components/right/LoginButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ export default function LoginButton() {
1313

1414
const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
1515
e.preventDefault();
16+
// clear local storage
17+
window.localStorage.clear();
1618
// destroys cookie by backdating expiration time
1719
document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
20+
// destroy cookie in production via electron main process
21+
window.api.delCookie();
1822
// uses useHistory to return to the login page
1923
history.push('/login');
2024
};
@@ -25,7 +29,7 @@ export default function LoginButton() {
2529
variant="contained"
2630
onClick={handleLogout}
2731
color="secondary"
28-
style={{ textAlign: 'center' }}
32+
className={classes.button}
2933
endIcon={<ExitToAppIcon />}
3034
>
3135
Log Out

app/src/components/right/ProjectManager.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@ import React, { useState, useContext } from 'react';
22
import { stateContext } from '../../context/context';
33

44
import { makeStyles } from '@material-ui/core/styles';
5-
import ExitToAppIcon from '@material-ui/icons/ExitToApp';
65
import List from '@material-ui/core/List';
76
import ListItem from '@material-ui/core/ListItem';
87
import ListItemText from '@material-ui/core/ListItemText';
98
import WarningIcon from '@material-ui/icons/Warning';
109
import PublishIcon from '@material-ui/icons/Publish';
1110
import Button from '@material-ui/core/Button';
12-
import Checkbox from '@material-ui/core/Checkbox';
1311
import MenuItem from '@material-ui/core/MenuItem';
1412
import Select from '@material-ui/core/Select';
1513
import FormControl from '@material-ui/core/FormControl';
1614
import { useHistory, withRouter } from 'react-router-dom';
1715

1816
import exportProject from '../../utils/exportProject.util';
19-
import { saveProject } from '../../helperFunctions/projectGetSave';
2017

2118
import ProjectsFolder from './ProjectsFolder';
2219
import createModal from './createModal';

app/src/components/right/ProjectsFolder.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ export default function ProjectsFolder() {
8989
const classes = useStyles();
9090

9191
const handleClickOpen = () => {
92-
getProjects().then((data: any) => {
93-
setProjects(data);
94-
setOpen(true);
92+
getProjects().then(data => {
93+
if (data) {
94+
setProjects(data);
95+
setOpen(true);
96+
}
9597
});
9698
};
9799

app/src/containers/RightContainer.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ProjectManager from '../components/right/ProjectManager';
1515

1616
// need to pass in props to use the useHistory feature of react router
1717
const RightContainer = (props): JSX.Element => {
18-
//console.log('this is a rerender');
18+
1919
const classes = useStyles();
2020
const [state, dispatch] = useContext(stateContext);
2121
const [displayMode, setDisplayMode] = useState('');
@@ -43,7 +43,6 @@ const RightContainer = (props): JSX.Element => {
4343
// after component renders, reset the input fields with the current styles of the selected child
4444
useEffect(() => {
4545
resetFields();
46-
//console.log('configTarget is', configTarget);
4746
}, [state.canvasFocus.componentId, state.canvasFocus.childId]);
4847

4948
// handles all input field changes, with specific updates called based on input's name
@@ -143,7 +142,7 @@ const RightContainer = (props): JSX.Element => {
143142
if (compWidth !== '') styleObj.width = compWidth;
144143
if (compHeight !== '') styleObj.height = compHeight;
145144
if (BGColor !== '') styleObj.backgroundColor = BGColor;
146-
console.log(styleObj);
145+
147146
dispatch({
148147
type: 'UPDATE CSS',
149148
payload: { style: styleObj }
@@ -154,7 +153,6 @@ const RightContainer = (props): JSX.Element => {
154153

155154
// placeholder for handling deleting instance
156155
const handleDelete = () => {
157-
console.log('DELETING ...');
158156
dispatch({ type: 'DELETE CHILD', payload: {} });
159157
};
160158

app/src/helperFunctions/auth.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
const isDev = process.env.NODE_ENV === 'development';
2+
let serverURL = 'https://reactype.herokuapp.com';
3+
if (isDev) {
4+
serverURL = 'http://localhost:5000';
5+
}
6+
17
export const sessionIsCreated = (
28
username: string,
39
password: string
410
): Promise<string> => {
5-
console.log('Username and pw in sessionIsCreated', username, password);
611
const body = JSON.stringify({
712
username,
813
password
914
});
10-
console.log('In sessionIsCreated, body is', body);
11-
const result = fetch('http://localhost:8081/login', {
15+
console.log(process.env.NODE_ENV);
16+
const result = fetch(`${serverURL}/login`, {
1217
method: 'POST',
1318
credentials: 'include',
1419
headers: {
15-
'Content-Type': 'application/json',
16-
Origin: 'reactype'
20+
'Content-Type': 'application/json'
1721
},
1822
body
1923
})
@@ -48,13 +52,11 @@ export const newUserIsCreated = (
4852
email,
4953
password
5054
});
51-
const result = fetch('http://localhost:8081/signup', {
55+
const result = fetch(`${serverURL}/signup`, {
5256
method: 'POST',
53-
//credentials: 'include',
54-
//mode: 'no-cors',
57+
credentials: 'include',
5558
headers: {
5659
'Content-Type': 'application/json'
57-
//'Access-Control-Allow-Origin': 'https://localhost:8081'
5860
},
5961
body
6062
})

app/src/helperFunctions/projectGetSave.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
const isDev = process.env.NODE_ENV === 'development';
2+
let serverURL = 'https://reactype.herokuapp.com';
3+
if (isDev) {
4+
serverURL = 'http://localhost:5000';
5+
}
16
// helper functions that will do fetch requests to get and save user/guest projects
27

38
export const getProjects = (): Promise<Object> => {
49
//console.log("Loading user's projects...");
510
let userId = window.localStorage.getItem('ssid');
611
//console.log('userId from localStorage is', userId);
712
const body = JSON.stringify({ userId });
8-
const projects = fetch('http://localhost:8081/getProjects', {
13+
const projects = fetch(`${serverURL}/getProjects`, {
914
method: 'POST',
1015
headers: {
1116
'content-type': 'application/json'
@@ -33,7 +38,7 @@ export const saveProject = (
3338
project: workspace,
3439
userId: window.localStorage.getItem('ssid')
3540
});
36-
const project = fetch('http://localhost:8081/saveProject', {
41+
const project = fetch(`${serverURL}/saveProject`, {
3742
method: 'POST',
3843
headers: {
3944
'content-type': 'application/json'

0 commit comments

Comments
 (0)