- Updated ViewLocationCard to accept userSettings prop - Replaced all hardcoded payment values with dynamic data: * Amount calculated from monthly expenses * Payer info from tenant fields (name, street, town) * Recipient info from userSettings (name, street, town, IBAN) * Reference number and description generated from location data - Created getUserSettingsByUserId function for fetching owner settings on public pages - Updated LocationViewPage to fetch and pass userSettings to ViewLocationCard 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { ViewLocationCard } from '@/app/ui/ViewLocationCard';
|
|
import { fetchLocationById, setSeenByTenant } from '@/app/lib/actions/locationActions';
|
|
import { getUserSettingsByUserId } from '@/app/lib/actions/userSettingsActions';
|
|
import { notFound } from 'next/navigation';
|
|
import { myAuth } from '@/app/lib/auth';
|
|
|
|
export default async function LocationViewPage({ locationId }: { locationId:string }) {
|
|
const location = await fetchLocationById(locationId);
|
|
|
|
if (!location) {
|
|
return(notFound());
|
|
}
|
|
|
|
// Fetch user settings for the location owner
|
|
const userSettings = await getUserSettingsByUserId(location.userId);
|
|
|
|
// 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} userSettings={userSettings} />);
|
|
} |