Add seenByTenant tracking feature
- Add seenByTenant field to BillingLocation interface - Implement setSeenByTenant function to mark locations as viewed by tenant - Checks if flag is already set to avoid unnecessary DB updates - Includes TypeDoc documentation - Update LocationViewPage to call setSeenByTenant when non-owner visits - Add seenByTenant to fetchAllLocations projection - Update LocationCard to show "seen by tenant" status indicator - Displays in "Monthly statement" fieldset with checkmark icon - Shows alongside monthly expense total - Add localization strings for monthly statement and seen status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ViewLocationCard } from '@/app/ui/ViewLocationCard';
|
||||
import { fetchLocationById } from '@/app/lib/actions/locationActions';
|
||||
import { fetchLocationById, setSeenByTenant } from '@/app/lib/actions/locationActions';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { myAuth } from '@/app/lib/auth';
|
||||
|
||||
export default async function LocationViewPage({ locationId }: { locationId:string }) {
|
||||
const location = await fetchLocationById(locationId);
|
||||
@@ -9,5 +10,14 @@ export default async function LocationViewPage({ locationId }: { locationId:stri
|
||||
return(notFound());
|
||||
}
|
||||
|
||||
// Check if the page was accessed by an authenticated user who is the owner
|
||||
const session = await myAuth();
|
||||
const isOwner = session?.user?.id === location.userId;
|
||||
|
||||
// If the page is not visited by the owner, mark it as seen by tenant
|
||||
if (!isOwner) {
|
||||
await setSeenByTenant(locationId);
|
||||
}
|
||||
|
||||
return (<ViewLocationCard location={location} />);
|
||||
}
|
||||
Reference in New Issue
Block a user