Skip to content

Commit b82741b

Browse files
authored
Merge pull request #205 from CodeForPhilly/US-routing-improvements-from-participant-info-to-Queuetable
US-routing-improvements-from-PInfo-page
2 parents d5134c5 + 69f0230 commit b82741b

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

frontend/src/components/ParticipantInfo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Button from "@material-ui/core/Button"
2020
import { observer } from "mobx-react-lite"
2121
import { useHistory } from "react-router-dom"
2222
import { format } from "date-fns"
23+
import { autorun } from "mobx"
2324

2425
const useStyles = makeStyles(theme => ({
2526
paper: {
@@ -185,7 +186,11 @@ const ParticipantInfo = observer(() => {
185186
participantIndex > -1
186187
? participantStore.updateParticipant()
187188
: participantStore.createParticipant()
188-
history.push("/")
189+
autorun(() => {
190+
if (participantStore.routeToQueueTable) {
191+
history.push("/")
192+
}
193+
})
189194
}
190195

191196
const classes = useStyles()

frontend/src/stores/ParticipantStore.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class ParticipantStore {
1515
params = {}
1616
visit = {}
1717
visitList = []
18+
@observable routeToQueueTable = false
1819

1920
// Setters
2021
setParticipantsList = data => {
@@ -50,6 +51,9 @@ export class ParticipantStore {
5051
setVisitParticipantId = data => {
5152
this.visit.participant = data
5253
}
54+
setRouteToQueue = data => {
55+
this.routeToQueueTable = data
56+
}
5357

5458
// Getters
5559
getParticipantsList = () => {
@@ -135,13 +139,9 @@ export class ParticipantStore {
135139
})
136140

137141
updateVisit = flow(function*() {
138-
const { ok } = yield api.updateVisits(
139-
toJS(this.visit.id),
140-
toJS(this.participant)
141-
)
142+
const { ok } = yield api.updateVisits(toJS(this.visit.id), toJS(this.visit))
142143
if (ok) {
143144
this.setRouteToQueue(true)
144-
this.routeToQueueTable()
145145
} else {
146146
// TODO: Handle errors
147147
}
@@ -156,17 +156,6 @@ export class ParticipantStore {
156156
}
157157
})
158158

159-
getFrontDeskStuff = flow(function*() {
160-
const { ok } = yield api.getFrontDeskEvent({
161-
participant: this.participant.id,
162-
})
163-
if (ok) {
164-
// TODO: Handle sucess
165-
} else {
166-
// TODO: Handle errors
167-
}
168-
})
169-
170159
updateFrontEndDeskEvent = flow(function*() {
171160
const { ok } = yield api.patchFrontDeskEvent()
172161
if (ok) {
@@ -182,7 +171,7 @@ export class ParticipantStore {
182171
event_type: "ARRIVED",
183172
})
184173
if (ok) {
185-
// TODO: Handle sucess
174+
this.setRouteToQueue(true)
186175
} else {
187176
// TODO: Handle errors
188177
}

0 commit comments

Comments
 (0)