Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Feb 11, 2025
1 parent 1185942 commit 731b752
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
23 changes: 16 additions & 7 deletions .internal/setup/code/app-(public)-page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import { Suspense } from "react";
import { getSessionOrReject } from "../_actions/auth";

export default async function Page() {
const session = await getSessionOrReject();

return (
<div className="space-y-10 p-10">
<h1 className="text-2xl text-center">Hello World 😄</h1>
<p className="text-gray-300" aria-label="User status">
{session?.data?.user
? `you are signed in as ${session.data.user.name} 😄`
: "you are not signed in 🥲"}
</p>
<Suspense fallback={<p>loading...</p>}>
<ValidateUser />
</Suspense>
</div>
);
}

async function ValidateUser() {
const session = await getSessionOrReject();

return (
<p className="text-gray-300" aria-label="User status">
{session?.data?.user
? `you are signed in as ${session.data.user.name} 😄`
: "you are not signed in 🥲"}
</p>
);
}
23 changes: 16 additions & 7 deletions .internal/tests/no-sample-code.test.mjs.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -349,22 +349,31 @@ exports[`no-sample-code > should update prisma/schema.prisma 1`] = `

exports[`no-sample-code > should update src/app/(public)/page.tsx 1`] = `
[
"import { Suspense } from \\"react\\";",
"import { getSessionOrReject } from \\"../_actions/auth\\";",
"",
"export default async function Page() {",
" const session = await getSessionOrReject();",
"",
" return (",
" <div className=\\"space-y-10 p-10\\">",
" <h1 className=\\"text-2xl text-center\\">Hello World 😄</h1>",
" <p className=\\"text-gray-300\\" aria-label=\\"User status\\">",
" {session?.data?.user",
" ? \`you are signed in as \${session.data.user.name} 😄\`",
" : \\"you are not signed in 🥲\\"}",
" </p>",
" <Suspense fallback={<p>loading...</p>}>",
" <ValidateUser />",
" </Suspense>",
" </div>",
" );",
"}",
"",
"async function ValidateUser() {",
" const session = await getSessionOrReject();",
"",
" return (",
" <p className=\\"text-gray-300\\" aria-label=\\"User status\\">",
" {session?.data?.user",
" ? \`you are signed in as \${session.data.user.name} 😄\`",
" : \\"you are not signed in 🥲\\"}",
" </p>",
" );",
"}",
""
]
`;
Expand Down
3 changes: 2 additions & 1 deletion .internal/tests/no-stripe.test.mjs.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports[`no-stripe > should put files 1`] = `
"internal-tests-output-no-stripe/src/app/(public)/layout.tsx",
"internal-tests-output-no-stripe/src/app/(public)/page.tsx",
"internal-tests-output-no-stripe/src/app/(public)/signin/page.tsx",
"internal-tests-output-no-stripe/src/app/@dialog/(.)create/Content.tsx",
"internal-tests-output-no-stripe/src/app/@dialog/(.)create/_components/Form.tsx",
"internal-tests-output-no-stripe/src/app/@dialog/(.)create/default.tsx",
"internal-tests-output-no-stripe/src/app/@dialog/(.)create/page.tsx",
"internal-tests-output-no-stripe/src/app/@dialog/_components/Dialog.tsx",
Expand All @@ -61,6 +61,7 @@ exports[`no-stripe > should put files 1`] = `
"internal-tests-output-no-stripe/src/app/_components/FormBox.tsx",
"internal-tests-output-no-stripe/src/app/_components/Header.tsx",
"internal-tests-output-no-stripe/src/app/_components/Input.tsx",
"internal-tests-output-no-stripe/src/app/_components/Placeholder.tsx",
"internal-tests-output-no-stripe/src/app/_components/SignInButton.tsx",
"internal-tests-output-no-stripe/src/app/_components/SignOutButton.tsx",
"internal-tests-output-no-stripe/src/app/_hooks/useOnlineStatus.test.ts",
Expand Down
2 changes: 1 addition & 1 deletion e2e/helpers/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function registerUserToDB(user: User) {
create: {
type: "oauth",
provider: "google",
providerAccountId: `${Math.random()}`,
providerAccountId: "google-123",
id_token: "id_token",
access_token: "access_token",
token_type: "Bearer",
Expand Down
2 changes: 1 addition & 1 deletion src/app/_components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function Avatar() {
async function Action() {
const session = await getSessionOrReject();

if (!session) {
if (!session.success) {
return <SignInButton />;
}

Expand Down

0 comments on commit 731b752

Please # to comment.