8.7 제휴문의: 접수 폼/관리자 승인 워크플로우/알림 o
This commit is contained in:
10
src/app/api/partner-inquiries/[id]/approve/route.ts
Normal file
10
src/app/api/partner-inquiries/[id]/approve/route.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export async function POST(_: Request, context: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await context.params;
|
||||
const updated = await prisma.partnerInquiry.update({ where: { id }, data: { status: "approved", approvedAt: new Date() } });
|
||||
return NextResponse.json({ inquiry: updated });
|
||||
}
|
||||
|
||||
|
||||
20
src/app/api/partner-inquiries/route.ts
Normal file
20
src/app/api/partner-inquiries/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { z } from "zod";
|
||||
|
||||
const schema = z.object({ name: z.string().min(1), contact: z.string().min(1), category: z.string().optional(), message: z.string().min(1) });
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const parsed = schema.safeParse(body);
|
||||
if (!parsed.success) return NextResponse.json({ error: parsed.error.flatten() }, { status: 400 });
|
||||
const created = await prisma.partnerInquiry.create({ data: parsed.data });
|
||||
return NextResponse.json({ inquiry: created }, { status: 201 });
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
const items = await prisma.partnerInquiry.findMany({ orderBy: { createdAt: "desc" } });
|
||||
return NextResponse.json({ inquiries: items });
|
||||
}
|
||||
|
||||
|
||||
24
src/app/partners/inquiry/page.tsx
Normal file
24
src/app/partners/inquiry/page.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
"use client";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function PartnerInquiryPage() {
|
||||
const [form, setForm] = useState({ name: "", contact: "", category: "", message: "" });
|
||||
const [done, setDone] = useState(false);
|
||||
async function submit() {
|
||||
const r = await fetch("/api/partner-inquiries", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(form) });
|
||||
setDone(r.ok);
|
||||
}
|
||||
if (done) return <div>접수되었습니다. 검토 후 연락드리겠습니다.</div>;
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
||||
<h1>제휴 문의</h1>
|
||||
<input placeholder="업체명" value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} />
|
||||
<input placeholder="연락처/이메일" value={form.contact} onChange={(e) => setForm({ ...form, contact: e.target.value })} />
|
||||
<input placeholder="카테고리(선택)" value={form.category} onChange={(e) => setForm({ ...form, category: e.target.value })} />
|
||||
<textarea placeholder="문의 내용" value={form.message} onChange={(e) => setForm({ ...form, message: e.target.value })} rows={8} />
|
||||
<button onClick={submit}>접수</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user