Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit 8d2fa95

Browse files
authored
Merge pull request #97 from sd19oracle/bugfixes
Fix service cards and register bugs
2 parents 6fcc589 + 3866ac1 commit 8d2fa95

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

src/App.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export default class App extends Component {
4848
<Route
4949
path="/register"
5050
exact
51-
component={Register}/>
51+
render={({location, history}) =>
52+
<Register history={history}
53+
location={location}
54+
setUser={this.setUser}/>}/>
5255
<Route
5356
path="/providers"
5457
exact

src/components/Register.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ const Register = ({setUser, location, history}) =>
99
<Formik
1010
initialValues={{email: "", password: "", firstName: "", lastName: ""}}
1111
onSubmit={(values, {resetForm}) => {
12-
UserService.getInstance().createUser(values)
12+
const service = UserService.getInstance();
13+
service.createUser(values)
1314
.then(() => {
14-
history.push("/login");
15+
service.login(values.email, values.password)
16+
.then((user) => {
17+
setUser(user);
18+
history.push("/home");
19+
})
1520
})
1621
.catch(err => {
1722
if (err instanceof HttpError && err.response.status === 409) {

src/components/ServiceNavigator/ServiceCards.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ServiceCards = ({services}) =>
1212
className="card-img-top cover"/>
1313
<div className="card-body">
1414
<p className="card-text">
15-
<Link to="/providers">{service.serviceName}</Link>
15+
<Link to={`/providers/${service.id}`}>{service.serviceName}</Link>
1616
</p>
1717
</div>
1818
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react'
2+
import {Link} from "react-router-dom";
3+
import "./index.css"
4+
5+
const ServiceLinks = ({services}) =>
6+
<div className="row">
7+
{services.map(service =>
8+
<div key={service.id} className="col-4 mb-3">
9+
<Link to={`/providers/${service.id}`}>{service.serviceName}</Link>
10+
</div>
11+
)}
12+
</div>;
13+
14+
export default ServiceLinks

src/components/ServiceNavigator/index.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
}
44

55
.cover {
6-
max-height: 15rem;
6+
max-height: 13rem;
77
object-fit: cover;
8+
border-radius: 0.5rem;
89
}

src/components/ServiceNavigator/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ServiceCategoryService from "../../services/ServiceCategoryService";
55
import "./index.css"
66
import ServiceCards from "./ServiceCards";
77
import ServiceService from "../../services/ServiceService";
8+
import ServiceLinks from "./ServiceLinks";
89

910
export default class ServiceNavigator extends React.Component {
1011

@@ -41,7 +42,9 @@ export default class ServiceNavigator extends React.Component {
4142
// if switching ids then load the services for the new one
4243
this.loadServices("");
4344

44-
} else if (currentCatID && prevCatID) {
45+
} else if (currentCatID && prevCatID
46+
&& this.state.serviceCategories.length
47+
!== prevState.serviceCategories.length) {
4548
// if user selects a category then filters it out,
4649
// deselect that category
4750
const pred = cat => cat.id === Number(currentCatID);
@@ -93,7 +96,9 @@ export default class ServiceNavigator extends React.Component {
9396
</div>
9497
<div className="col-8">
9598
<h1>{this.currentServiceTitle()}</h1>
96-
<ServiceCards services={this.state.services}/>
99+
<ServiceCards services={this.state.services.slice(0, 4)}/>
100+
<hr/>
101+
<ServiceLinks services={this.state.services}/>
97102
</div>
98103
</div>;
99104
}

0 commit comments

Comments
 (0)