10.6 카테고리 유형/설정 관리(일반/특수/승인/레벨/익명/태그) o
This commit is contained in:
@@ -27,6 +27,8 @@ export default function AdminBoardsPage() {
|
||||
<th>익명</th>
|
||||
<th>비밀댓</th>
|
||||
<th>승인</th>
|
||||
<th>유형</th>
|
||||
<th>성인</th>
|
||||
<th>정렬</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -66,6 +68,13 @@ function Row({ b, onSave, saving }: { b: any; onSave: (b: any) => void; saving:
|
||||
<td><input type="checkbox" checked={edit.allowAnonymousPost} onChange={(e) => setEdit({ ...edit, allowAnonymousPost: e.target.checked })} /></td>
|
||||
<td><input type="checkbox" checked={edit.allowSecretComment} onChange={(e) => setEdit({ ...edit, allowSecretComment: e.target.checked })} /></td>
|
||||
<td><input type="checkbox" checked={edit.requiresApproval} onChange={(e) => setEdit({ ...edit, requiresApproval: e.target.checked })} /></td>
|
||||
<td>
|
||||
<select value={edit.type} onChange={(e) => setEdit({ ...edit, type: e.target.value })}>
|
||||
<option value="general">general</option>
|
||||
<option value="special">special</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="checkbox" checked={!!edit.isAdultOnly} onChange={(e) => setEdit({ ...edit, isAdultOnly: e.target.checked })} /></td>
|
||||
<td><input type="number" value={edit.sortOrder} onChange={(e) => setEdit({ ...edit, sortOrder: Number(e.target.value) })} style={{ width: 80 }} /></td>
|
||||
<td><button onClick={() => onSave(edit)} disabled={saving}>{saving ? "저장중" : "저장"}</button></td>
|
||||
</tr>
|
||||
|
||||
@@ -5,9 +5,15 @@ export async function PATCH(req: Request, context: { params: Promise<{ id: strin
|
||||
const { id } = await context.params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const data: any = {};
|
||||
for (const k of ["name", "slug", "description", "sortOrder", "readLevel", "writeLevel", "allowAnonymousPost", "allowSecretComment", "requiresApproval", "status"]) {
|
||||
for (const k of ["name", "slug", "description", "sortOrder", "readLevel", "writeLevel", "allowAnonymousPost", "allowSecretComment", "requiresApproval", "status", "type", "isAdultOnly"]) {
|
||||
if (k in body) data[k] = body[k];
|
||||
}
|
||||
if ("requiredTags" in body) {
|
||||
try { data.requiredTags = typeof body.requiredTags === "string" ? JSON.parse(body.requiredTags) : body.requiredTags; } catch { /* ignore invalid */ }
|
||||
}
|
||||
if ("requiredFields" in body) {
|
||||
try { data.requiredFields = typeof body.requiredFields === "string" ? JSON.parse(body.requiredFields) : body.requiredFields; } catch { /* ignore invalid */ }
|
||||
}
|
||||
const updated = await prisma.board.update({ where: { id }, data });
|
||||
return NextResponse.json({ board: updated });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user