TourIAm/TIAMSharedUI/Pages/TransferPage.razor

424 lines
16 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@page "/transfer"
@using AyCode.Core.Consts
@using AyCode.Core.Helpers
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Pages.Components.EditComponents
@using TIAMSharedUI.Shared
@using TIAMSharedUI.Shared.Components.BaseComponents
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using AyCode.Services.Loggers
@using TIAMSharedUI.Pages.User.Hotels
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Services
@using TIAMWebApp.Shared.Application.Utility
@inherits BasePageComponent
@inject NavigationManager navManager
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject IWizardProcessor WizardProcessor
@inject IUserDataService UserDataService
@inject AdminSignalRClient _adminSignalRClient
<PageTitle>Transfer</PageTitle>
<HeroSlider SliderItems="_sliders" Height="30vh"></HeroSlider>
<div class="container-fluid" style="position: relative; z-index: 2;">
<div class="row d-flex justify-content-center">
@{
if (_displayHelp)
{
<div class="col-md-6 col-12 px-5">
<!-- Step 1 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 1: Choose Your Transfer Direction
</p>
<p class="text-muted">At the top of the form, select whether you need a transfer <strong>"To the Airport"</strong> or <strong>"From the Airport"</strong> by clicking on the corresponding tab.</p>
</div>
</div>
<!-- Step 2 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 2: Enter the Destination (or Pickup) Address
</p>
<p class="text-muted">In the <strong>PickupAddress</strong> section, select your address:</p>
<ul>
<li><strong>Preset addresses:</strong> Click on the dropdown menu under “Preset addresses” and choose an address from the list. For example, you may see options like "Széchenyi fürdő."</li>
<li><strong>Custom address:</strong> If your address is not listed, click on the "Custom address" tab to manually enter your address.</li>
</ul>
</div>
</div>
<!-- Step 3 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 3: Confirm the Destination
</p>
<p class="text-muted">Once you select or enter the address, the form will display it as the "Selected address." Make sure this is correct before proceeding.</p>
</div>
</div>
<!-- Step 4 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 4: Enter Flight Information (Optional)
</p>
<p class="text-muted">If applicable, fill in your <strong>FlightNumber</strong>. This is optional, so you can leave it blank if you don't have or dont want to provide it.</p>
</div>
</div>
<!-- Step 5 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 5: Specify the Number of Passengers
</p>
<p>In the <strong>NumberOfPassengers</strong> field, enter the number of people who will be traveling. The default is set to 1, but you can change it as needed.</p>
</div>
</div>
<!-- Step 6 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 6: Indicate the Amount of Luggage
</p>
<p class="text-muted">In the <strong>NumberOfLuggage</strong> field, enter the total number of luggage items you will be bringing.</p>
</div>
</div>
<!-- Step 7 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 7: Fill in Your Personal Information
</p>
<p class="text-muted">Under <strong>FullName</strong>, enter your first and last name in the respective fields. Provide your <strong>PhoneNumber</strong> in the designated field. The phone number appears to be pre-filled with a sample number ("+11234567890"), so be sure to update it with your actual contact number. Enter your <strong>EmailAddress</strong> to receive confirmation and any further communication regarding your transfer.</p>
</div>
</div>
<!-- Step 8 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 8: Add Additional Comments (Optional)
</p>
<p class="text-muted">If you have any special requests or additional information youd like to provide, use the <strong>Comment</strong> section to do so.</p>
</div>
</div>
<!-- Step 9 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 9: Submit Your Request
</p>
<p>Once all fields are filled in correctly, click the <strong>Submit</strong> button at the bottom of the form to place your transfer order.</p>
</div>
</div>
<!-- Step 10 -->
<div class="card mb-3 shadow-sm">
<div class="card-body">
<p>
Step 10: Confirmation
</p>
<p>After submitting, you should receive a confirmation email or message. Ensure all the details are correct, and youre all set!</p>
</div>
</div>
</div>
}
}
<div class="col-12 col-md-6">
<DxToolbar ItemRenderStyleMode="ToolbarRenderStyleMode.Contained">
<Items>
<DxToolbarItem Alignment="ToolbarItemAlignment.Right" Text="Help" RenderStyle="ButtonRenderStyle.Secondary" IconCssClass="grid-icon-column-chooser" Click="ShowHelp_Click" />
</Items>
</DxToolbar>
<DxTabs>
<DxTabPage TabIconCssClass="fa-solid fa-plane-departure" Click="ToAirport" Text="To the Airport">
<DynamicEditForm Data="_myModel" TitleString="@($"To: {_myModel.Destination}")" isEditing="true" IgnoreReflection="_transferIgnorList1" OnSubmit="SubmitForm"></DynamicEditForm>
</DxTabPage>
<DxTabPage TabIconCssClass="fa-solid fa-plane-arrival" Click="FromAirport" Text="From the Airport">
<DynamicEditForm Data="_myModel" TitleString="@($"From: {_myModel.Destination}")" isEditing="true" IgnoreReflection="_transferIgnorList2" OnSubmit="SubmitForm"></DynamicEditForm>
</DxTabPage>
</DxTabs>
@* <InputWizard Data=@myModel
OnSubmit="SubmitForm"
IgnoreReflection="@TransferIgnorList"
SubmitButtonText="ButtonSend"
TitleResourceString="TransferTitle"
SubtitleResourceString="TransferSubtitle"></InputWizard> *@
</div>
</div>
</div>
<div class="container mt-5">
<div class="row align-items-center">
<div class="col-12 col-sm-6 p-5">
<h1>Book an Airport Transfer</h1>
<p>Welcome to Tour I Am! Book your airport transfer with us for a smooth and stress-free experience. Our professional drivers are ready to take you to and from the airport in comfort and style. We offer competitive rates and reliable service, ensuring you get to your destination on time.</p>
<h2>Why Choose Tour I Am?</h2>
<ul class="list-unstyled">
<li><strong>Reliable Service:</strong> Punctual pickups and drop-offs.</li>
<li><strong>Professional Drivers:</strong> Experienced and courteous drivers.</li>
<li><strong>Affordable Rates:</strong> Competitive pricing with no hidden fees.</li>
<li><strong>Comfortable Vehicles:</strong> Clean, modern, and well-maintained cars.</li>
</ul>
</div>
<div class="col-12 col-sm-6 p-5">
<img class="img-fluid" src="_content/TIAMSharedUI/images/about1.jpg" />
</div>
<div class="col-12 col-sm-6 p-5">
<img class="img-fluid" src="_content/TIAMSharedUI/images/about2.jpg" />
</div>
<div class="col-12 col-sm-6 p-5">
<h2>How to Book</h2>
<p>Booking your airport transfer is easy! Simply visit our <a href="/transfer">booking page</a>, enter your details, and confirm your reservation. You can also contact us at <a href="mailto:info@touriam.com">info@touriam.com</a> or call us at (123) 456-7890 for assistance.</p>
<p>Experience the convenience and reliability of Tour I Am. Book your airport transfer today and travel with peace of mind!</p>
</div>
</div>
</div>
@code {
private LoggerClient<TransferPage> _logger;
private readonly TransferWizardModel _myModel = new TransferWizardModel();
private readonly List<HeroSliderItem> _sliders =
[
new HeroSliderItem
{
Title = "Welcome to TIAM",
ImageUrl = "_content/TIAMSharedUI/images/f1_1.png"
},
new HeroSliderItem
{
Title = "Welcome to TIAM",
ImageUrl = "_content/TIAMSharedUI/images/f1_2.png"
},
new HeroSliderItem
{
Title = "Welcome to TIAM",
ImageUrl = "_content/TIAMSharedUI/images/f1_3.png"
}
];
private readonly List<string> _transferIgnorList1 =
[
"Id",
"Destination",
"UserId",
"ProductId",
"PaymentId",
"FirstName",
"LastName",
"UserProductMappingId",
"UserProductToCarId",
"ReferralId",
"Price"
];
private readonly List<string> _transferIgnorList2 =
[
"Id",
"PickupAddress",
"UserId",
"ProductId",
"PaymentId",
"FirstName",
"LastName",
"UserProductMappingId",
"UserProductToCarId",
"ReferralId",
"Price"
];
/*protected override void OnAfterRender(bool isFirst)
{
message = " Target destination is " + slider.SliderElementId.ToString();
}*/
private bool _toAirport = true;
private bool _displayHelp = false;
public void ToAirport()
{
_toAirport = true;
_myModel.Destination = "Budapest, 1185";
}
public void FromAirport()
{
_toAirport = false;
_myModel.PickupAddress = "Budapest, 1185";
}
public async Task SubmitForm(object result)
{
var resModel = (TransferWizardModel)result;
//let's check if user exists with this email
var user = await UserDataService.GetUserByEmailAsync(resModel.EmailAddress!);
if (user != null && user.Id != Guid.Empty)
{
resModel.UserId = user.Id;
//user exists already
if (_sessionService.User != null)
{
if (_sessionService.User.UserId == user.Id)
{
//I have ordered for myself
resModel.ReferralId = null;
}
else
{
//if I am logged in and different user I become referrer (if no referrer already)
var transferUserDetail = await UserDataService.GetUserDetailByIdAsync(user.Id);
var userDetail = await UserDataService.GetUserDetailByIdAsync(_sessionService.User.UserId);
if (transferUserDetail.UserDto.RefferalId != null)
{
//user has aready a referrer so we use that
resModel.ReferralId = transferUserDetail.UserDto.RefferalId;
}
else
{
//user has no referrer so I am the referrer
resModel.ReferralId = userDetail.UserDto.RefferalId;
}
}
}
}
else
{
//create a guest user and set referralId
var registration = new RegistrationModel();
var password = AcCharsGenerator.NewPassword(AcConst.MinPasswordLength, 16);
registration.Email = resModel.EmailAddress;
registration.PhoneNumber = resModel.PhoneNumber;
registration.Password = password;
//get list with one member!
var createResult = await UserDataService.CreateGuestUser(registration);
if (createResult.isSuccess)
{
if (createResult.user != null)
{
if (_sessionService.User != null)
{
//if I am logged in user I become referrer
var userDetail = await UserDataService.GetUserDetailByIdAsync(_sessionService.User.UserId);
var createdUserDetail = await UserDataService.GetUserDetailByIdAsync(createResult.user.Id);
if (createdUserDetail != null)
{
createdUserDetail.UserDto.RefferalId = userDetail.UserDto.RefferalId;
var updatedNewUser = await _adminSignalRClient.UpdateUserModelDtoDetail(userDetail);
if (updatedNewUser != null)
{
//referral set
}
else
{
//something wrong
}
}
resModel.ReferralId = userDetail.UserDto.RefferalId;
}
resModel.UserId = createResult.user.Id;
}
else
{
//some error handling
}
}
}
var transfer = await WizardProcessor.ProcessWizardAsync<TransferWizardModel>(result.GetType(), result);
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
navManager.NavigateTo($"/mytransfers/{resModel.Id}");
}
protected override Task OnInitializedAsync()
{
_logger = new LoggerClient<TransferPage>(LogWriters.ToArray());
ToAirport();
return base.OnInitializedAsync();
}
private void ShowHelp_Click()
{
_displayHelp = !_displayHelp;
}
}