import{r,j as e,L as v}from"./index-BMcVAjQW.js";import{s as S}from"./client-BVfsVemL.js";import{u as U}from"./useSiteSettings-GEm0exaR.js";function A(){const{settings:t,loading:s,refetch:y}=U(),[o,l]=r.useState(""),[i,u]=r.useState(""),[d,m]=r.useState(""),[p,c]=r.useState(""),[x,g]=r.useState(""),[b,h]=r.useState(!1),[f,n]=r.useState(null);r.useEffect(()=>{s||(l(t.whatsappNumber),u(t.whatsappNumber2),m(t.instagramUrl),c(t.tiktokUrl),g(t.whatsappChannelUrl))},[s,t.whatsappNumber,t.whatsappNumber2,t.instagramUrl,t.tiktokUrl,t.whatsappChannelUrl]);const j=async a=>{a.preventDefault(),h(!0),n(null);const N=o.replace(/[^0-9]/g,""),w=i.replace(/[^0-9]/g,""),{error:k}=await S.from("site_settings").update({whatsapp_number:N,whatsapp_number_2:w,instagram_url:d.trim(),tiktok_url:p.trim(),whatsapp_channel_url:x.trim()}).eq("id",!0);h(!1),k?n("Gagal menyimpan: "+k.message):(n("Tersimpan! Perubahan langsung muncul di website."),y())};return e.jsxs("div",{className:"max-w-2xl",children:[e.jsx(v,{to:"/adminpergam",className:"text-xs text-muted-foreground hover:text-foreground",children:"← Kembali"}),e.jsx("h1",{className:"font-display text-3xl font-bold mt-2 mb-2",children:"Pengaturan Kontak"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Nomor WhatsApp (Stock & Rental) dan Instagram di sini akan digunakan di seluruh website utama (kecuali kategori Partner Resmi & Paid Promote yang punya nomor sendiri per produk). Perubahan tampil real-time."}),e.jsxs("form",{onSubmit:j,className:"card-surface rounded-2xl p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"Wa Khusus Stock"}),e.jsx("input",{type:"text",value:o,onChange:a=>l(a.target.value.replace(/[^0-9]/g,"")),placeholder:"6282312715218",className:"w-full px-4 py-3 rounded-xl bg-card border border-border focus:border-primary focus:ring-2 focus:ring-primary/40 outline-none transition-all text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:'Format internasional tanpa "+" atau spasi. Contoh: 6282312715218'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"Wa Khusus Rental (Opsional)"}),e.jsx("input",{type:"text",value:i,onChange:a=>u(a.target.value.replace(/[^0-9]/g,"")),placeholder:"62812xxxxxxx",className:"w-full px-4 py-3 rounded-xl bg-card border border-border focus:border-primary focus:ring-2 focus:ring-primary/40 outline-none transition-all text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Digunakan untuk CTA WhatsApp khusus Rental di bagian Kontak. Kosongkan untuk menyembunyikan."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"URL Instagram"}),e.jsx("input",{type:"url",value:d,onChange:a=>m(a.target.value),placeholder:"https://instagram.com/username",className:"w-full px-4 py-3 rounded-xl bg-card border border-border focus:border-primary focus:ring-2 focus:ring-primary/40 outline-none transition-all text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Link lengkap profil Instagram."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"URL TikTok (Opsional)"}),e.jsx("input",{type:"url",value:p,onChange:a=>c(a.target.value),placeholder:"https://tiktok.com/@username",className:"w-full px-4 py-3 rounded-xl bg-card border border-border focus:border-primary focus:ring-2 focus:ring-primary/40 outline-none transition-all text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Kosongkan jika tidak ingin menampilkan CTA TikTok."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"URL Saluran WhatsApp (Opsional)"}),e.jsx("input",{type:"url",value:x,onChange:a=>g(a.target.value),placeholder:"https://whatsapp.com/channel/...",className:"w-full px-4 py-3 rounded-xl bg-card border border-border focus:border-primary focus:ring-2 focus:ring-primary/40 outline-none transition-all text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Kosongkan jika tidak ingin menampilkan CTA Saluran WhatsApp."})]}),f&&e.jsx("div",{className:"text-xs px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-foreground",children:f}),e.jsx("button",{type:"submit",disabled:b||s,className:"px-6 py-3 rounded-full bg-primary text-primary-foreground text-sm font-semibold glow-purple-sm hover:-translate-y-0.5 transition disabled:opacity-50",children:b?"Menyimpan...":"Simpan Perubahan"})]})]})}export{A as component};
