Skip to content

Commit 4f31705

Browse files
committed
useDevEnvironment returns the current user’s dev environment, not the first
1 parent 3afd5f8 commit 4f31705

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/webapp/app/hooks/useEnvironments.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RouteMatch } from "@remix-run/react";
22
import { MatchedProject, useOptionalProject } from "./useProject";
3+
import { useUser } from "./useUser";
34

45
export type ProjectJobEnvironment = MatchedProject["environments"][number];
56

@@ -11,10 +12,13 @@ export function useEnvironments(matches?: RouteMatch[]) {
1112
}
1213

1314
export function useDevEnvironment(matches?: RouteMatch[]) {
15+
const user = useUser();
1416
const environments = useEnvironments(matches);
1517
if (!environments) return;
1618

17-
return environments.find((environment) => environment.type === "DEVELOPMENT");
19+
return environments.find(
20+
(environment) => environment.type === "DEVELOPMENT" && environment.userId === user.id
21+
);
1822
}
1923

2024
export function useProdEnvironment(matches?: RouteMatch[]) {

0 commit comments

Comments
 (0)