"use client";
import { useState } from "react";

export default function PartnerRequestPage() {
  const [form, setForm] = useState({ name: "", category: "spa", latitude: "", longitude: "", address: "", contact: "" });
  const [done, setDone] = useState(false);
  async function submit() {
    const r = await fetch("/api/partner-requests", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ ...form, latitude: Number(form.latitude), longitude: Number(form.longitude) }) });
    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="카테고리(spa/gym 등)" value={form.category} onChange={(e) => setForm({ ...form, category: e.target.value })} />
      <input placeholder="위도" value={form.latitude} onChange={(e) => setForm({ ...form, latitude: e.target.value })} />
      <input placeholder="경도" value={form.longitude} onChange={(e) => setForm({ ...form, longitude: e.target.value })} />
      <input placeholder="주소(선택)" value={form.address} onChange={(e) => setForm({ ...form, address: e.target.value })} />
      <input placeholder="연락처(선택)" value={form.contact} onChange={(e) => setForm({ ...form, contact: e.target.value })} />
      <button onClick={submit}>요청하기</button>
    </div>
  );
}


