11import { type LoaderFunctionArgs } from "@remix-run/server-runtime" ;
22import { prisma } from "~/db.server" ;
3+ import { env } from "~/env.server" ;
34import { redirectWithSuccessMessage } from "~/models/message.server" ;
45import { OrgIntegrationRepository } from "~/models/orgIntegration.server" ;
56import { findProjectBySlug } from "~/models/project.server" ;
67import { requireUserId } from "~/services/session.server" ;
78import {
9+ EnvironmentParamSchema ,
810 ProjectParamSchema ,
911 v3NewProjectAlertPath ,
1012 v3NewProjectAlertPathConnectToSlackPath ,
1113} from "~/utils/pathBuilder" ;
1214
1315export async function loader ( { request, params } : LoaderFunctionArgs ) {
1416 const userId = await requireUserId ( request ) ;
15- const { organizationSlug, projectParam } = ProjectParamSchema . parse ( params ) ;
17+ const { organizationSlug, projectParam, envParam } = EnvironmentParamSchema . parse ( params ) ;
1618
1719 const project = await findProjectBySlug ( organizationSlug , projectParam , userId ) ;
1820
@@ -30,7 +32,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
3032
3133 if ( integration ) {
3234 return redirectWithSuccessMessage (
33- `${ v3NewProjectAlertPath ( { slug : organizationSlug } , project ) } ?option=slack` ,
35+ `${ v3NewProjectAlertPath ( { slug : organizationSlug } , project , {
36+ slug : envParam ,
37+ } ) } ?option=slack`,
3438 request ,
3539 "Successfully connected your Slack workspace"
3640 ) ;
@@ -40,7 +44,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
4044 "SLACK" ,
4145 project . organizationId ,
4246 request ,
43- v3NewProjectAlertPathConnectToSlackPath ( { slug : organizationSlug } , project )
47+ v3NewProjectAlertPathConnectToSlackPath ( { slug : organizationSlug } , project , {
48+ slug : envParam ,
49+ } )
4450 ) ;
4551 }
4652}
0 commit comments