@@ -4,12 +4,14 @@ import { notFound, redirect } from "next/navigation";
4
4
5
5
import { type PubTypesId } from "db/public" ;
6
6
import { Button } from "ui/button" ;
7
+ import { Label } from "ui/label" ;
7
8
8
9
import { ContentLayout } from "~/app/c/[communitySlug]/ContentLayout" ;
10
+ import { FormSwitcher } from "~/app/components/FormSwitcher/FormSwitcher" ;
9
11
import { PageTitleWithStatus } from "~/app/components/pubs/PubEditor/PageTitleWithStatus" ;
10
12
import { PubEditor } from "~/app/components/pubs/PubEditor/PubEditor" ;
11
13
import { getPageLoginData } from "~/lib/authentication/loginData" ;
12
- import { userCanCreatePub } from "~/lib/authorization/capabilities" ;
14
+ import { getAuthorizedCreateForms , userCanCreatePub } from "~/lib/authorization/capabilities" ;
13
15
import { findCommunityBySlug } from "~/lib/server/community" ;
14
16
15
17
export async function generateMetadata ( props : {
@@ -29,7 +31,7 @@ export async function generateMetadata(props: {
29
31
30
32
export default async function Page ( props : {
31
33
params : Promise < { communitySlug : string } > ;
32
- searchParams : Promise < Record < string , string > & { pubTypeId : PubTypesId } > ;
34
+ searchParams : Promise < Record < string , string > & { pubTypeId : PubTypesId ; form ?: string } > ;
33
35
} ) {
34
36
const searchParams = await props . searchParams ;
35
37
const params = await props . params ;
@@ -57,6 +59,12 @@ export default async function Page(props: {
57
59
58
60
const htmlFormId = `create-pub` ;
59
61
62
+ const availableForms = await getAuthorizedCreateForms ( {
63
+ userId : user . id ,
64
+ communityId : community . id ,
65
+ pubTypeId : searchParams . pubTypeId ,
66
+ } ) . execute ( ) ;
67
+
60
68
return (
61
69
< ContentLayout
62
70
left = {
@@ -69,10 +77,19 @@ export default async function Page(props: {
69
77
>
70
78
< div className = "flex justify-center py-10" >
71
79
< div className = "max-w-prose flex-1" >
80
+ < div className = "mb-4 flex flex-col gap-3" >
81
+ < Label htmlFor = "create-page-form-switcher" > Current form</ Label >
82
+ < FormSwitcher
83
+ htmlId = "create-page-form-switcher"
84
+ defaultFormSlug = { searchParams . form }
85
+ forms = { availableForms }
86
+ />
87
+ </ div >
72
88
< PubEditor
73
89
searchParams = { searchParams }
74
90
communityId = { community . id }
75
91
htmlFormId = { htmlFormId }
92
+ formSlug = { searchParams . form }
76
93
// PubEditor checks for the existence of the stageId prop
77
94
{ ...( searchParams [ "stageId" ] ? { stageId : searchParams [ "stageId" ] } : { } ) }
78
95
/>
0 commit comments