-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add weekday pricing #1942
Add weekday pricing #1942
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1942 +/- ##
==========================================
+ Coverage 83.09% 83.21% +0.11%
==========================================
Files 100 100
Lines 3526 3544 +18
==========================================
+ Hits 2930 2949 +19
+ Misses 596 595 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Passing run #3053 ↗︎Details:
Review all test suite changes for PR #1942 ↗︎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admins can change prices at frontend/src/pages/cabins/admin/index.tsx
, should also be updated so that they may change the prices for weekends. Minor comments otherwise
frontend/src/components/pages/cabins/booking/Steps/calculatePrice.ts
Outdated
Show resolved
Hide resolved
let currentDate = dayjs(startDate); | ||
const finalDate = dayjs(endDate); | ||
let weekdayNights = 0; | ||
let weekendNights = 0; | ||
let totalPrice = 0; | ||
while (currentDate.isBefore(finalDate, "day")) { | ||
// Last day has no night. | ||
if (currentDate.day() === 5 || currentDate.day() === 6) { | ||
// 5 = Friday to sat, 6 = Saturday to sunday | ||
weekendNights++; | ||
} else { | ||
weekdayNights++; | ||
} | ||
currentDate = currentDate.add(1, "day"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly concerned that we have to duplicate the backend logic here. I suggest that we instead add a price
-query or something similar and rely on the backend logic to calculate the price. That way, we won't accidentally end up with different prices.
Co-authored-by: Lars Waage <46653859+larwaa@users.noreply.github.com>
|
Passing run #3054 ↗︎Details:
Review all test suite changes for PR #1942 ↗︎ |
This pull request implements the requested changes to cabin pricing.