feat(specials): add launch and end dates for scheduling
This commit is contained in:
@@ -11,7 +11,7 @@ export async function GET() {
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const { name, maxAttempts = 7, unlockSteps = '[2,4,7,11,16,30,60]' } = await request.json();
|
||||
const { name, maxAttempts = 7, unlockSteps = '[2,4,7,11,16,30,60]', launchDate, endDate } = await request.json();
|
||||
if (!name) {
|
||||
return NextResponse.json({ error: 'Name is required' }, { status: 400 });
|
||||
}
|
||||
@@ -20,6 +20,8 @@ export async function POST(request: Request) {
|
||||
name,
|
||||
maxAttempts: Number(maxAttempts),
|
||||
unlockSteps,
|
||||
launchDate: launchDate ? new Date(launchDate) : null,
|
||||
endDate: endDate ? new Date(endDate) : null,
|
||||
},
|
||||
});
|
||||
return NextResponse.json(special);
|
||||
@@ -35,7 +37,7 @@ export async function DELETE(request: Request) {
|
||||
}
|
||||
|
||||
export async function PUT(request: Request) {
|
||||
const { id, name, maxAttempts, unlockSteps } = await request.json();
|
||||
const { id, name, maxAttempts, unlockSteps, launchDate, endDate } = await request.json();
|
||||
if (!id) {
|
||||
return NextResponse.json({ error: 'ID required' }, { status: 400 });
|
||||
}
|
||||
@@ -45,6 +47,8 @@ export async function PUT(request: Request) {
|
||||
...(name && { name }),
|
||||
...(maxAttempts && { maxAttempts: Number(maxAttempts) }),
|
||||
...(unlockSteps && { unlockSteps }),
|
||||
launchDate: launchDate ? new Date(launchDate) : null,
|
||||
endDate: endDate ? new Date(endDate) : null,
|
||||
},
|
||||
});
|
||||
return NextResponse.json(updated);
|
||||
|
||||
Reference in New Issue
Block a user