Skip to content

Commit 3455eea

Browse files
authored
feat(showcase): Add the Travel host side (#1343) (#1376)
- Host role (demo account Aiko Tanaka) and a host back office with its own sidebar (D-031); the guest site and the back office share a new TravelFrame. A host viewing the site sees a "Back to hosting" bar (D-032). - Today: requests to answer with deadlines, arrivals and departures, earnings this month, occupancy, rating, unread messages, and reviews without a reply. - Reservations: every booking of the host's listings by phase, with filters; accept a request (the held test card is charged and the guest is notified) or decline it. Requests expire after 24 hours or at check-in, and stop holding dates (T30-F1). - Calendar with booked, requested, and blocked nights and host blocks; listings CRUD (rates, amenities, photos from a library, list or unlist, delete without history); inbox with host replies; public review replies; earnings with monthly payouts (payment without taxes, less a 3% fee, paid the day after check-in). - Listings are now part of the per-tab snapshot (format 3), and each booking keeps its policy and rates. - Review fixes: bookings keep their guest count, policy, and booked rates when the host edits the listing, so edits never break the tab's data or change existing trips; moving a listing to another city moves its map pin; same-day requests need time for the host to answer; guests with a trip at an unlisted stay can still open it and message the host; writing in a conversation marks it read for the writer only.
1 parent 254b76d commit 3455eea

49 files changed

Lines changed: 6800 additions & 95 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Travel/Book.razor.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ private void Submit()
281281

282282
[Inject] private TravelState State { get; set; } = default!;
283283

284-
private TravelStay? Stay => State.FindStay(Id);
284+
/// <summary>The stay, when it is listed; an unlisted stay can't be booked.</summary>
285+
private TravelStay? Stay => State.FindStay(Id) is { IsListed: true } stay ? stay : null;
285286

286287
/// <summary>Gets the taken nights in the chosen range, by date, for the availability message.</summary>
287288
private string TakenNightsText
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@page "/showcase/travel/host/account"
2+
@layout HostLayout
3+
4+
<PageTitle>Account · Hosting · @TravelSeedData.SiteName</PageTitle>
5+
6+
@* The host's profile and password. *@
7+
<div class="container-fluid px-lg-4">
8+
<h1 class="ds-title mb-1">Account</h1>
9+
<p class="text-body-secondary mb-4">Your name, email, and password for this demo. Guests see your host profile on your listings.</p>
10+
<ShowcaseAccountProfile />
11+
</div>
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
@page "/showcase/travel/host/calendar"
2+
@layout HostLayout
3+
4+
<PageTitle>Calendar · Hosting · @TravelSeedData.SiteName</PageTitle>
5+
6+
<div class="container-fluid px-lg-4">
7+
<h1 class="ds-title mb-1">Calendar</h1>
8+
<p class="ds-lead text-body-secondary mb-3">Who's staying, which requests are waiting, and the nights you've blocked, one listing and one month at a time.</p>
9+
10+
@* Always rendered and focusable, so an action's outcome is announced and focus has somewhere to go. *@
11+
<p class="ds-hc-status" role="status" tabindex="-1" @ref="statusRegion">@statusMessage</p>
12+
13+
@if (Stay is not { } stay)
14+
{
15+
<section class="ds-panel text-center py-5" aria-labelledby="ds-hc-empty">
16+
<span class="ds-icon fs-4" aria-hidden="true"><Icon Name="IconName.Calendar3" /></span>
17+
<h2 class="h5 fw-bold mt-3" id="ds-hc-empty">No listings yet</h2>
18+
<p class="text-body-secondary">Add a listing to see its calendar.</p>
19+
<a class="btn btn-primary" href="@HostListingEdit.NewUrl">Add listing</a>
20+
</section>
21+
}
22+
else
23+
{
24+
var month = FirstMonth;
25+
var nights = NightsOf(stay.Id, month);
26+
var monthName = MonthName(month);
27+
28+
<div class="ds-hc-picker mb-3">
29+
<label class="form-label fw-semibold mb-1" for="ds-hc-stay">Listing</label>
30+
<select id="ds-hc-stay" class="form-select" value="@stay.Id" @onchange="OnStayChanged" aria-describedby="@(stayNotice is null ? null : "ds-hc-stay-notice")">
31+
@foreach (var option in State.HostStays())
32+
{
33+
<option value="@option.Id">@option.Name@(option.IsListed ? null : " (unlisted)")</option>
34+
}
35+
</select>
36+
@if (stayNotice is not null)
37+
{
38+
<div class="form-text" id="ds-hc-stay-notice">@stayNotice</div>
39+
}
40+
</div>
41+
42+
<section class="ds-panel mb-4" aria-labelledby="ds-hc-month-title">
43+
<h2 class="h5 fw-bold" id="ds-hc-month-title">Nights of @stay.Name</h2>
44+
45+
<div class="ds-hc-toolbar">
46+
<button type="button" class="btn btn-sm btn-outline-secondary" @ref="previousButton" @onclick="PreviousAsync" disabled="@(!CanGoBack)" aria-label="Previous month">
47+
<Icon Name="IconName.ChevronLeft" aria-hidden="true" /><span class="ms-1 d-none d-sm-inline">Previous</span>
48+
</button>
49+
@* Announces the month shown after Previous, Next, or This month. *@
50+
<p class="ds-hc-shown" aria-live="polite">@monthName</p>
51+
<button type="button" class="btn btn-sm btn-outline-secondary" @ref="nextButton" @onclick="NextAsync" disabled="@(!CanGoForward)" aria-label="Next month">
52+
<span class="me-1 d-none d-sm-inline">Next</span><Icon Name="IconName.ChevronRight" aria-hidden="true" />
53+
</button>
54+
</div>
55+
<p class="small text-body-secondary d-flex flex-wrap align-items-center gap-2 mb-3">
56+
<span>Today is @LongDay(State.Today).</span>
57+
@if (month != StartOfMonth(State.Today))
58+
{
59+
<button type="button" class="btn btn-link btn-sm p-0" @onclick="ShowThisMonthAsync">Show this month</button>
60+
}
61+
</p>
62+
63+
@* A month grid where there is room; a list of runs of nights on narrower screens. Only one is displayed at a time. *@
64+
<div class="d-none d-lg-block">
65+
<table class="ds-hc-table">
66+
<caption>@monthName: nights of @stay.Name</caption>
67+
<thead>
68+
<tr>
69+
@foreach (var weekday in weekdays)
70+
{
71+
<th scope="col"><abbr title="@weekday">@weekday[..3]</abbr></th>
72+
}
73+
</tr>
74+
</thead>
75+
<tbody>
76+
@foreach (var week in Weeks(month))
77+
{
78+
<tr>
79+
@foreach (var day in week)
80+
{
81+
if (day is { } date)
82+
{
83+
var night = nights[date.Day - 1];
84+
<td class="ds-hc-day @KindClass(night.Kind) @(date == State.Today ? "ds-hc-is-today" : null)">
85+
<span class="ds-hc-num">
86+
<span aria-hidden="true">@date.Day</span><span class="visually-hidden">@date.ToString("MMMM d", CultureInfo.InvariantCulture)</span>
87+
</span>
88+
@if (date == State.Today)
89+
{
90+
<span class="ds-hc-today-tag">Today</span>
91+
}
92+
<span class="ds-hc-label">@KindText(night.Kind)</span>
93+
@if (night.Booking is { } booking)
94+
{
95+
<span class="ds-hc-detail">@ShortName(booking.GuestName)</span>
96+
@if (date == booking.CheckIn || date.DayOfWeek == DayOfWeek.Sunday || date.Day == 1)
97+
{
98+
<a class="ds-hc-detail" href="@ReservationUrl(booking.Reference)">@booking.Reference</a>
99+
}
100+
else
101+
{
102+
<span class="ds-hc-detail">@booking.Reference</span>
103+
}
104+
}
105+
else if (night.Block is { } block)
106+
{
107+
<span class="ds-hc-detail">@block.Note</span>
108+
}
109+
</td>
110+
}
111+
else
112+
{
113+
<td class="ds-hc-blank"></td>
114+
}
115+
}
116+
</tr>
117+
}
118+
</tbody>
119+
</table>
120+
</div>
121+
122+
<div class="d-lg-none">
123+
<ol class="ds-hc-agenda list-unstyled mb-0" aria-label="@($"{monthName}: nights of {stay.Name}")">
124+
@foreach (var run in Runs(nights))
125+
{
126+
<li class="ds-hc-run @KindClass(run.Kind)" @key="run.First">
127+
<span class="ds-hc-run-dates">@RangeText(run.First, run.Last)<span class="fw-normal text-body-secondary"> · @TravelDisplay.Nights(run.Last.DayNumber - run.First.DayNumber + 1)</span></span>
128+
<span class="ds-hc-run-what">
129+
<span class="ds-hc-label">@KindText(run.Kind)</span>
130+
@if (run.Booking is { } booking)
131+
{
132+
<span>@booking.GuestName, <a href="@ReservationUrl(booking.Reference)">@booking.Reference</a>@(booking.Status == TravelBookingStatus.Requested ? " (waiting for your answer)" : null)</span>
133+
}
134+
else if (run.Block is { } block)
135+
{
136+
<span>@block.Note</span>
137+
}
138+
@if (State.Today >= run.First && State.Today <= run.Last)
139+
{
140+
<span class="ds-hc-today-tag">Includes today</span>
141+
}
142+
</span>
143+
</li>
144+
}
145+
</ol>
146+
</div>
147+
148+
<ul class="ds-hc-legend" aria-label="Calendar key">
149+
<li><span class="ds-hc-swatch ds-hc-booked" aria-hidden="true"></span><strong>Booked:</strong> a confirmed guest is staying.</li>
150+
<li><span class="ds-hc-swatch ds-hc-requested" aria-hidden="true"></span><strong>Requested:</strong> a request waits for your answer; the nights are held.</li>
151+
<li><span class="ds-hc-swatch ds-hc-blocked" aria-hidden="true"></span><strong>Blocked:</strong> you closed the nights.</li>
152+
<li><span class="ds-hc-swatch ds-hc-free" aria-hidden="true"></span><strong>Free:</strong> guests can book.</li>
153+
</ul>
154+
<p class="small text-body-secondary mb-0">Each date is a night: a guest checks out on the morning of the day after their last night.</p>
155+
</section>
156+
157+
<div class="row g-4">
158+
<div class="col-xl-6">
159+
<section class="ds-panel h-100" aria-labelledby="ds-hc-block-title">
160+
<h2 class="h5 fw-bold" id="ds-hc-block-title">Block dates</h2>
161+
<p class="small text-body-secondary">Close nights you can't host, for up to @TravelState.MaxBlockNights nights at a time. The nights must be free: no booking, request, or other block.</p>
162+
<form @onsubmit="AddBlockAsync" novalidate>
163+
<div class="row g-3 mb-3">
164+
<div class="col-sm-6">
165+
<label class="form-label fw-semibold" for="ds-hc-first">First night</label>
166+
<DateInput @ref="firstInput" TValue="DateOnly" Id="ds-hc-first" Value="blockFirst" ValueExpression="() => blockFirst" ValueChanged="OnFirstChanged"
167+
Min="State.Today" Max="State.Today.AddDays(365)" EnableMinMax="true" aria-describedby="ds-hc-dates-error" />
168+
</div>
169+
<div class="col-sm-6">
170+
<label class="form-label fw-semibold" for="ds-hc-last">Last night</label>
171+
<DateInput TValue="DateOnly" Id="ds-hc-last" Value="blockLast" ValueExpression="() => blockLast" ValueChanged="OnLastChanged"
172+
Min="blockFirst" Max="State.Today.AddDays(365)" EnableMinMax="true" aria-describedby="ds-hc-dates-help ds-hc-dates-error" />
173+
</div>
174+
</div>
175+
<p class="form-text mt-n2" id="ds-hc-dates-help">@BlockSummary(stay)</p>
176+
<p class="ds-hc-error" id="ds-hc-dates-error" role="alert">@datesError</p>
177+
178+
<div class="mb-3">
179+
<label class="form-label fw-semibold" for="ds-hc-note">Note <span class="fw-normal text-body-secondary">(optional, only you see it)</span></label>
180+
<input @ref="noteInput" id="ds-hc-note" class="form-control @(noteError is null ? null : "is-invalid")" value="@blockNote" @oninput="OnNoteInput" autocomplete="off"
181+
aria-describedby="ds-hc-note-count ds-hc-note-error" aria-invalid="@(noteError is null ? null : "true")" />
182+
<div class="form-text @(blockNote.Trim().Length > MaxNoteLength ? "ds-hc-error" : null)" id="ds-hc-note-count">
183+
@CounterText(blockNote, MaxNoteLength). Without a note, the nights show as "Blocked".
184+
</div>
185+
<p class="ds-hc-error" id="ds-hc-note-error">@noteError</p>
186+
</div>
187+
188+
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary"><Icon Name="IconName.CalendarX" class="me-2" aria-hidden="true" />Block nights</Button>
189+
</form>
190+
</section>
191+
</div>
192+
193+
<div class="col-xl-6">
194+
<section class="ds-panel h-100" aria-labelledby="ds-hc-blocks-title">
195+
<h2 class="h5 fw-bold" id="ds-hc-blocks-title">Blocked dates of @stay.Name</h2>
196+
@{
197+
var blocks = State.BlocksFor(stay.Id);
198+
}
199+
@if (blocks.Count == 0)
200+
{
201+
<p class="small text-body-secondary mb-0">No blocked dates. Every night without a booking or request is open to guests.</p>
202+
}
203+
else
204+
{
205+
<ul class="ds-hc-blocks list-unstyled mb-0">
206+
@foreach (var block in blocks)
207+
{
208+
var blockKey = BlockKey(block);
209+
<li @key="blockKey">
210+
<div class="ds-hc-block-text">
211+
<span class="fw-semibold">@BlockRange(block)</span>
212+
<span class="small text-body-secondary">@TravelDisplay.Nights(block.End.DayNumber - block.Start.DayNumber)@(block.End <= State.Today ? ", past" : null)</span>
213+
<span class="small d-block">@block.Note</span>
214+
</div>
215+
<button type="button" class="btn btn-sm btn-outline-danger" @ref="removeButtons[blockKey]" @onclick="() => AskRemoveAsync(block)">
216+
Remove<span class="visually-hidden"> the block on @BlockRange(block)</span>
217+
</button>
218+
</li>
219+
}
220+
</ul>
221+
}
222+
</section>
223+
</div>
224+
</div>
225+
}
226+
</div>
227+
228+
@* Outside the branches, so the dialog is never removed while it is open. *@
229+
<Modal @ref="removeModal" IsVerticallyCentered="true" ShowCloseButton="false" aria-labelledby="ds-hc-remove-title" OnHidden="OnRemoveHiddenAsync">
230+
<HeaderTemplate>
231+
<h2 class="modal-title h5" id="ds-hc-remove-title">Remove the block on @(pendingBlock is null ? null : BlockRange(pendingBlock))?</h2>
232+
</HeaderTemplate>
233+
<BodyTemplate>
234+
@if (pendingBlock is { } shown)
235+
{
236+
var blockStay = State.FindStay(shown.StayId);
237+
<p class="mb-2">@TravelDisplay.Nights(shown.End.DayNumber - shown.Start.DayNumber) on @blockStay?.Name (@shown.Note).</p>
238+
<p class="mb-0">
239+
@(blockStay is { IsListed: true } ? "The nights become free, and guests can book them straight away." : "The nights become free. The listing is unlisted, so guests can book them once you list it again.")
240+
</p>
241+
}
242+
<p class="text-danger-emphasis fw-semibold small mt-2 mb-0" role="alert">@dialogError</p>
243+
</BodyTemplate>
244+
<FooterTemplate>
245+
<Button Color="ButtonColor.Secondary" Outline="true" @onclick="() => removeModal.HideAsync()">Keep block</Button>
246+
<Button Color="ButtonColor.Danger" @onclick="ConfirmRemoveAsync">Remove block</Button>
247+
</FooterTemplate>
248+
</Modal>

0 commit comments

Comments
 (0)