@@ -11,6 +11,7 @@ import { Pencil } from "ui/icon";
11
11
import Move from "~/app/c/[communitySlug]/stages/components/Move" ;
12
12
import { MembersList } from "~/app/components//Memberships/MembersList" ;
13
13
import { PubsRunActionDropDownMenu } from "~/app/components/ActionUI/PubsRunActionDropDownMenu" ;
14
+ import { FormSwitcher } from "~/app/components/FormSwitcher/FormSwitcher" ;
14
15
import { AddMemberDialog } from "~/app/components/Memberships/AddMemberDialog" ;
15
16
import { CreatePubButton } from "~/app/components/pubs/CreatePubButton" ;
16
17
import { RemovePubButton } from "~/app/components/pubs/RemovePubButton" ;
@@ -22,7 +23,7 @@ import { getPubByForm, getPubTitle } from "~/lib/pubs";
22
23
import { getPubsWithRelatedValues , pubValuesByVal } from "~/lib/server" ;
23
24
import { autoCache } from "~/lib/server/cache/autoCache" ;
24
25
import { findCommunityBySlug } from "~/lib/server/community" ;
25
- import { getForm , getMembershipForms } from "~/lib/server/form" ;
26
+ import { getForm , getSimpleForms } from "~/lib/server/form" ;
26
27
import { selectAllCommunityMemberships } from "~/lib/server/member" ;
27
28
import { getStages } from "~/lib/server/stages" ;
28
29
import {
@@ -68,7 +69,7 @@ export default async function Page(props: {
68
69
params : Promise < { pubId : PubsId ; communitySlug : string } > ;
69
70
searchParams : Promise < Record < string , string > > ;
70
71
} ) {
71
- const searchParams = await props . searchParams ;
72
+ const { form : formSlug , ... searchParams } = await props . searchParams ;
72
73
const params = await props . params ;
73
74
const { pubId, communitySlug } = params ;
74
75
@@ -137,24 +138,26 @@ export default async function Page(props: {
137
138
}
138
139
139
140
const actionsPromise = pub . stage ? getStageActions ( pub . stage . id ) . execute ( ) : null ;
140
-
141
+ const getFormProps = formSlug
142
+ ? { communityId : community . id , slug : formSlug }
143
+ : {
144
+ communityId : community . id ,
145
+ pubTypeId : pub . pubType . id ,
146
+ } ;
141
147
const [ actions , communityMembers , communityStages , form , withExtraPubValues , availableForms ] =
142
148
await Promise . all ( [
143
149
actionsPromise ,
144
150
communityMembersPromise ,
145
151
communityStagesPromise ,
146
- getForm ( {
147
- communityId : community . id ,
148
- pubTypeId : pub . pubType . id ,
149
- } ) . executeTakeFirstOrThrow (
152
+ getForm ( getFormProps ) . executeTakeFirstOrThrow (
150
153
( ) => new Error ( `Could not find a form for pubtype ${ pub . pubType . name } ` )
151
154
) ,
152
155
userCan (
153
156
Capabilities . seeExtraPubValues ,
154
157
{ type : MembershipType . pub , pubId : pub . id } ,
155
158
user . id
156
159
) ,
157
- getMembershipForms ( pub . pubType . id ) ,
160
+ getSimpleForms ( pub . pubType . id ) ,
158
161
] ) ;
159
162
160
163
const pubTypeHasRelatedPubs = pub . pubType . fields . some ( ( field ) => field . isRelation ) ;
@@ -170,8 +173,11 @@ export default async function Page(props: {
170
173
< div className = "flex flex-col space-y-4" >
171
174
< div className = "mb-8 flex items-center justify-between" >
172
175
< div >
173
- < div className = "text-lg font-semibold text-muted-foreground" >
174
- { pub . pubType . name }
176
+ < div className = "flex items-center gap-2" >
177
+ < span className = "text-lg font-semibold text-muted-foreground" >
178
+ { pub . pubType . name }
179
+ </ span >
180
+ < FormSwitcher defaultFormSlug = { formSlug } forms = { availableForms } />
175
181
</ div >
176
182
< h1 className = "mb-2 text-xl font-bold" > { getPubTitle ( pub ) } </ h1 >
177
183
</ div >
0 commit comments