blob: b22e99f162362a5ae4593c2ae8462856bc8edbb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { NextRequest, NextResponse } from 'next/server';
import { createBasicContractTemplate } from '@/lib/basic-contract/service';
import { revalidatePath ,revalidateTag} from 'next/cache';
import { createBasicContractTemplateSchema } from '@/lib/basic-contract/validations';
export async function POST(request: NextRequest) {
try {
const json = await request.json();
const parsed = createBasicContractTemplateSchema.safeParse(json);
if (!parsed.success) {
return NextResponse.json(
{ success: false, error: parsed.error.flatten() },
{ status: 400 }
);
}
const { data, error } = await createBasicContractTemplate(parsed.data);
revalidatePath('/evcp/basic-contract-templates');
revalidateTag("basic-contract-templates");
if (error) {
throw new Error(error);
}
return NextResponse.json({ success: true, data });
} catch (error) {
console.error('템플릿 저장 오류:', error);
return NextResponse.json({ success: false, error: '서버 오류' }, { status: 500 });
}
}
|