Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changeset/olive-oranges-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@clerk/clerk-js': patch
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default async function Page({ params }: { params: Promise<{ orgId: string }> }) {
const { orgId } = await params;

return (
<div>
<p data-testid='current-org-id'>{orgId}</p>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import { OrganizationSwitcher, useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { orgId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${orgId}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<OrganizationSwitcher
fallback={<div>Loading organization switcher</div>}
afterSelectOrganizationUrl='/transitive-state/organization-switcher/:id'
/>
</div>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use client';

import { useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { userId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${String(userId)}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SignOutButton } from '@clerk/nextjs';

export default function Page() {
return (
<div>
<p data-testid='page-name'>sign-out</p>
<SignOutButton redirectUrl='/transitive-state/sign-out/sign-in' />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>sign-in</p>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import { UserButton, useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { userId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${userId}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<UserButton
fallback={<div>Loading user button</div>}
afterSwitchSessionUrl='/transitive-state/user-button/switched'
/>
</div>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>initial</p>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>switched</p>;
}
Loading
Loading