vault backup: 2025-06-29 13:49:40
This commit is contained in:
+9
@@ -1,3 +1,12 @@
|
||||
|
||||
### ⚠ Important Tip
|
||||
If your `agent.ts` uses `useAuthStore().token` **at the top level**, remember:
|
||||
- On very first load, Zustand will **rehydrate** from storage _after_ initial render, so token may be `null` until rehydration is done.
|
||||
- Fix: either delay access until after `hasHydrated`, or refactor `agent` to inject token per request.
|
||||
|
||||
|
||||
|
||||
|
||||
To **safely handle concurrency** in your `CreateTicketOrderAsync` method — particularly for **seat reservation** on the same `Transportation` — you need to **prevent race conditions** where two users might reserve the same seat or oversell capacity.
|
||||
|
||||
This is a **classic critical section problem**, and you can solve it using **application-level locking**, **database-level locking**, or both.
|
||||
@@ -1,14 +1,131 @@
|
||||
Endpoint for increasing balance
|
||||
Endpoint for reserving ticket(s) + updating transportation remaining count + adding transaction
|
||||
Endpoint for getting seats + seeing if each is reserved or not
|
||||
Creating and sending a pdf downloadable ticket
|
||||
Here's a **structured checklist document**, broken into **sections by feature area**. Each section contains tasks in implementation order (oldest to newest), rephrased as clear action items with contextual notes for implementation.
|
||||
These are created based on this commit messages:
|
||||
https://github.com/MehrdadShirvani/AlibabaClone-Backend/commits/develop/
|
||||
|
||||
---
|
||||
# Miscellaneous / Fixes
|
||||
|
||||
- [ ] Fix GUID generation and async handling in ticket creation. (Use `Guid.NewGuid()` instead of `new Guid()`)
|
||||
- [ ] Make `SerialNumber`, `TicketOrderId`, `BaseAmount` publicly settable in DTOs.
|
||||
- [ ] Fix issues in seat mappings and transportation queries.
|
||||
# Fixes and Missing Parts from Session 08
|
||||
|
||||
## 👤 Person & Account Info
|
||||
|
||||
- [ ] Add `Person`, `BankAccountDetail`, and navigation properties.
|
||||
- [ ] Add `UpsertPersonAsync` and `UpsertBankAccountDetailAsync` in `IAccountService`.
|
||||
- [ ] Add `UpsertPerson`, `UpsertBankDetail` endpoints in `AccountController`.
|
||||
- [ ] Add `GetPeople`, `GetProfileAsync`, and DTOs (`ProfileDto`, `PersonDto`, `BankAccountDetailDto`).
|
||||
- [ ] Handle person editing logic via `UpsertPerson` and adjust classes that used it the old way.
|
||||
## 🔐 Auth & Settings
|
||||
|
||||
- [ ] Complete the error handling of `EditEmailDto`, `EditPasswordDto`.
|
||||
- [ ] Add `GetByEmailAsync` in `AccountRepository`.
|
||||
|
||||
|
||||
|
||||
### ⚠ Important Tip
|
||||
# Branching
|
||||
- [ ] Create the feature/ticket-reservation branch based on develop
|
||||
|
||||
# Ticket Ordering System
|
||||
|
||||
## 🧱 Domain and Infrastructure Setup
|
||||
|
||||
- [ ] Check out new ERD: [Here](https://github.com/TheOrderOfPhoenix/ASP.NET/blob/main/ProjectOrientedSessions/docs/AlibabaERD-Version02.pdf)
|
||||
- [ ] Create `TicketOrder`, `Ticket`, and `Transaction` entities.
|
||||
- [ ] Add configurations for `TicketOrder`, `Ticket`, and `Transaction` (relationships, constraints).
|
||||
- [ ] Adjust `Transportation` entity configuration to support ticketing.
|
||||
- [ ] Add migrations for the above database changes.
|
||||
|
||||
## 🧑💼 Service Layer
|
||||
|
||||
- [ ] Create `ITicketOrderService`, `TicketOrderService` and implement:
|
||||
- [ ] `CreateTicketOrderAsync`
|
||||
- [ ] `GenerateTicketsPdfAsync`
|
||||
- [ ] Register `TicketOrderService` in DI container.
|
||||
|
||||
## 🎯 Controller Layer
|
||||
|
||||
- [ ] Create `TicketOrderController` with the following endpoints:
|
||||
- [ ] `POST /CreateTicketOrder`
|
||||
- [ ] `GET /DownloadPdf`
|
||||
|
||||
## 🔁 DTOs & Mappings
|
||||
|
||||
- [ ] Add `CreateTicketOrderDto`, `CreateTravelerTicketDto`.
|
||||
- [ ] Add `TicketOrderSummaryDto`, `TravelerTicketDto`.
|
||||
- [ ] Add mappings in `MappingProfile`.
|
||||
|
||||
## 🗃️ Repository Layer
|
||||
|
||||
- [ ] Create `ITicketOrderRepository`, `TicketOrderRepository`.
|
||||
- [ ] Implement:
|
||||
- [ ] `FindAndLoadAllDetails`
|
||||
- [ ] `GetAllByBuyerId`
|
||||
|
||||
---
|
||||
|
||||
# Transportation and Seat Selection
|
||||
|
||||
- [ ] Add `TransportationSeatDto`.
|
||||
- [ ] Add method `GetSeatsByVehicleId` in `ISeatRepository` and implement it.
|
||||
- [ ] Add mapping from `Seat` to `TransportationSeatDto`.
|
||||
- [ ] Add `GetTransportationSeatsAsync` in `ITransportationService` and implement.
|
||||
- [ ] Add `GetTransportationSeats` endpoint in `TransportationController`.
|
||||
- [ ] Fix vehicle and seat-related mapping issues (e.g., missing `VehicleTypeId`, logic errors).
|
||||
- [ ] Ensure `RemainingCapacity` is treated as calculated (ignored in EF, removed from schema).
|
||||
|
||||
---
|
||||
|
||||
# Coupon System
|
||||
|
||||
## 🏗️ Domain & Infrastructure
|
||||
- [ ] Add `Coupon` entity with `IsExpired`, `CouponCode` (unique).
|
||||
- [ ] Add `ICouponRepository`, `CouponRepository`.
|
||||
- [ ] Add `DiscountDto`, `CouponValidationRequestDto`.
|
||||
- [ ] Add migrations for new `Coupon` table.
|
||||
|
||||
### 🧑💼 Service & Logic
|
||||
- [ ] Create `ICouponService`, implement validation logic.
|
||||
- [ ] Add coupon validation in `TicketOrderService`.
|
||||
### 🎯 Controller
|
||||
- [ ] Add `ValidateCoupon` endpoint in `CouponController`.
|
||||
|
||||
---
|
||||
|
||||
# Payment & Transactions
|
||||
|
||||
- [ ] Add `CouponId` to `PayForTicketOrderAsync` in `IAccountService` & implementation.
|
||||
- [ ] Add `CouponId` to `TransactionDto` (adjusted to `CouponCode` later).
|
||||
- [ ] Add `TopUpAccount` logic (DTO, Controller, Service).
|
||||
- [ ] Add `Transaction` relationship to `TicketOrder` as one-to-one.
|
||||
- [ ] Add logic for creating transactions with tickets.
|
||||
- [ ] Add endpoint `GetMyTransactions` and DTOs (`TransactionDto`).
|
||||
|
||||
---
|
||||
|
||||
## ✅ Ticket Review & Confirmation
|
||||
|
||||
- [ ] Add `TicketOrderSummaryDto`, map details: from/to city, company, vehicle, time.
|
||||
- [ ] Implement `GetTravelOrderDetails` endpoint to fetch ticket summary.
|
||||
- [ ] Display number of travelers, per-seat price, and total cost.
|
||||
- [ ] Include coupon entry and balance payment option.
|
||||
- [ ] Use ticket + person data (via `GetTicketOrderTravelersDetails`).
|
||||
|
||||
---
|
||||
|
||||
## ✅ PDF Generation
|
||||
|
||||
- [ ] Install `QuestPDF` in infrastructure.
|
||||
- [ ] Create `IPdfGenerator`, implement with QuestPDF.
|
||||
- [ ] Register `IPdfGenerator` service.
|
||||
- [ ] Create `PdfGenerator` logic to render ticket PDFs.
|
||||
- [ ] Add PDF download endpoint (`DownloadPdf`) in `TicketOrderController`.
|
||||
---
|
||||
# Merge
|
||||
- [ ] Create a PR and merge the current branch with develop
|
||||
|
||||
|
||||
---
|
||||
|
||||
If your `agent.ts` uses `useAuthStore().token` **at the top level**, remember:
|
||||
|
||||
- On very first load, Zustand will **rehydrate** from storage _after_ initial render, so token may be `null` until rehydration is done.
|
||||
|
||||
- Fix: either delay access until after `hasHydrated`, or refactor `agent` to inject token per request.
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# Reservation System Development Guide
|
||||
|
||||
This guide helps developers understand how to implement, update, and maintain the ticket reservation system. It summarizes changes from commits and provides step-by-step actions, grouped by feature area.
|
||||
https://github.com/MehrdadShirvani/AlibabaClone-Frontend/commits/develop/
|
||||
---
|
||||
|
||||
# Fixes and Missing Things from Session 08
|
||||
## Authentication & Protected Routes
|
||||
|
||||
- [ ] Store `showLoginModal` state in `authStore` and adjust navbar
|
||||
- [ ] Add `ProtectedRoute` component
|
||||
- [ ] Adjust main `App` to route authenticated pages through protection layer
|
||||
- [ ] Add session persistence in `authStore` to store token more persistently
|
||||
|
||||
---
|
||||
## Profile and User Info Enhancements
|
||||
|
||||
- [ ] Fix and align `birthDate` types in `PersonDto`, `transportationSearchResult`, and `ListOfTravelers`
|
||||
## Agent
|
||||
- [ ] Add `topUpDto` and its method in `agent.ts`
|
||||
- [ ] Add optional config parameter to `request()` in `agent.ts`
|
||||
|
||||
# Branching
|
||||
- [ ] Create the feature/themes branch based on develop
|
||||
# 🎨 Theming and UI Styling
|
||||
- [ ] Install and import `preline`
|
||||
- [ ] Add theme colors and global styles (index.css)
|
||||
- [ ] Add `ThemeSwitcher` and integrate it into the navbar
|
||||
- [ ] If you decide to do this part after implementing pages, make sure to add theme support to the following components:
|
||||
- [ ] `transportationCard`, `transportationSearchForm`, `ReviewAndConfirm`
|
||||
- [ ] All modals: `LoginModal`, `RegisterModal`, `SelectFromPeopleModal`
|
||||
- [ ] Profile section: `ProfilePage`, `ProfileSummary`, `PersonalInformation`, `AccountInfo`, `PersonalAccountInfo`, `BankAccountDetails`, `MyTravels`, `MyTransactions`, `ListOfTravelers`
|
||||
- [ ] Reservation views and components
|
||||
|
||||
# Merge
|
||||
- [ ] Create a PR and merge the current branch with develop
|
||||
---
|
||||
# Branching
|
||||
- [ ] Create the feature/ticket-reservation branch based on develop
|
||||
# Backend Agent Methods
|
||||
- [ ] Add `createTicketOrderDto` and `createTravelerTicketDto`
|
||||
- [ ] Add `transportationSeatDto`
|
||||
- [ ] Add related methods in `TicketOrder` and add it to agent
|
||||
|
||||
# Reservation Process & Step Management
|
||||
|
||||
- [ ] Implement `useReservationStore` using `zustand` to manage reservation state
|
||||
- [ ] Create step-based routing using `ReservationLayout`
|
||||
- [ ] Add routing for reservation steps in `App.tsx`
|
||||
- [ ] Add `StepIndicator` component to show step progress visually
|
||||
- [ ] Add `stepGuard` logic to prevent accessing future steps prematurely
|
||||
- [ ] Add logic to skip back only if previous steps are completed
|
||||
- [ ] Create `TravelerForm` to gather passenger info, with the possibility to load data from the related people of the account.
|
||||
- [ ] Create `TravelerDetailsForm` to gather passengers info with `TravelerForm` integration
|
||||
- [ ] Create `ReviewAndConfirm` page to review selections
|
||||
- [ ] Create `PaymentForm` for transaction process
|
||||
- [ ] Create `TicketIssued` page for confirmation
|
||||
- [ ] Add validation to show error if `seatId` is missing
|
||||
|
||||
---
|
||||
# Seat Selection
|
||||
- [ ] Add DTO:
|
||||
```tsx
|
||||
export interface transportationSeatDto{
|
||||
id : number,
|
||||
vehicleId : number,
|
||||
row : number,
|
||||
column : number,
|
||||
isVIP : boolean,
|
||||
isAvailable : boolean,
|
||||
description : string | null,
|
||||
isReserved : boolean,
|
||||
genderId : number | null
|
||||
}
|
||||
```
|
||||
- [ ] Add `getSeats()` method to `agent.ts`
|
||||
- [ ] Add `SeatGridSelector` component for graphical seat layout in `TravelerDetailForm` and integrate it with traveler list, only for Buses
|
||||
- [ ] Modify `transportationCard` to integrate with seat selection
|
||||
- [ ] Add `SeatOnlyGridSeatMap` for simpler seat-only display
|
||||
---
|
||||
# Coupon Integration
|
||||
|
||||
- [ ] Add `couponValidationRequestDto` and `discountDto`
|
||||
- [ ] Add `validateCoupon()` method to `agent.ts`
|
||||
- [ ] Update `useReservationStore` to include `couponCode`
|
||||
- [ ] Ensure `createTicketOrderDto` uses `couponCode` instead of `couponId`
|
||||
- [ ] Connect coupon validation flow in `ReviewAndConfirm`
|
||||
|
||||
---
|
||||
# Search, Filter, and Sort Functionality
|
||||
|
||||
- [ ] Add filters (company) and sorting (time or price) UI to `SearchResultPage`
|
||||
- [ ] Add company logo support in result cards and filters
|
||||
- [ ] Add `previous/next day` buttons for time navigation
|
||||
- [ ] Add remaining capacity check to transportation cards
|
||||
- [ ] Add refund policy info display
|
||||
- [ ] Implement showing seat map in `TransportaionCard` using `ReadOnlySeatMap`
|
||||
|
||||
## 📎 Notes
|
||||
|
||||
- Ensure you run a full theme test after UI changes.
|
||||
- Test step transitions with various invalid scenarios.
|
||||
- Confirm persistent session and coupon behavior across refreshes.
|
||||
- Validate all filters, sort, and search navigation works.
|
||||
- Test seat selection and proper rendering of rotated layouts.
|
||||
|
||||
---
|
||||
|
||||
# Merge
|
||||
- [ ] Create a PR and merge the current branch with develop
|
||||
|
||||
Reference in New Issue
Block a user