Skip to content

Feat/create message placeholder page#215

Closed
FrancoEspinosa08 wants to merge 3 commits intoStellar-Rent:mainfrom
FrancoEspinosa08:feat/create-message-placeholder-page
Closed

Feat/create message placeholder page#215
FrancoEspinosa08 wants to merge 3 commits intoStellar-Rent:mainfrom
FrancoEspinosa08:feat/create-message-placeholder-page

Conversation

@FrancoEspinosa08
Copy link
Contributor

@FrancoEspinosa08 FrancoEspinosa08 commented Jan 29, 2026

StellarRent Logo

Pull Request | StellarRent

📝 Summary

Provide a brief description of what this PR accomplishes.

🔗 Related Issues

Closes #(issue number) (Replace with the actual issue number).

🔄 Changes Made

Provide a general description of the changes. Include any relevant background information or context to help reviewers understand the purpose of this PR.

🖼️ Current Output

Provide visual evidence of the changes:

  • For small changes: Screenshots.
  • For large changes: Video or Loom link.

🧪 Testing

If applicable, describe the tests performed. Include screenshots, test outputs, or any resources that help reviewers understand how the changes were tested.

✅ Testing Checklist

  • Unit tests added/modified
  • Integration tests performed
  • Manual tests executed
  • All tests pass in CI/CD

⚠️ Potential Risks

List any possible issues that might arise with this change.

🚀 Next Steps & Improvements

This change lays a solid foundation for further optimizations. Some areas that could benefit from future improvements include:

  • 🔹 Performance optimization
  • 🔹 Increased test coverage
  • 🔹 Potential user experience enhancements

💬 Comments

Any additional context, questions, or considerations for reviewers.

Summary by CodeRabbit

  • New Features

    • Added a Messages page with local search and two-column chat UI.
  • Refactor

    • Restructured layout with updated navbar and right sidebar.
    • Consolidated menu items into a single shared menu.
    • Improved user-role resolution and loading state handling.
    • Enhanced payment config validation and more robust transaction handling.
  • Bug Fixes / UI

    • Updated site metadata and language settings (branding and locale).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

This PR restructures the app layout with Navbar and RightSidebar, adds a Messages page, consolidates menu item constants, reworks user role resolution to use profileAPI with localStorage fallback, and validates USDC/Stellar configuration while updating transaction handling to use XDR.

Changes

Cohort / File(s) Summary
Layout & Pages
apps/web/src/app/layout.tsx, apps/web/src/app/messages/page.tsx
RootLayout updated to include Navbar and RightSidebar; HTML/lang and metadata adjusted. New client-side Messages page added with two-column UI and local search state.
Menu Constants
apps/web/src/constants/menu-items.ts
Replaced scattered menu arrays with named ICON_* constants and a single GUEST_MENU_ITEMS array; other role menus now re-export copies of GUEST_MENU_ITEMS.
User Role Hook
apps/web/src/hooks/useUserRole.tsx
Replaced simple role lookup with API-driven resolution (uses profileAPI), computes role from hostStatus/hasProperties, persists fallbacks to localStorage, adds isLoading to return type (UseUserRoleReturn). Signature changed accordingly.
Stellar & Config
apps/web/src/lib/config/config.ts, apps/web/src/lib/stellar.ts
Added TESTNET_USDC_ISSUER fallback and guarded env lookup for USDC_ISSUER (warns instead of throwing). Introduced getUSDCAsset, switched payment/submit flows to use XDR-based transaction handling, and updated balance lookup to use resolved asset.
Search / Property Grid
apps/web/src/app/search/page.tsx
Switched PropertyGrid import from default to named import and adjusted rendering (uses local alias Grid); removed distance-based sorting logic; minor formatting tweaks.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant useUserRole
  participant profileAPI
  participant localStorage

  Client->>useUserRole: call hook (on mount)
  useUserRole->>profileAPI: fetchProfile(userId)
  alt API success
    profileAPI-->>useUserRole: profile { hostStatus, hasProperties }
    useUserRole->>localStorage: set hostStatus / hasProperties
    useUserRole-->>Client: return { role, canAccessHostDashboard, hasProperties, isLoading:false }
  else API failure
    profileAPI-->>useUserRole: error
    useUserRole->>localStorage: read hostStatus / hasProperties fallback
    useUserRole-->>Client: return { role (from fallback), isLoading:false }
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #109 — Modifies apps/web/src/lib/stellar.ts and USDC/Stellar payment flow; directly related to the Stellar changes here.
  • #179 — Directly changes useUserRole.tsx hook implementation and signature; strongly related to role-resolution changes.
  • #184 — Updates menu/sidebar items and usage; related to the consolidated menu-items.ts changes.

Poem

