Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed initial date of new booking #37

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 43 additions & 27 deletions src/components/Booking/BookingEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,24 @@
:placeholder="selectedBooking._couponUsed.id"
></v-text-field>
</v-col>
<v-col>
<v-text-field
v-if="!!selectedBooking.couponCode"
background-color="accent"
filled
hide-details
label="Rabatt"
v-model.number="selectedBooking._couponUsed.discount"
readonly
disabled
:placeholder="selectedBooking._couponUsed.discount"
:suffix="selectedBooking._couponUsed.type === 'percentage' ? '%' : '€'"
></v-text-field>
</v-col>
<v-col>
<v-text-field
v-if="!!selectedBooking.couponCode"
background-color="accent"
filled
hide-details
label="Rabatt"
v-model.number="selectedBooking._couponUsed.discount"
readonly
disabled
:placeholder="selectedBooking._couponUsed.discount"
:suffix="
selectedBooking._couponUsed.type === 'percentage'
? '%'
: '€'
"
></v-text-field>
</v-col>
</v-row>

<v-row>
Expand Down Expand Up @@ -527,42 +531,54 @@ export default {
},
dateFrom: {
get() {
if (!this.selectedBooking.timeBegin) return undefined;
if (!this.selectedBooking.timeBegin) {
return this.formatDate(new Date());
}
return this.formatDate(new Date(this.selectedBooking.timeBegin));
},
set(val) {
this.selectedBooking.timeBegin = new Date(val + " " + this.timeFrom);
this.selectedBooking.timeBegin = new Date(
val + " " + this.timeFrom
).getTime();
},
},
dateTo: {
get() {
if (!this.selectedBooking.timeEnd) return undefined;
if (!this.selectedBooking.timeEnd) {
return this.formatDate(new Date());
}
return this.formatDate(new Date(this.selectedBooking.timeEnd));
},
set(val) {
this.selectedBooking.timeEnd = new Date(val + " " + this.timeTo);
this.selectedBooking.timeEnd = new Date(
val + " " + this.timeTo
).getTime();
},
},
timeFrom: {
get() {
if (!this.selectedBooking.timeBegin) return undefined;
if (!this.selectedBooking.timeBegin) {
return this.formatTime(new Date());
}
return this.formatTime(new Date(this.selectedBooking.timeBegin));
},
set(val) {
this.selectedBooking.timeBegin = this.formatDateTime(
new Date(this.dateFrom + " " + val)
);
this.selectedBooking.timeBegin = new Date(
this.dateFrom + " " + val
).getTime();
},
},
timeTo: {
get() {
if (!this.selectedBooking.timeEnd) return undefined;
if (!this.selectedBooking.timeEnd) {
return this.formatTime(new Date())
}
return this.formatTime(new Date(this.selectedBooking.timeEnd));
},
set(val) {
this.selectedBooking.timeEnd = this.formatDateTime(
new Date(this.dateTo + " " + val)
);
this.selectedBooking.timeEnd = new Date(
this.dateTo + " " + val
).getTime();
},
},
bookableItems: {
Expand Down Expand Up @@ -736,7 +752,7 @@ export default {
this.selectedBooking.timeEnd = null;
},
},
created() {
mounted() {
if (this.selectedBooking._id) {
this.getEvents();
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/Management/Bookings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ export default {
this.selectedBooking = {
tenant: this.tenant,
assignedUserId: null,
timeBegin: 1681383600000,
timeEnd: 1681387200000,
timeBegin: Date.now(),
timeEnd: Date.now(),
bookableItems: [],
couponCode: null,
name: null,
Expand Down