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