-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26ac152
commit 3780eb4
Showing
14 changed files
with
237 additions
and
571 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
integration/templates/next-app-router/src/app/protect-action/page-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
import { useState, useTransition } from 'react'; | ||
|
||
export function PageComponent({ action }: { action: () => Promise<any> }) { | ||
const [pending, startTransition] = useTransition(); | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
disabled={pending} | ||
onClick={() => { | ||
startTransition(async () => { | ||
await action().then(setRes); | ||
}); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
} |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-action/signed-out-with-all/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
'use client'; | ||
import { useState, useTransition } from 'react'; | ||
import { logUserIdActionStack } from '@/app/protect-action/actions'; | ||
import { PageComponent } from '@/app/protect-action/page-component'; | ||
|
||
function Page() { | ||
const [pending, startTransition] = useTransition(); | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
disabled={pending} | ||
onClick={() => { | ||
startTransition(async () => { | ||
await logUserIdActionStack().then(setRes); | ||
}); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent action={logUserIdActionStack} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
.../templates/next-app-router/src/app/protect-action/signed-out-with-reverification/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
'use client'; | ||
import { useState, useTransition } from 'react'; | ||
import { logUserIdActionReverification } from '@/app/protect-action/actions'; | ||
import { PageComponent } from '@/app/protect-action/page-component'; | ||
|
||
function Page() { | ||
const [pending, startTransition] = useTransition(); | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
disabled={pending} | ||
onClick={() => { | ||
startTransition(async () => { | ||
await logUserIdActionReverification().then(setRes); | ||
}); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent action={logUserIdActionReverification} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-action/signed-out-with-role/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
'use client'; | ||
import { useState, useTransition } from 'react'; | ||
import { logUserIdActionRole } from '@/app/protect-action/actions'; | ||
import { PageComponent } from '@/app/protect-action/page-component'; | ||
|
||
function Page() { | ||
const [pending, startTransition] = useTransition(); | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
disabled={pending} | ||
onClick={() => { | ||
startTransition(async () => { | ||
await logUserIdActionRole().then(setRes); | ||
}); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent action={logUserIdActionRole} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-action/signed-out/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
'use client'; | ||
import { useState, useTransition } from 'react'; | ||
import { logUserIdAction } from '@/app/protect-action/actions'; | ||
import { PageComponent } from '@/app/protect-action/page-component'; | ||
|
||
function Page() { | ||
const [pending, startTransition] = useTransition(); | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
disabled={pending} | ||
onClick={() => { | ||
startTransition(async () => { | ||
await logUserIdAction().then(setRes); | ||
}); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent action={logUserIdAction} />; | ||
} | ||
|
||
export default Page; |
49 changes: 0 additions & 49 deletions
49
integration/templates/next-app-router/src/app/protect-route/actions.ts
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
integration/templates/next-app-router/src/app/protect-route/page-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useState } from 'react'; | ||
|
||
export function PageComponent({ url }: { url: string }) { | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={async () => { | ||
await fetch(url, { | ||
method: 'POST', | ||
}) | ||
.then(res => res.json()) | ||
.then(setRes); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
} |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-route/signed-out-with-all/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import { PageComponent } from '@/app/protect-route/page-component'; | ||
|
||
function Page() { | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={async () => { | ||
await fetch('/api/log-user-id-all', { | ||
method: 'POST', | ||
}) | ||
.then(res => res.json()) | ||
.then(setRes); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent url={'/api/log-user-id-all'} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
...n/templates/next-app-router/src/app/protect-route/signed-out-with-reverification/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import { PageComponent } from '@/app/protect-route/page-component'; | ||
|
||
function Page() { | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={async () => { | ||
await fetch('/api/log-user-id-reverification', { | ||
method: 'POST', | ||
}) | ||
.then(res => res.json()) | ||
.then(setRes); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent url={'/api/log-user-id-reverification'} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-route/signed-out-with-role/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import { PageComponent } from '@/app/protect-route/page-component'; | ||
|
||
function Page() { | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={async () => { | ||
await fetch('/api/log-user-id-role', { | ||
method: 'POST', | ||
}) | ||
.then(res => res.json()) | ||
.then(setRes); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent url={'/api/log-user-id-role'} />; | ||
} | ||
|
||
export default Page; |
21 changes: 2 additions & 19 deletions
21
integration/templates/next-app-router/src/app/protect-route/signed-out/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
'use client'; | ||
import { useState } from 'react'; | ||
import { PageComponent } from '@/app/protect-route/page-component'; | ||
|
||
function Page() { | ||
const [res, setRes] = useState(null); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={async () => { | ||
await fetch('/api/log-user-id', { | ||
method: 'POST', | ||
}) | ||
.then(res => res.json()) | ||
.then(setRes); | ||
}} | ||
> | ||
LogUserId | ||
</button> | ||
<pre>{JSON.stringify(res)}</pre> | ||
</> | ||
); | ||
return <PageComponent url={'/api/log-user-id'} />; | ||
} | ||
|
||
export default Page; |
Oops, something went wrong.