Merge all open feature branches + admin whitelist management#418
Merge all open feature branches + admin whitelist management#418CasperL1218 wants to merge 73 commits intomainfrom
Conversation
Merge main repository code to current branch
\ - Implemented apartment information edit endpoint - Implemented create new apartment endpoint - Implemented admin page apartment pagination, sorting, and editing functionalities
- Implement folder page to display user folders - Add folder card component for folder representation - Added 'add to folder' button in apartment page - Debugged authentication issues in folder operations
Backend Changes:
- Add RoomType interface with UUID-based IDs (beds, baths, price)
- Replace single numBeds/numBaths/price fields with roomTypes array
- Add migration endpoint POST /api/admin/migrate-all-apartments-schema
- Supports dry run mode for preview
- Batch processing (100 apartments per batch)
- Initializes roomTypes as empty array and removes old fields
- Update PUT /api/admin/update-apartment to handle roomTypes
- Generate UUIDs for new room types
- Validate beds/baths/price >= 1 (integers only)
- Check for duplicate room type combinations
- Update POST /api/admin/add-apartment to accept roomTypes
- Same validation and UUID generation
- Allow empty roomTypes array
- Update add_buildings.ts script to use new schema
Frontend Changes (Temporary):
- Comment out old bed/bath/price displays in ApartmentCard
- Comment out bed display in NewApartmentCard
- Update price sorting to use avgPrice temporarily
- Proper room type display will be implemented in future commits
- Proper room type sorting will be implemented in future commits
Note: All apartments will start with empty roomTypes after migration.
Frontend integer validation for admin UI will be added in following commits.
Admin Page Room Type Management
- Added room types editing modal with table UI for beds/baths/price
- Displays existing room types with inline editing and delete functionality
- Includes "Add Room Type" button with validation (>= 1 for all fields)
- Checks for duplicate room types (same beds/baths/price combination)
- Backend generates UUIDs for new room types automatically
- Shows room type count in Data tab instead of old numBeds/numBaths fields
- Displays room type IDs (truncated) for debugging
Room Type Display Utilities and Card Updates
- Created roomTypeUtils.ts with comprehensive display functions:
- formatPrice: Formats prices with K suffix (e.g., $1.5K, $3K)
- formatBeds/formatBaths: Formats bed/bath counts (e.g., "2 beds", "1 bath")
- getRoomTypeRange: Gets min/max values for beds/baths/price
- formatPriceRange: Formats price ranges (e.g., "$1.5K - $3K")
- formatRoomTypesDisplay: Complete display string for cards
- getMinPrice/getMaxPrice: Helper functions for sorting
- Updated NewApartmentCard to display dynamic price ranges from room types
- Shows "Coming soon" when no room types are available
- Update ApartmentCard component to display room type information
- Add imports for formatPriceRange, formatBedsRange, getRoomTypeRange utilities
- Replace TODO section with dynamic room types display
- Show "Coming soon" message for apartments with empty roomTypes
- Display formatted price and bed ranges for apartments with room types data
- Implement comprehensive search filtering with room types support
- Re-enable price, bedroom, and bathroom filter parameters
- Add exact match filtering for beds/baths (not >=)
- Implement additional search result sections (location, price, bed/bath)
- Return structured response with main results + 3 additional sections
- Filter apartments based on roomTypes array instead of old schema
- Handle empty roomTypes arrays in filter logic
- Update search results page to support additional sections
- Add state variables for additionalLocation, additionalPrice, additionalBedBath
- Prepare frontend for displaying multiple result sections
- Enhance apartment sorting with room types
- Use getMinPrice/getMaxPrice utilities for sorting by price
- Sort by minimum price (cheapest) or maximum price (most expensive)
- Handle apartments with empty roomTypes arrays
This completes the frontend display implementation for the room types refactor.
Backend migration tools and admin CRUD are already in place from previous commits.
Ready for data migration and testing.
…ayout
- Rename "Data" tab to "Apartment Data" for clarity
- Remove test apartments pagination and filtering logic
- Add real-time search functionality:
- Search by apartment name
- Search by apartment address
- Both searches reset pagination to first page
- Add room types filter dropdown:
- All Apartments (default)
- With Room Types (show only apartments with room types data)
- Without Room Types (show only apartments missing room types)
- Reorganize apartment display with horizontal card layout:
- Replace vertical list with compact card-based design
- Organize information in 3 responsive columns (Location, Details, Stats)
- Add visual distinction for apartments without room types (gray italic)
- Position edit button in top-right corner of each card
- Reduce vertical space usage by ~50%
- Update display counter to show filtered vs total apartment counts
- Simplify pagination logic by removing test apartment handling
- Improve visual hierarchy with section labels and consistent spacing
This makes it easier for admins to find and manage apartments,
especially when populating room types data after migration.
- Add "Create New Apartment" button in Apartment Data tab header
- Implement two-step apartment creation workflow:
1. Preview mode: Calculate location data from address
2. Confirm mode: Create apartment in database
- Create modal dialog with required fields:
- Apartment Name (text input)
- Full Address (text input with geocoding support)
- Landlord ID (text input)
- Area (dropdown: Collegetown, West, North, Downtown, Other)
- Display preview of calculated location data before creation:
- Show latitude and longitude from geocoded address
- Show calculated distance to campus
- Confirm before final creation
- Add comprehensive error handling and validation:
- Form validation for required fields
- Backend error display in modal
- Loading states for preview and create actions
- Integrate with existing `/api/admin/add-apartment` endpoint
- Endpoint automatically geocodes address to get coordinates
- Calculates walking distance to Ho Plaza
- Validates landlord exists
- Checks for duplicate locations
- Auto-reload apartment list after successful creation
- Show success message with generated apartment ID
This streamlines the apartment creation process for admins by
automating location data calculation and providing validation
before committing changes to the database.
- Added scripts to export apartment data to CSV and update apartment data from CSV - Updated package.json with new script commands for data export and update
4.9.5, pin @types/react to ^17
project documentation style guide, add local files to gitignore
…unused dayjs/react-datepicker deps
…ntry instead of discarding
Aligns common/types/db-types.ts with the actual Firestore field name used by all backend endpoints and frontend components.
Adds user folder/bookmark system — folder CRUD endpoints, AddToFolderPopover component, FolderCard, FolderSection, BookmarksPage integration, and FolderDetailPage. Conflict resolutions: kept dynamic priceDisplay over hardcoded values, preserved landlord messaging feature from bugs-in-reviews, kept both firebase and AddToFolderPopover imports.
- Resolved AdminPage.tsx conflicts: kept both blog post tab and apartment
data/dev tools tabs from main's admin-data-edit merge
- Resolved app.ts conflicts: kept BlogPost types + Folder types + both
blogPostCollection and folderCollection declarations
- Removed duplicate axios/firebase imports introduced by merge
- Fixed onEditorChange implicit any in TinyMCE Editor
- Removed unused firebase import in BlogPostDetailPage.tsx
- Added backend/scripts/init_blogposts_collection.ts (idempotent Firestore
init script for prod)
- Added POST /api/admin/init-collections endpoint (admin-authenticated)
- Added Database Initialization section to Dev Tools tab in AdminPage
Moves admin access from hardcoded-only to Firestore-backed:
- backend/src/authAdmin.ts: new authenticateAdmin middleware that checks
both hardcoded superadmins AND Firestore adminWhitelist collection
- GET /api/is-admin: async admin check for frontend
- GET/POST/DELETE /api/admin/whitelist: CRUD endpoints for Firestore whitelist
- App.tsx: async isAdminUser state via /api/is-admin so Firestore-added
admins can access /admin route without a redeploy
- AdminPage.tsx: new Admin Management tab with add/remove + confirmation
|
Lauren Pothuru seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
[diff-counting] Significant lines: 9448. This diff might be too big! Developer leads are invited to review the code. |
laurenp-2
left a comment
There was a problem hiding this comment.
As all these features have already been reviewed in their own PRs, I'll omit a full length feature-by-feature review. The only key issue is that we're migrating from node 16 -> 18, which is potentially a breaking change and should probably be mentioned as such.
Otherwise this is good to go!
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 16 | ||
| node-version: 18 |
There was a problem hiding this comment.
Make sure to note this as a breaking change in the PR description (I got dependency version issues with ts-node and a few other dependencies as a result)
Summary
This PR brings in all open contributor branches, resolves conflicts between them, fixes bugs found during review,
and adds admin whitelist management.
Merged branches:
Bug fixes made during review:
Test Plan
Notes
content; needs rebuild before merging
blogposts Firestore collection in prod
added via the Admin Management tab without code changes
Breaking Changes