Skip to content

Commit

Permalink
chore(repo): Update playground apps
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdouvlis committed Dec 14, 2023
1 parent d04efe7 commit 84c1a31
Show file tree
Hide file tree
Showing 38 changed files with 16 additions and 944 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`/server public exports should not include a breaking change 1`] = `
"authMiddleware",
"buildClerkProps",
"clerkClient",
"createClerkClient",
"currentUser",
"getAuth",
"redirectToSignIn",
Expand Down
11 changes: 11 additions & 0 deletions playground/nextjs/app/app-dir/client-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

import React from 'react';
import { isClerkAPIResponseError, isEmailLinkError, isKnownError, isMetamaskError } from '@clerk/nextjs/errors';

export const ClientComponent = () => {
React.useEffect(() => {
console.log({ isClerkAPIResponseError, isEmailLinkError, isKnownError, isMetamaskError });
});
return <div>Client Component</div>;
};
13 changes: 2 additions & 11 deletions playground/nextjs/app/app-dir/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import {
auth,
clerkClient,
currentUser,
OrganizationSwitcher,
SignedIn,
SignedOut,
SignIn,
UserButton,
} from '@clerk/nextjs';
import { OrganizationSwitcher, SignedIn, SignedOut, SignIn, UserButton } from '@clerk/nextjs';
import { auth, clerkClient, currentUser } from '@clerk/nextjs/server';
import Link from 'next/link';

export default async function Page() {
const { userId } = auth();
const currentUser_ = await currentUser();
const user = userId ? await clerkClient.users.getUser(userId) : null;
console.log({ userId, currentUser_, user });

return (
<main>
Expand Down
26 changes: 1 addition & 25 deletions playground/nextjs/pages/session-examples/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSession, withSession, WithSession, WithSessionProp } from '@clerk/nextjs';
import { useSession } from '@clerk/nextjs';
import { PublicUserData } from '@clerk/types';
import type { NextPage } from 'next';
import React from 'react';
Expand All @@ -20,36 +20,12 @@ function PublicMetadataWithHook() {
return <Template publicUserData={session?.publicUserData} />;
}

class PublicMetadataClass extends React.Component<WithSessionProp> {
render() {
return <Template publicUserData={this.props.session.publicUserData} />;
}
}

export const PublicMetadataClassHOC = withSession(PublicMetadataClass);

const PublicMetadataFn = (props: WithSessionProp) => {
const { session } = props;
return <Template publicUserData={session?.publicUserData} />;
};

export const PublicMetadataFnHOC = withSession(PublicMetadataFn);

class PublicMetadataFaaC extends React.Component {
render() {
return <WithSession>{session => <Template publicUserData={session?.publicUserData} />}</WithSession>;
}
}

const SessionExamplesPage: NextPage = () => {
return (
<div
style={{ display: 'flex', flexDirection: 'column', gap: '2rem', justifyContent: 'center', alignItems: 'center' }}
>
<PublicMetadataWithHook />
<PublicMetadataClassHOC />
<PublicMetadataFnHOC />
{/*<PublicMetadataFaaC />*/}
</div>
);
};
Expand Down
35 changes: 1 addition & 34 deletions playground/nextjs/pages/user-examples/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextPage } from 'next';
import React from 'react';
import { useUser, withUser, WithUser, WithUserProp } from '@clerk/nextjs';
import { useUser } from '@clerk/nextjs';

function GreetingWithHook() {
// Use the useUser hook to get the Clerk.user object
Expand All @@ -15,45 +15,12 @@ function GreetingWithHook() {
return <div>Hello, {user.firstName}!</div>;
}

class GreetingClass extends React.Component<WithUserProp> {
render() {
return <div>{this.props.user.firstName ? `Hello ${this.props.user.firstName}!` : 'Hello there!'}</div>;
}
}

export const GreetingClassHOC = withUser(GreetingClass);

type GreetingProps = {
greeting: string;
};

const GreetingFn = (props: WithUserProp<GreetingProps>) => {
const { user, greeting } = props;
return (
<>
<h1>{greeting}</h1>
<div>{user.firstName ? `Hello, ${user.firstName}!` : 'Hello there!'}</div>
</>
);
};

export const GreetingFnHOC = withUser(GreetingFn);

class GreetingFaaC extends React.Component {
render() {
return <WithUser>{user => <div>{user.firstName ? `Hello, ${user.firstName}!` : 'Hello there!'}</div>}</WithUser>;
}
}

const UserExamplesPage: NextPage = () => {
return (
<div
style={{ display: 'flex', flexDirection: 'column', gap: '2rem', justifyContent: 'center', alignItems: 'center' }}
>
<GreetingWithHook />
<GreetingClassHOC />
<GreetingFnHOC greeting={'Ciao'} />
{/*<GreetingFaaC />*/}
</div>
);
};
Expand Down
4 changes: 0 additions & 4 deletions playground/nextjs12/.eslintrc.json

This file was deleted.

36 changes: 0 additions & 36 deletions playground/nextjs12/.gitignore

This file was deleted.

55 changes: 0 additions & 55 deletions playground/nextjs12/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions playground/nextjs12/app/app-dir/client/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions playground/nextjs12/app/app-dir/create-organization/page.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions playground/nextjs12/app/app-dir/organization/page.tsx

This file was deleted.

43 changes: 0 additions & 43 deletions playground/nextjs12/app/app-dir/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions playground/nextjs12/app/app-dir/sign-in/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions playground/nextjs12/app/app-dir/sign-up/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions playground/nextjs12/app/app-dir/user/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions playground/nextjs12/app/layout.tsx

This file was deleted.

Loading

0 comments on commit 84c1a31

Please sign in to comment.