@@ -4,6 +4,7 @@ import { notFound } from "next/navigation"
44
55import { Capabilities , MembershipType } from "db/public"
66import { PubFieldProvider } from "ui/pubFields"
7+ import { StagesProvider , stagesDAO } from "ui/stages"
78import { TokenProvider } from "ui/tokens"
89
910import { getActionByName } from "~/actions/api"
@@ -13,13 +14,23 @@ import { getActionConfigDefaults } from "~/lib/server/actions"
1314import { findCommunityBySlug } from "~/lib/server/community"
1415import { redirectToLogin , redirectToUnauthorized } from "~/lib/server/navigation/redirects"
1516import { getPubFields } from "~/lib/server/pubFields"
17+ import { getStages } from "~/lib/server/stages"
1618import { ContentLayout } from "../../../ContentLayout"
1719import { ActionConfigDefaultForm } from "./ActionConfigDefaultForm"
1820
1921type Props = {
20- params : {
22+ params : Promise < {
2123 action : Action
2224 communitySlug : string
25+ } >
26+ }
27+
28+ export async function generateMetadata ( { params } : { params : Promise < Props [ "params" ] > } ) {
29+ const action = ( await params ) . action
30+ const actionNiceName = getActionByName ( action ) . niceName
31+
32+ return {
33+ title : `${ actionNiceName } Action Defaults` ,
2334 }
2435}
2536
@@ -36,7 +47,7 @@ export default async function Page(props: Props) {
3647 redirectToLogin ( )
3748 }
3849
39- const [ userCanEditCommunity , pubFields , actionConfigDefaults ] = await Promise . all ( [
50+ const [ userCanEditCommunity , pubFields , actionConfigDefaults , stages ] = await Promise . all ( [
4051 userCan (
4152 Capabilities . editCommunity ,
4253 { type : MembershipType . community , communityId : community . id } ,
@@ -45,19 +56,19 @@ export default async function Page(props: Props) {
4556 getPubFields ( { communityId : community . id } ) . executeTakeFirstOrThrow ( ) ,
4657
4758 getActionConfigDefaults ( community . id , params . action ) . executeTakeFirst ( ) ,
59+ getStages ( { communityId : community . id , userId : loginData . user . id } ) . execute ( ) ,
4860 ] )
4961
5062 if ( ! userCanEditCommunity ) {
5163 return await redirectToUnauthorized ( )
5264 }
5365
54- const actionTitle = params . action [ 0 ] . toUpperCase ( ) + params . action . slice ( 1 )
55-
5666 const action = getActionByName ( params . action )
5767
5868 if ( ! action ) {
5969 notFound ( )
6070 }
71+ const actionTitle = action . niceName
6172
6273 return (
6374 < ContentLayout
@@ -75,17 +86,21 @@ export default async function Page(props: Props) {
7586 defaults will be applied to new instances of this action in your community.
7687 </ p >
7788 </ div >
78- < PubFieldProvider pubFields = { pubFields } >
79- < TokenProvider tokens = { action . tokens ?? { } } >
80- < ActionConfigDefaultForm
81- communityId = { community . id }
82- action = { params . action }
83- values = {
84- actionConfigDefaults ?. config as Record < string , unknown > | undefined
85- }
86- />
87- </ TokenProvider >
88- </ PubFieldProvider >
89+ < StagesProvider stages = { stagesDAO ( stages ) } >
90+ < PubFieldProvider pubFields = { pubFields } >
91+ < TokenProvider tokens = { action . tokens ?? { } } >
92+ < ActionConfigDefaultForm
93+ communityId = { community . id }
94+ action = { params . action }
95+ values = {
96+ actionConfigDefaults ?. config as
97+ | Record < string , unknown >
98+ | undefined
99+ }
100+ />
101+ </ TokenProvider >
102+ </ PubFieldProvider >
103+ </ StagesProvider >
89104 </ div >
90105 </ ContentLayout >
91106 )
0 commit comments