feat: streamline group dispatch reminders

This commit is contained in:
kris
2026-04-04 03:00:34 +08:00
parent 425d8992ef
commit 5ebb37cbfc
13 changed files with 485 additions and 37 deletions

View File

@@ -24,6 +24,7 @@ export async function POST(
const body = (await request.json().catch(() => ({}))) as {
approvedTargetProjectIds?: string[];
rememberLightReminder?: boolean;
};
const { projectId, planId } = await context.params;
@@ -37,6 +38,7 @@ export async function POST(
(item): item is string => typeof item === "string" && item.trim().length > 0,
)
: [],
rememberLightReminder: body.rememberLightReminder === true,
});
return NextResponse.json({

View File

@@ -0,0 +1,48 @@
import { NextRequest, NextResponse } from "next/server";
import { requireRequestSession } from "@/lib/boss-auth";
import {
buildCollaborationGate,
getProject,
updateProjectLightDispatchReminder,
} from "@/lib/boss-data";
export async function PATCH(
request: NextRequest,
context: { params: Promise<{ projectId: string }> },
) {
const session = await requireRequestSession(request);
if (!session) {
return NextResponse.json({ ok: false, message: "UNAUTHORIZED" }, { status: 401 });
}
const { projectId } = await context.params;
const body = (await request.json().catch(() => ({}))) as {
lightDispatchReminderEnabled?: unknown;
};
if (typeof body.lightDispatchReminderEnabled !== "boolean") {
return NextResponse.json(
{ ok: false, message: "INVALID_DISPATCH_REMINDER_PAYLOAD" },
{ status: 400 },
);
}
try {
await updateProjectLightDispatchReminder({
projectId,
requestedBy: session.account,
lightDispatchReminderEnabled: body.lightDispatchReminderEnabled,
});
const project = await getProject(projectId);
if (!project) {
return NextResponse.json({ ok: false, message: "PROJECT_NOT_FOUND" }, { status: 404 });
}
return NextResponse.json({
ok: true,
project,
collaborationGate: buildCollaborationGate(project),
});
} catch (error) {
const reason = error instanceof Error ? error.message : "UNKNOWN_ERROR";
return NextResponse.json({ ok: false, message: reason }, { status: 400 });
}
}

View File

@@ -181,6 +181,7 @@ export default async function ProjectChatPage({
</div>
<ChatComposer
projectId={detail.project.id}
initialLightDispatchReminderEnabled={Boolean(detail.project.lightDispatchReminderEnabled)}
dispatchPlanRecoveryHint={dispatchPlanState.pendingDispatchPlan ? dispatchPlanState.recoveryHint : null}
initialPendingDispatchPlan={
dispatchPlanState.pendingDispatchPlan