Skip to content

Commit bec9579

Browse files
committed
merging dev branch into current local dev branchMerge branch 'dev' of https://github.com/oslabs-beta/Chronos into dev
2 parents 3b3117c + 1725b46 commit bec9579

32 files changed

+22052
-3872
lines changed

app/components/SignUp.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ const SignUp:React.FC = React.memo(() => {
2222
// eslint-disable-next-line no-return-assign
2323
inputFields.forEach(input => (input.value = ''));
2424

25+
if (!password) {
26+
setFailedSignUp(<p>Please enter valid password</p>)
27+
return;
28+
}
2529
if (password !== confirmPassword) {
2630
setFailedSignUp(<p>Entered passwords do not match</p>);
2731
return;
2832
}
2933

3034
ipcRenderer.invoke('addUser', { username, email, password})
31-
.then(validSignUp => {
32-
if (validSignUp) {
33-
setUser(username);
34-
navigate('/');
35-
} else
36-
setFailedSignUp(<p>Sorry, your sign up failed. Please try a different username or email</p>);
37-
}).catch(error => {
35+
.then((message) => {
36+
if (message === true) {
37+
setUser(username);
38+
console.log(username)
39+
navigate('/');
40+
} else {
41+
setFailedSignUp(<p>Sorry, your sign up failed. Please try a different username or email</p>)
42+
}
43+
}).catch(error => {
3844
console.error('Failed to sign up:', error);
3945
setFailedSignUp(<p>Sorry, your sign up failed. Please try again later</p>);
4046
});

electron/routes/dashboard.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ipcMain, IpcMainEvent } from 'electron';
1+
import { BrowserWindow, ipcMain, IpcMainEvent } from 'electron';
22
import moment from 'moment';
33
import path from 'path';
44
import fs from 'fs';
@@ -160,25 +160,28 @@ ipcMain.on('changeMode', (message: IpcMainEvent, currMode: string) => {
160160
message.returnValue = currMode;
161161
});
162162

163-
ipcMain.on(
163+
ipcMain.handle(
164164
'addUser',
165165
(message: IpcMainEvent, user: { username: string; password: string; email: string }) => {
166166
const { username, password, email } = user;
167+
console.log(user)
167168

168169
// Verify that username and email have not been taken
169170
const settings = JSON.parse(fs.readFileSync(settingsLocation).toString('utf8'));
170-
if (username in settings) {
171+
if (settings[username]) {
171172
message.returnValue = false;
172-
return;
173+
return message.returnValue;
173174
}
174-
175+
175176
// Add the new user to the local storage
176-
const newUser = new User(username, password, email);
177-
settings[username] = newUser;
178-
fs.writeFileSync(settingsLocation, JSON.stringify(settings, null, '\t'));
179-
currentUser = username;
180-
message.returnValue = true;
181-
return;
177+
else {
178+
const newUser = new User(username, password, email);
179+
settings[username] = newUser;
180+
fs.writeFileSync(settingsLocation, JSON.stringify(settings, null, '\t'));
181+
currentUser = username;
182+
message.returnValue = true;
183+
return message.returnValue;
184+
}
182185
}
183186
);
184187

examples/docker/README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ The frontend has a reverse proxy set up for proxying requests to the appropriate
1212
## Steps to Run Example
1313
Peform the following steps in each of the _books_, _customers_, _frontend_, and _orders_ directories
1414

15-
1. Add a `.env` file to *each* folder with the following key/value pairs:
16-
17-
- `CHRONOS_DB`: `MongoDB` or `PostgreSQL`
18-
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos**
19-
- `BOOK_URI`: A **MongoDB** URI for the bookserver microservice to use
20-
- `CUSTOMER_URI`: A **MongoDB** URI for the customerserver microservice to use
21-
- `ORDER_URI`: A **MongoDB** URI for the orderserver microservice to use
15+
1. Add a `.env` file to *each* folder with the following key/value pairs:
16+
- **NOTE**: Ensure that there are no quotes surrounding any of the keys and values.
2217

18+
```
19+
CHRONOS_DB = MongoDB or PostgreSQL
20+
CHRONOS_URI = The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos**
21+
BOOK_URI = A **MongoDB** URI for the bookserver microservice to use
22+
CUSTOMER_URI = A **MongoDB** URI for the customerserver microservice to use
23+
ORDER_URI = A **MongoDB** URI for the orderserver microservice to use
24+
```
2325
2. Verify that @chronosmicro/tracker is a dependency in each of the /books, /customers, /frontend, and /orders folders (see the `package.json` in each folder).
2426

25-
- If the @chronosmicro/tracker dependency is listed as a remote npm package (i.e. `"@chronosmicro/tracker": "^8.0.1"`), no further work is needed.
26-
27-
- If the @chronosmicro/tracker dependency is listed as a local npm package (i.e. `"@chronosmicro/tracker": "file:./chronos_npm_package"`), the Docker build will require that the the Chronos code is in this folder. Either copy the _chronos_npm_package_ folder in manually, or see next bullet to automate this process **if you are a Mac user**. If the folder is copied in manually for this example, we recommend deleting the copied in folder from each directory when the example is complete.
28-
29-
- **Mac users only:** `cd` into the _scripts_ folder and run the `buildDockerExample.sh` script. This will automatically copy the _chronos_npm_package_ folder into all 4 folders, and then runs the requried `docker-compose` command. If you run this script this, the example should be up and running and no further steps are needed. To delete the copied in folders if they were not automatically deleted by `buildDockerExample.sh`, run the script `cleanupDockerExample.sh`.
27+
- If the @chronosmicro/tracker dependency is listed as a remote npm package (i.e. `"@chronosmicro/tracker": "^8.0.3"`) and you've ran *npm install*, no further work is needed continue to step 3. If you have the dependency as `"@chronosmicro/tracker": "file:./chronos_npm_package"`, make sure to change the version from `"file:./chronos_npm_package"` to `"^8.0.3"` and run npm install.
3028

3129
3. With the terminal navigated to the the examples/docker folder, run the command:
3230
```

0 commit comments

Comments
 (0)