Skip to content

Commit 985ef3c

Browse files
authored
Wrong flight logic (#1473)
* correct logic for date warning * for ease with translation * modify alert condition for ease with translation * specify month value in 0-11 range
1 parent 7f27716 commit 985ef3c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/examples/src/flight-booker/App/composition.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export default {
1616

1717
function book() {
1818
alert(
19-
`You have booked a ${flightType.value} leaving on ${
20-
departureDate.value
21-
}${isReturn.value ? ` and returning on ${returnDate.value}` : ``}`
19+
isReturn.value
20+
? `You have booked a return flight leaving on ${departureDate.value} and returning on ${returnDate.value}.`
21+
: `You have booked a one-way flight leaving on ${departureDate.value}.`
2222
)
2323
}
2424

2525
function stringToDate(str) {
2626
const [y, m, d] = str.split('-')
27-
return new Date(+y, +m, +d)
27+
return new Date(+y, m - 1, +d)
2828
}
2929

3030
function dateToString(date) {

src/examples/src/flight-booker/App/options.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function stringToDate(str) {
22
const [y, m, d] = str.split('-')
3-
return new Date(+y, +m, +d)
3+
return new Date(+y, m - 1, +d)
44
}
55

66
function dateToString(date) {
@@ -31,17 +31,17 @@ export default {
3131
},
3232
canBook() {
3333
return (
34-
this.isReturn ||
34+
!this.isReturn ||
3535
stringToDate(this.returnDate) > stringToDate(this.departureDate)
3636
)
3737
}
3838
},
3939
methods: {
4040
book() {
4141
alert(
42-
`You have booked a ${this.flightType} leaving on ${this.departureDate}${
43-
this.isReturn ? ` and returning on ${this.returnDate}` : ``
44-
}`
42+
this.isReturn
43+
? `You have booked a return flight leaving on ${this.departureDate} and returning on ${this.returnDate}.`
44+
: `You have booked a one-way flight leaving on ${this.departureDate}.`
4545
)
4646
}
4747
}

src/examples/src/flight-booker/App/template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<select v-model="flightType">
2-
<option>one-way flight</option>
3-
<option>return flight</option>
2+
<option value="one-way flight">One-way Flight</option>
3+
<option value="return flight">Return Flight</option>
44
</select>
55

66
<input type="date" v-model="departureDate" />

0 commit comments

Comments
 (0)