Skip to content

Commit 351ee53

Browse files
committed
Fix for archiving branches
1 parent 4bb22d6 commit 351ee53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
4444
return json({ error: parsed.error.message }, { status: 400 });
4545
}
4646

47-
const environment = await prisma.runtimeEnvironment.findFirst({
47+
const environments = await prisma.runtimeEnvironment.findMany({
4848
select: {
4949
id: true,
5050
archivedAt: true,
@@ -64,11 +64,12 @@ export async function action({ request, params }: ActionFunctionArgs) {
6464
},
6565
});
6666

67-
if (!environment) {
67+
if (environments.length === 0) {
6868
return json({ error: "Branch not found" }, { status: 404 });
6969
}
7070

71-
if (environment.archivedAt) {
71+
const environment = environments.find((env) => env.archivedAt === null);
72+
if (!environment) {
7273
return json({ error: "Branch already archived" }, { status: 400 });
7374
}
7475

0 commit comments

Comments
 (0)