🐰 I hopped through Navbar halls, so bright and new,
Sidebars to the right, messages in view.
Icons gathered tidy, roles fetched with care,
Stellar coins validated, XDR in the air.
A rabbit's small cheer — code cleaned and true!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'Feat/create message placeholder page' is partially related to the changeset but does not accurately reflect the main changes. The PR includes significant changes beyond the messages page: layout restructuring, Stellar config updates, menu constants refactoring, and useUserRole hook reworking. Consider a more comprehensive title or breaking changes into multiple PRs.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@apps/web/src/app/layout.tsx`:
- Around line 5-18: RootLayout is missing the Providers wrapper so
context-dependent pieces (useAuth/useUserRole in RightSidebar, ThemeToggle in
Navbar, toasts) break; update RootLayout to wrap the app tree (Navbar, main
children, RightSidebar) with the existing Providers component (and include any
Toast/Theme providers that Providers normally supplies), remove the hardcoded
className="dark" from the <html> element so theme comes from the provider, and
ensure Providers is imported and used around the children and components
referenced (RootLayout, Navbar, RightSidebar, ThemeToggle).

In `@apps/web/src/app/messages/page.tsx`:
- Line 10: The container's height uses calc(100vh-64px) which mismatches the
Navbar's h-14 (56px) and the layout's pt-14, causing visual gap; update the div
in page.tsx (the element with className "flex h-[calc(100vh-64px)] ...") to
either use h-[calc(100vh-56px)] to match Navbar h-14 or replace the calc with
h-full and rely on the parent <main> sizing (and keep pt-14 on the layout),
ensuring the Navbar component (Navbar, h-14) and page padding remain consistent.

In `@apps/web/src/app/search/page.tsx`:
- Around line 78-79: PropertyGrid currently ignores passed props because it has
no props type and renders mockProperties; update PropertyGrid to accept a props
interface (e.g., PropertyGridProps with properties: Property[] and optional
onLoadMore: () => void), use those props inside the component to map properties
to PropertyCard and call/render onLoadMore for pagination, then remove the "as
any" alias in page.tsx so the real typing error surfaces and the caller passes
its properties and onLoadMore correctly to PropertyGrid.

In `@apps/web/src/lib/config/config.ts`:
- Around line 26-28: The thrown Error referencing the USDC issuer uses the short
name "USDC_ISSUER_MAINNET" but should reference the actual env var
NEXT_PUBLIC_USDC_ISSUER_MAINNET; update the error thrown where rawIssuer is
validated (the block that throws new Error("CRITICAL: USDC_ISSUER_MAINNET is not
defined...")) to mention NEXT_PUBLIC_USDC_ISSUER_MAINNET so the message
accurately reflects the expected environment variable.
- Line 14: Replace the incorrect hardcoded constant by updating
TESTNET_FALLBACK_ISSUER to the correct Stellar testnet USDC issuer; locate the
constant named TESTNET_FALLBACK_ISSUER and set its value to
"GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5".
🧹 Nitpick comments (6)
apps/web/src/app/messages/page.tsx (1)

7-7: Unused state: searchQuery is captured but never used.

The search input updates searchQuery state but it's not used for any filtering or API calls. If this is intentional for the placeholder, consider adding a brief comment. Otherwise, this is dead code.

apps/web/src/hooks/useUserRole.tsx (3)

78-78: API errors are silently discarded; consider logging for debugging.

The API error is caught but not logged, making it difficult to diagnose why the fallback path is being used.

Suggested fix
-        } catch (_apiError) {
+        } catch (apiError) {
+          console.warn('Failed to fetch user profile, falling back to localStorage:', apiError);
           // Fallback to localStorage if API fails

45-109: Nested try blocks add complexity; the outer try has no catch.

The outer try (Line 45) has no corresponding catch—only a finally. The inner try (Line 48) handles all errors. This structure is confusing and the outer try serves no purpose.

Suggested simplification
-      try {
-        setIsLoading(true);
-
-        try {
+      setIsLoading(true);
+      try {
           const response = await profileAPI.getUserProfile(userId);
           // ... success handling ...
-        } catch (_apiError) {
+      } catch (apiError) {
+        console.warn('Failed to fetch user profile:', apiError);
         // Fallback to localStorage if API fails
         // ... fallback handling ...
-        }
       } finally {
         setIsLoading(false);
       }

59-65: Clarify: verified hosts without properties cannot access host dashboard.

Line 64 sets canAccessHostDashboard = false for the 'host' role (verified but no properties). If this is intentional business logic (hosts need at least one property to access the dashboard), a brief comment would help future maintainers.

apps/web/src/lib/stellar.ts (1)

87-93: Consider passing networkPassphrase to Freighter's signTransaction for explicit network validation.

While the Freighter API's signTransaction accepts networkPassphrase as an optional parameter, explicitly passing it ensures the wallet signs for the intended network rather than relying on implicit default behavior.

Suggested improvement
     // `@ts-ignore`: Freighter API global access
-    const signedTransaction = await window.freighterApi.signTransaction(transactionXDR);
+    const signedTransaction = await window.freighterApi.signTransaction(transactionXDR, {
+      networkPassphrase: NETWORK_PASSPHRASE,
+    });
apps/web/src/constants/menu-items.ts (1)

28-30: Consider isolating role menus from shared object mutation.
Line 28–30 creates new arrays but reuses the same item objects; if any downstream code mutates a menu item (e.g., adds an active flag), the change will bleed across roles. If mutation is possible, clone items per role or freeze the base list.

♻️ Possible defensive clone
-export const TENANT_MENU_ITEMS: MenuItem[] = [...GUEST_MENU_ITEMS];
-export const HOST_MENU_ITEMS: MenuItem[] = [...GUEST_MENU_ITEMS];
-export const DUAL_MENU_ITEMS: MenuItem[] = [...GUEST_MENU_ITEMS];
+export const TENANT_MENU_ITEMS: MenuItem[] = GUEST_MENU_ITEMS.map((item) => ({ ...item }));
+export const HOST_MENU_ITEMS: MenuItem[] = GUEST_MENU_ITEMS.map((item) => ({ ...item }));
+export const DUAL_MENU_ITEMS: MenuItem[] = GUEST_MENU_ITEMS.map((item) => ({ ...item }));

Comment on lines +78 to +79
// Alias para evitar el error de IntrinsicAttributes
const Grid = PropertyGrid as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

The as any cast masks a real bug: PropertyGrid ignores the passed props.

Per the relevant snippet from PropertyGrid.tsx (lines 128-136), the component accepts no props and renders mockProperties directly. The passed properties and onLoadMore props on Line 102 are silently ignored, meaning:

  • Filtering/sorting logic (Lines 35-58) has no effect on rendered output
  • Pagination via loadNextPage doesn't work
  • Users always see hardcoded mock data regardless of filters

The as any cast hides the TypeScript error that would have caught this.

Recommended approach

Update PropertyGrid to accept and use props:

// In PropertyGrid.tsx
interface PropertyGridProps {
  properties: Property[];
  onLoadMore?: () => void;
}

export const PropertyGrid = ({ properties, onLoadMore }: PropertyGridProps) => {
  return (
    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
      {properties.map((property) => (
        <PropertyCard key={property.id} property={property} />
      ))}
      {onLoadMore && (
        <button onClick={onLoadMore}>Load More</button>
      )}
    </div>
  );
};

Then remove the as any cast in this file:

-  // Alias para evitar el error de IntrinsicAttributes
-  const Grid = PropertyGrid as any;
   ...
-  <Grid properties={visibleProperties} onLoadMore={loadNextPage} />
+  <PropertyGrid properties={visibleProperties} onLoadMore={loadNextPage} />

Also applies to: 102-102

🤖 Prompt for AI Agents
In `@apps/web/src/app/search/page.tsx` around lines 78 - 79, PropertyGrid
currently ignores passed props because it has no props type and renders
mockProperties; update PropertyGrid to accept a props interface (e.g.,
PropertyGridProps with properties: Property[] and optional onLoadMore: () =>
void), use those props inside the component to map properties to PropertyCard
and call/render onLoadMore for pagination, then remove the "as any" alias in
page.tsx so the real typing error surfaces and the caller passes its properties
and onLoadMore correctly to PropertyGrid.

Comment on lines 26 to 28
if (!rawIssuer) {
throw new Error("CRITICAL: USDC_ISSUER_MAINNET is not defined in environment variables.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Error message should reference the full env var name.

The error mentions "USDC_ISSUER_MAINNET" but the actual env var is NEXT_PUBLIC_USDC_ISSUER_MAINNET.

Suggested fix
-      throw new Error("CRITICAL: USDC_ISSUER_MAINNET is not defined in environment variables.");
+      throw new Error("CRITICAL: NEXT_PUBLIC_USDC_ISSUER_MAINNET is not defined in environment variables.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!rawIssuer) {
throw new Error("CRITICAL: USDC_ISSUER_MAINNET is not defined in environment variables.");
}
if (!rawIssuer) {
throw new Error("CRITICAL: NEXT_PUBLIC_USDC_ISSUER_MAINNET is not defined in environment variables.");
}
🤖 Prompt for AI Agents
In `@apps/web/src/lib/config/config.ts` around lines 26 - 28, The thrown Error
referencing the USDC issuer uses the short name "USDC_ISSUER_MAINNET" but should
reference the actual env var NEXT_PUBLIC_USDC_ISSUER_MAINNET; update the error
thrown where rawIssuer is validated (the block that throws new Error("CRITICAL:
USDC_ISSUER_MAINNET is not defined...")) to mention
NEXT_PUBLIC_USDC_ISSUER_MAINNET so the message accurately reflects the expected
environment variable.

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.

1 participant