Update web-app to use @evidencija-rezija/shared-code for common types and utilities instead of maintaining duplicate copies. Changes: - Add shared-code dependency to package.json - Update all imports across 35+ files to use @evidencija-rezija/shared-code - Remove duplicate db-types.ts and shareChecksum.ts files This ensures type consistency between web-app and email-worker and reduces maintenance burden. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { Suspense } from 'react';
|
|
import EmailVerifyPage from './EmailVerifyPage';
|
|
import { Main } from '@/app/ui/Main';
|
|
import { getDbClient } from '@/app/lib/dbClient';
|
|
import { BillingLocation, EmailStatus } from '@evidencija-rezija/shared-code';
|
|
import { extractShareId, validateShareChecksum } from '@evidencija-rezija/shared-code';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
export default async function Page({ params: { id } }: { params: { id: string } }) {
|
|
// Extract and validate share ID
|
|
const extracted = extractShareId(id);
|
|
if (!extracted) {
|
|
notFound();
|
|
}
|
|
|
|
const { locationId, checksum } = extracted;
|
|
|
|
// Validate checksum
|
|
if (!validateShareChecksum(locationId, checksum)) {
|
|
notFound();
|
|
}
|
|
|
|
// Fetch location to check email status
|
|
const dbClient = await getDbClient();
|
|
const location = await dbClient.collection<BillingLocation>("lokacije")
|
|
.findOne(
|
|
{ _id: locationId },
|
|
{ projection: { tenantEmail: 1, tenantEmailStatus: 1 } }
|
|
);
|
|
|
|
if (!location || !location.tenantEmail) {
|
|
notFound();
|
|
}
|
|
|
|
// Check if email is pending verification
|
|
const isPending = location.tenantEmailStatus === EmailStatus.VerificationPending;
|
|
|
|
return (
|
|
<Main>
|
|
<Suspense fallback={<div className="text-center p-8">Loading...</div>}>
|
|
<EmailVerifyPage shareId={id} isPending={isPending} />
|
|
</Suspense>
|
|
</Main>
|
|
);
|
|
}
|