Skip to content

Merge all open feature branches + admin whitelist management#418

Open
CasperL1218 wants to merge 73 commits intomainfrom
phase1-all-merges
Open

Merge all open feature branches + admin whitelist management#418
CasperL1218 wants to merge 73 commits intomainfrom
phase1-all-merges

Conversation

@CasperL1218
Copy link
Copy Markdown
Contributor

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:

  • apartment-component-documentation — Firebase import fix, JSDoc docs
  • deprecated-endpoints — Flag old save/landlord endpoints as deprecated
  • data-update — Unit tests, bulk apartment data migration script
  • bug_fixes — Map pin fix, force review on new apartment, search prompt
  • bugs-in-reviews — Landlord messaging feature, UX fixes
  • admin-data-edit — Admin apartment CRUD, room types schema, pagination
  • folder_system — User bookmarks/folders system
  • blog-post-feature — Blog post CRUD, admin gallery, DB init script
  • Admin whitelist management — Firestore-backed admin list with UI

Bug fixes made during review:

  • Email endpoint: moved landlordEmail/subject/message from URL params → req.body (security)
  • Schema migration: preserved legacy numBeds/numBaths/price as RoomType instead of wiping
  • Folder type: fixed apartmentIds → apartments field name mismatch
  • ContactModal: fixed wrong profanity error variable on review field

Test Plan

  • Admin page loads all tabs: Reviews, Contact, Blog Posts, Apartment Data, Dev Tools, Admin Management
  • Blog post create → publish → edit → archive → delete → recover flow
  • Folder system: create folder, add apartment, view folder detail page
  • Landlord messaging modal sends email successfully
  • Search results show "Can't find your apartment?" prompt

Notes

  • admin_newsletter branch intentionally excluded — batch sending is disabled and template uses placeholder
    content; needs rebuild before merging
  • Blog post feature requires running Initialize Collections in Dev Tools after first deployment to create the
    blogposts Firestore collection in prod
  • Admin whitelist: existing hardcoded admins (HomeConsts.ts) continue to work as superadmins; new admins can be
    added via the Admin Management tab without code changes

Breaking Changes

  • Database schema change: apartments collection migrated from numBeds/numBaths/price fields to roomTypes array
  • Database schema change: new folders collection added for bookmarks feature
  • Database schema change: new blogposts collection (requires init script on prod)
  • Database schema change: new adminWhitelist collection for dynamic admin management

parsa-tehranipoor and others added 30 commits May 27, 2025 00:20
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.
laurenp-2 and others added 20 commits February 27, 2026 11:39
- 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
  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
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

✅ CasperL1218
✅ laurenp-2
✅ parsa-tehranipoor
❌ Lauren Pothuru


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.

@dti-github-bot dti-github-bot requested a review from Destaq March 23, 2026 03:14
@dti-github-bot
Copy link
Copy Markdown
Member

[diff-counting] Significant lines: 9448. This diff might be too big! Developer leads are invited to review the code.

Copy link
Copy Markdown

@laurenp-2 laurenp-2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants