Repository navigation
Conversation
…Supabase URL from settings that are not defined, so every request fell through to shared mock totals.
…ruary check-in is March in Paris, and sub-cent bookings are rounded only after the sum.
…, and a property-only cache key was serving one client's totals to the other.
…properties now 404, and totals stay as cent strings instead of binary floats.
…nger lists the other company's properties or sends a simulated tenant header.
Comment on lines
39
to
49
| const fetchRevenue = async () => { | ||
| setLoading(true); | ||
| setError(''); | ||
| try { | ||
| // Use SecureAPI to handle authentication automatically | ||
| // We pass the simulatedTenant option which SecureAPI will attach as a header | ||
| const response = await SecureAPI.getDashboardSummary(propertyId, { | ||
| simulatedTenant: activeTenant, | ||
| timestamp: Date.now() | ||
| }); | ||
| const response = await SecureAPI.getDashboardSummary(propertyId, { month, year }); | ||
| setData(response); | ||
| } catch (err) { | ||
| setData(null); | ||
| setError('Failed to load revenue data'); | ||
| console.error(err); | ||
| } finally { |
There was a problem hiding this comment.
Bug: The fetch effect in RevenueSummary lacks a cancellation guard, causing out-of-order responses to overwrite current data when switching properties rapidly.
Severity: MEDIUM
Suggested Fix
Add a cleanup function inside the useEffect that toggles a cancelled boolean flag or aborts the request via AbortController, preventing state updates if the effect has re-run or unmounted.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: frontend/src/components/RevenueSummary.tsx#L38-L49
Potential issue: In `RevenueSummary`, the data fetching effect triggers on changes to
`propertyId`, `month`, and `year` without an `AbortController` or cancellation flag. If
a user quickly switches properties, an earlier slower request can resolve after a
subsequent request. The stale response will unconditionally update `data`, `loading`,
and `error`, causing the summary card to display data for a different property than what
is currently selected.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prop-001because the Redis key was only the property id, and both companies use that id. Cache keys now include the tenant, and each dashboard only lists that tenant's properties.DATABASE_URL. It had been using unset Supabase settings and falling back to the same mock totals for every client.Test plan
cd backend && PYTHONPATH=. python3 tests/test_revenue_rules.pydocker compose down -v && docker compose up --buildsunset@propertyflow.com/client_a_2024. Confirm only Sunset properties are listed, and Beach House Alpha shows USD 2,250.00 for March 2024 in Europe/Paris with 4 bookings.ocean@propertyflow.com/client_b_2024. Confirm Mountain Lodge Beta shows USD 0.00, and Lakeside Cottage and Urban Loft Modern are the only other properties.