Some checks failed
Deploy to Cloudflare Workers / deploy (push) Has been cancelled
23 lines
755 B
TypeScript
23 lines
755 B
TypeScript
import { createClient } from "@/lib/supabase/server";
|
|
import { requireUser } from "@/lib/api/auth";
|
|
import { apiError, apiSuccess, parseJson } from "@/lib/api/errors";
|
|
import * as teams from "@/lib/services/teams";
|
|
|
|
export async function PUT(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ teamId: string }> }
|
|
) {
|
|
try {
|
|
const { teamId } = await params;
|
|
const supabase = await createClient();
|
|
await requireUser(supabase);
|
|
const body = await parseJson<{
|
|
windows: { day_of_week: number; start_time?: string; end_time?: string }[];
|
|
}>(request);
|
|
await teams.setAvailability(supabase, teamId, body.windows ?? []);
|
|
return apiSuccess({ saved: true });
|
|
} catch (e) {
|
|
return apiError(e);
|
|
}
|
|
}
|