← back to Professional Directory
agents/web-agent/app/orgs/[slug]/page.tsx
59 lines
// /orgs/[slug] — public org profile. Reuses the existing pd-preview render
// for now (consistency with admin pitch flow); reviews + community appended.
const PD_API = process.env.PD_API_BASE || 'http://127.0.0.1:9874';
const PD_PREVIEW = process.env.PD_PREVIEW_BASE || 'http://127.0.0.1:9875';
export default async function OrgPage({ params }: { params: { slug: string } }) {
const id = String(params.slug || '').replace(/[^0-9]/g, '');
if (!id) {
return <section className="section"><h2>Not found</h2></section>;
}
// Render the existing pd-preview HTML inline (same template as Steve's pitch).
// Reviews + community discussion are appended below.
const previewHtml = await fetch(`${PD_PREVIEW}/preview/${id}`, { next: { revalidate: 600 } })
.then(r => r.ok ? r.text() : null)
.catch(() => null);
const orgJson = await fetch(`${PD_API}/organizations/${id}`).then(r => r.ok ? r.json() : null).catch(() => null);
if (!orgJson || !previewHtml) {
return <section className="section"><h2>Not found</h2></section>;
}
return (
<>
{/* Inline-iframe the preview for safe isolation; alternative is dangerouslySetInnerHTML */}
<iframe
src={`${PD_PREVIEW}/preview/${id}`}
style={{ width: '100%', minHeight: '900px', border: 0 }}
title={`${orgJson.name} preview`}
/>
<section className="section">
<div className="eyebrow">Reviews</div>
<h2>What patients say</h2>
<p style={{ color: 'var(--ink-soft)' }}>
Reviews go live in Phase 3. Initial scores will seed from public Reddit + Yelp + Healthgrades signals;
patient subscribers can verify and add their own.
</p>
</section>
<section className="section" style={{ borderTop: '1px solid var(--line)' }}>
<div className="eyebrow">For this practice</div>
<h2>Are you the owner?</h2>
<p style={{ maxWidth: 580, color: 'var(--ink-soft)' }}>
Claim {titleCase(orgJson.name)} to respond to reviews, edit page content, and DM patients directly.
Verification: NPI + practice domain email.
</p>
<a href={`/account/claim?org=${id}`} className="card" style={{ display: 'inline-block', padding: '12px 22px', textAlign: 'center', background: 'var(--moss)', color: '#fff', borderRadius: 999, fontWeight: 600, letterSpacing: '0.04em', textTransform: 'uppercase', fontSize: 14 }}>
Claim this practice →
</a>
</section>
</>
);
}
function titleCase(s: string) { return String(s || '').toLowerCase().replace(/\b\w/g, c => c.toUpperCase()); }