1import{ai as V,ce as k,N as E,O as N,j as e,_ as U,$ as ae,a0 as ne,aY as te,aZ as re,B as f,a_ as ie,b1 as Q,ah as Z,a1 as G,cp as ce,k as L,s as y,Z as _,h as w,c0 as X,t as $,r as b,a as S,a4 as M,a5 as T,a6 as D,a7 as I,a8 as C,I as P,ag as H,W as le,y as de,b$ as oe,c1 as xe,aj as O,T as me,p as he,q as A,w as R}from"./index-LAef4FAh.js";import{H as ue}from"./HotelAdminLayout-D45NwIyk.js";import{S as pe}from"./switch-DU3zvDcN.js";import{E as je}from"./ellipsis-vertical-Plc1yVlW.js";import{T as Y,a as J,b as g,c as j,d as ee,e as c}from"./table-D5-oyEO6.js";import{A as se}from"./arrow-up-DZCEHmEP.js";import{D as ye,a as _e,b as ge,c as fe}from"./dialog-DMm6owy5.js";import{R as z}from"./radio-BaF6OSQY.js";import"./use-mobile-Kd5aMTze.js";import"./sheet-Cyv-LVly.js";import"./index-JglnD_Uo.js";import"./ticket-Bcy--bUf.js";import"./log-in-D7fHSPdv.js";import"./ellipsis-D5DDpfqE.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ve=V("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ne=V("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const we=V("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),be={agoda:{label:"Agoda",color:"bg-red-500"},booking_com:{label:"Booking.com",color:"bg-blue-600"},expedia:{label:"Expedia",color:"bg-yellow-500"}};function Ce({connection:t}){const{hotelClient:x}=k(),l=E(),i=be[t.provider]||{label:t.provider,color:"bg-gray-500"},r=N({mutationFn:async()=>{const{error:s}=await y.from("channel_connections").update({is_active:!t.is_active}).eq("id",t.id);if(s)throw s},onSuccess:()=>{l.invalidateQueries({queryKey:["channel-connections"]}),_.success(t.is_active?"à¸à¸´à¸à¹à¸à¹à¸à¸²à¸à¹à¸¥à¹à¸§":"à¹à¸à¸´à¸à¹à¸à¹à¸à¸²à¸à¹à¸¥à¹à¸§")}}),p=N({mutationFn:async()=>{const{data:s,error:o}=await y.functions.invoke("channel-manager",{body:{action:"test_connection",hotel_client_id:x==null?void 0:x.id,channel_connection_id:t.id}});if(o)throw o;return s},onSuccess:s=>{l.invalidateQueries({queryKey:["channel-connections"]}),s!=null&&s.success?_.success("à¸à¸à¸ªà¸à¸à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸à¸ªà¸³à¹à¸£à¹à¸"):_.error((s==null?void 0:s.error)||"à¸à¸à¸ªà¸à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")},onError:s=>_.error(s.message)}),n=N({mutationFn:async()=>{const{error:s}=await y.from("channel_connections").delete().eq("id",t.id);if(s)throw s},onSuccess:()=>{l.invalidateQueries({queryKey:["channel-connections"]}),_.success("ลà¸à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸à¹à¸¥à¹à¸§")}}),d=()=>{switch(t.sync_status){case"syncing":return e.jsxs(w,{variant:"secondary",className:"text-xs",children:[e.jsx(X,{className:"h-3 w-3 mr-1 animate-spin"}),"à¸à¸³à¸¥à¸±à¸ Sync"]});case"error":return e.jsx(w,{variant:"destructive",className:"text-xs",children:"Error"});default:return e.jsx(w,{variant:"outline",className:"text-xs",children:"à¸à¸£à¹à¸à¸¡"})}};return e.jsxs(U,{className:"relative",children:[e.jsx(ae,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${i.color}`}),e.jsx(ne,{className:"text-base",children:i.label})]}),e.jsxs(te,{children:[e.jsx(re,{asChild:!0,children:e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7",children:e.jsx(je,{className:"h-4 w-4"})})}),e.jsxs(ie,{align:"end",children:[e.jsxs(Q,{onClick:()=>p.mutate(),disabled:p.isPending,children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"à¸à¸à¸ªà¸à¸à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸"]}),e.jsxs(Q,{onClick:()=>n.mutate(),className:"text-destructive focus:text-destructive",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"ลà¸"]})]})]})]})}),e.jsxs(G,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[d(),e.jsxs("div",{className:"flex items-center gap-2",children:[t.is_active?e.jsx(ce,{className:"h-4 w-4 text-green-500"}):e.jsx(we,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(pe,{checked:t.is_active,onCheckedChange:()=>r.mutate(),disabled:r.isPending})]})]}),t.property_id&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Property ID: ",e.jsx("span",{className:"font-mono",children:t.property_id})]}),t.last_sync_at&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Sync ลà¹à¸²à¸ªà¸¸à¸: ",L(new Date(t.last_sync_at),"d MMM yyyy HH:mm",{locale:$})]})]})]})}const Se={agoda:"Agoda",booking_com:"Booking.com",expedia:"Expedia"};function ke({connections:t}){var B;const{hotelClient:x}=k(),l=E(),i=x==null?void 0:x.id,[r,p]=b.useState(((B=t[0])==null?void 0:B.id)||""),{data:n}=S({queryKey:["room-types-for-mapping",i],queryFn:async()=>{const{data:a,error:m}=await y.from("room_types").select("id, name_th, name_en").eq("hotel_client_id",i).order("sort_order");if(m)throw m;return a},enabled:!!i}),{data:d}=S({queryKey:["rate-plans-for-mapping",i],queryFn:async()=>{const{data:a,error:m}=await y.from("rate_plans").select("id, name_th, name_en, room_type_id, plan_code").eq("hotel_client_id",i).eq("is_active",!0).order("sort_order");if(m)throw m;return a},enabled:!!i}),{data:s,isLoading:o}=S({queryKey:["channel-room-mappings",r],queryFn:async()=>{const{data:a,error:m}=await y.from("channel_room_mappings").select("*").eq("channel_c
16onnection_id",r).order("created_at");if(m)throw m;return a},enabled:!!r}),v=N({mutationFn:async a=>{const{error:m}=await y.from("channel_room_mappings").insert({channel_connection_id:r,room_type_id:a.room_type_id,rate_plan_id:a.rate_plan_id||null,external_room_id:a.external_room_id,external_rate_id:a.external_rate_id||null});if(m)throw m},onSuccess:()=>{l.invalidateQueries({queryKey:["channel-room-mappings"]}),_.success("à¹à¸à¸´à¹à¸¡ Mapping à¹à¸¥à¹à¸§")},onError:a=>_.error(a.message)}),h=N({mutationFn:async a=>{const{error:m}=await y.from("channel_room_mappings").delete().eq("id",a);if(m)throw m},onSuccess:()=>{l.invalidateQueries({queryKey:["channel-room-mappings"]}),_.success("ลภMapping à¹à¸¥à¹à¸§")}}),[u,q]=b.useState({room_type_id:"",rate_plan_id:"",external_room_id:"",external_rate_id:""});return t.length?(t.find(a=>a.id===r),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:"à¸à¹à¸à¸à¸à¸²à¸:"}),e.jsxs(M,{value:r,onValueChange:p,children:[e.jsx(T,{className:"w-60",children:e.jsx(D,{})}),e.jsx(I,{children:t.map(a=>e.jsxs(C,{value:a.id,children:[Se[a.provider]||a.provider,a.property_id&&` (${a.property_id})`]},a.id))})]})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs(Y,{children:[e.jsx(J,{children:e.jsxs(g,{children:[e.jsx(j,{children:"à¸à¸£à¸°à¹à¸ à¸à¸«à¹à¸à¸ (PMS)"}),e.jsx(j,{children:"Rate Plan (PMS)"}),e.jsx(j,{children:"Room ID (OTA)"}),e.jsx(j,{children:"Rate ID (OTA)"}),e.jsx(j,{children:"สà¸à¸²à¸à¸°"}),e.jsx(j,{className:"w-12"})]})}),e.jsxs(ee,{children:[o?e.jsx(g,{children:e.jsx(c,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸..."})}):s!=null&&s.length?s.map(a=>{const m=n==null?void 0:n.find(K=>K.id===a.room_type_id),F=d==null?void 0:d.find(K=>K.id===a.rate_plan_id);return e.jsxs(g,{children:[e.jsx(c,{className:"font-medium",children:(m==null?void 0:m.name_th)||"-"}),e.jsx(c,{children:(F==null?void 0:F.name_th)||"-"}),e.jsx(c,{className:"font-mono text-xs",children:a.external_room_id||"-"}),e.jsx(c,{className:"font-mono text-xs",children:a.external_rate_id||"-"}),e.jsx(c,{children:e.jsx(w,{variant:a.is_active?"default":"secondary",className:"text-xs",children:a.is_active?"à¹à¸à¹à¸à¸²à¸":"à¸à¸´à¸"})}),e.jsx(c,{children:e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>h.mutate(a.id),children:e.jsx(Z,{className:"h-4 w-4"})})})]},a.id)}):e.jsx(g,{children:e.jsx(c,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"ยัà¸à¹à¸¡à¹à¸¡à¸µ Mapping"})}),e.jsxs(g,{className:"bg-muted/30",children:[e.jsx(c,{children:e.jsxs(M,{value:u.room_type_id,onValueChange:a=>q({...u,room_type_id:a}),children:[e.jsx(T,{className:"h-8 text-xs",children:e.jsx(D,{placeholder:"à¹à¸¥à¸·à¸à¸à¸à¸£à¸°à¹à¸ à¸à¸«à¹à¸à¸"})}),e.jsx(I,{children:n==null?void 0:n.map(a=>e.jsx(C,{value:a.id,children:a.name_th},a.id))})]})}),e.jsx(c,{children:e.jsxs(M,{value:u.rate_plan_id,onValueChange:a=>q({...u,rate_plan_id:a}),children:[e.jsx(T,{className:"h-8 text-xs",children:e.jsx(D,{placeholder:"à¹à¸¥à¸·à¸à¸ Rate Plan"})}),e.jsx(I,{children:d==null?void 0:d.filter(a=>!u.room_type_id||a.room_type_id===u.room_type_id).map(a=>e.jsx(C,{value:a.id,children:a.name_th},a.id))})]})}),e.jsx(c,{children:e.jsx(P,{className:"h-8 text-xs font-mono",placeholder:"Room ID",value:u.external_room_id,onChange:a=>q({...u,external_room_id:a.target.value})})}),e.jsx(c,{children:e.jsx(P,{className:"h-8 text-xs font-mono",placeholder:"Rate ID",value:u.external_rate_id,onChange:a=>q({...u,external_rate_id:a.target.value})})}),e.jsx(c,{colSpan:2,children:e.jsxs(f,{size:"sm",className:"h-8",disabled:!u.room_type_id||!u.external_room_id||v.isPending,onClick:()=>{v.mutate(u),q({room_type_id:"",rate_plan_id:"",external_room_id:"",external_rate_id:""})},children:[e.jsx(H,{className:"h-3 w-3 mr-1"}),"à¹à¸à¸´à¹à¸¡"]})})]})]})]})})]})):e.jsx("div",{className:"text-center py-12 text-muted-foreground border rounded-lg bg-muted/30",children:"à¸à¸£à¸¸à¸à¸²à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸à¸à¹à¸à¸"})}
16const W={pending:{label:"รà¸à¸à¸³à¹à¸à¸´à¸à¸à¸²à¸£",icon:le,variant:"outline"},processing:{label:"à¸à¸³à¸¥à¸±à¸à¸à¸³à¸à¸²à¸",icon:de,variant:"secondary"},completed:{label:"สำà¹à¸£à¹à¸",icon:oe,variant:"default"},failed:{label:"ลà¹à¸¡à¹à¸«à¸¥à¸§",icon:xe,variant:"destructive"}};function qe(){const{hotelClient:t}=k(),x=E(),l=t==null?void 0:t.id,{data:i,isLoading:r}=S({queryKey:["sync-queue",l],queryFn:async()=>{const{data:s,error:o}=await y.from("sync_queue").select("*, channel_connections(provider, property_id)").eq("hotel_client_id",l).order("created_at",{ascending:!1}).limit(50);if(o)throw o;return s},enabled:!!l,refetchInterval:1e4}),p=N({mutationFn:async()=>{const{data:s,error:o}=await y.functions.invoke("channel-sync-worker",{body:{}});if(o)throw o;return s},onSuccess:s=>{x.invalidateQueries({queryKey:["sync-queue"]}),_.success(`à¸à¸£à¸°à¸¡à¸§à¸¥à¸à¸¥à¹à¸¥à¹à¸§ ${(s==null?void 0:s.processed)||0} รายà¸à¸²à¸£`)},onError:s=>_.error(s.message)}),n=(i==null?void 0:i.filter(s=>s.status==="pending").length)||0,d=(i==null?void 0:i.filter(s=>s.status==="failed").length)||0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"รà¸à¸à¸³à¹à¸à¸´à¸à¸à¸²à¸£:"})," ",e.jsx("span",{className:"font-bold",children:n})]}),d>0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-destructive",children:"ลà¹à¸¡à¹à¸«à¸¥à¸§:"})," ",e.jsx("span",{className:"font-bold text-destructive",children:d})]})]}),e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>p.mutate(),disabled:p.isPending||n===0,children:[e.jsx(X,{className:`h-4 w-4 mr-1 ${p.isPending?"animate-spin":""}`}),"Sync à¸à¸à¸à¸à¸µà¹"]})]}),r?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸..."}):i!=null&&i.length?e.jsx("div",{className:"space-y-2",children:i.map(s=>{var u;const o=W[s.status]||W.pending,v=o.icon,h=(u=s.channel_connections)==null?void 0:u.provider;return e.jsx(U,{className:"py-0",children:e.jsxs(G,{className:"p-3 flex items-center gap-3",children:[e.jsx(v,{className:`h-4 w-4 flex-shrink-0 ${s.status==="processing"?"animate-spin":""} ${s.status==="failed"?"text-destructive":s.status==="completed"?"text-green-600":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.action}),h&&e.jsx(w,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:h})]}),s.error_message&&e.jsx("p",{className:"text-xs text-destructive truncate mt-0.5",children:s.error_message})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx(w,{variant:o.variant,className:"text-[10px]",children:o.label}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[s.retry_count>0&&`retry ${s.retry_count}/${s.max_retries} · `,L(new Date(s.created_at),"HH:mm",{locale:$})]})]})]})},s.id)})}):e.jsx("div",{className:"text-center py-12 border rounded-lg bg-muted/30 text-muted-foreground",children:"ยัà¸à¹à¸¡à¹à¸¡à¸µà¸£à¸²à¸¢à¸à¸²à¸£ Sync"})]})}const Me={push:se,pull:ve};function Te(){const{hotelClient:t}=k(),x=t==null?void 0:t.id,[l,i]=b.useState("all"),{data:r,isLoading:p}=S({queryKey:["sync-logs",x,l],queryFn:async()=>{let n=y.from("sync_logs").select("*, channel_connections(provider, property_id)").eq("hotel_client_id",x).order("created_at",{ascending:!1}).limit(100);l!=="all"&&(n=n.eq("status",l));const{data:d,error:s}=await n;if(s)throw s;return d},enabled:!!x});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:"à¸à¸£à¸à¸:"}),e.jsxs(M,{value:l,onValueChange:i,children:[e.jsx(T,{className:"w-40",children:e.jsx(D,{})}),e.jsxs(I,{children:[e.jsx(C,{value:"all",children:"à¸à¸±à¹à¸à¸«à¸¡à¸"}),e.jsx(C,{value:"success",children:"สำà¹à¸£à¹à¸"}),e.jsx(C,{value:"failed",children:"ลà¹à¸¡à¹à¸«à¸¥à¸§"})]})]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["à¹à¸ªà¸à¸ ",(r==null?void 0:r.length)||0," รายà¸à¸²à¸£à¸¥à¹à¸²à¸ªà¸¸à¸"]})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs(Y,{children:[e.jsx(J,{children:e.jsxs(g,{children:[e.jsx(j,{className:"w-12",children:"à¸à¸´à¸¨à¸à¸²à¸"}),e.jsx(j,{children:"à¸à¹à¸à¸à¸à¸²à¸"}),e.jsx(j,{children:"Action"}),e.jsx(j,{children:"สà¸à¸²à¸à¸°"}),e.jsx(j,{children:"ระยะà¹à¸§à¸¥à¸²"}),e.jsx(j,{children:"à¹à¸§à¸¥à¸²"}),e.jsx(j,{children:"à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸"})]})}),e.jsx(ee,{children:p?e.jsx(g,{children:e.jsx(c,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸..."})}):r!=null&&r.length?r.map(n=>{var o;
16const d=Me[n.direction]||se,s=(o=n.channel_connections)==null?void 0:o.provider;return e.jsxs(g,{children:[e.jsx(c,{children:e.jsx(d,{className:`h-4 w-4 ${n.direction==="push"?"text-blue-500":"text-green-500"}`})}),e.jsx(c,{className:"text-sm",children:s||"-"}),e.jsx(c,{className:"text-xs font-mono",children:n.action}),e.jsx(c,{children:e.jsx(w,{variant:n.status==="success"?"default":"destructive",className:"text-[10px]",children:n.status==="success"?"สำà¹à¸£à¹à¸":"ลà¹à¸¡à¹à¸«à¸¥à¸§"})}),e.jsx(c,{className:"text-xs text-muted-foreground",children:n.duration_ms!=null?`${n.duration_ms}ms`:"-"}),e.jsx(c,{className:"text-xs text-muted-foreground",children:L(new Date(n.created_at),"d MMM HH:mm:ss",{locale:$})}),e.jsx(c,{className:"text-xs text-destructive max-w-48 truncate",children:n.error_message||"-"})]},n.id)}):e.jsx(g,{children:e.jsx(c,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"ยัà¸à¹à¸¡à¹à¸¡à¸µà¸à¸£à¸°à¸§à¸±à¸à¸´ Sync"})})})]})})]})}const De=[{value:"agoda",label:"Agoda"},{value:"booking_com",label:"Booking.com"},{value:"expedia",label:"Expedia"}];function Ie({open:t,onOpenChange:x}){const{hotelClient:l}=k(),i=E(),[r,p]=b.useState(""),[n,d]=b.useState(""),[s,o]=b.useState(""),v=N({mutationFn:async()=>{const{error:h}=await y.from("channel_connections").insert({hotel_client_id:l.id,provider:r,property_id:n||null,credentials:s?{api_key:s}:{},is_active:!0,sync_status:"idle"});if(h)throw h},onSuccess:()=>{i.invalidateQueries({queryKey:["channel-connections"]}),_.success("à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸à¹à¸¥à¹à¸§"),x(!1),p(""),d(""),o("")},onError:h=>_.error(h.message)});return e.jsx(ye,{open:t,onOpenChange:x,children:e.jsxs(_e,{className:"sm:max-w-md",children:[e.jsx(ge,{children:e.jsx(fe,{children:"à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸ OTA"})}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"à¸à¹à¸à¸à¸à¸²à¸ (Provider)"}),e.jsxs(M,{value:r,onValueChange:p,children:[e.jsx(T,{children:e.jsx(D,{placeholder:"à¹à¸¥à¸·à¸à¸à¸à¹à¸à¸à¸à¸²à¸"})}),e.jsx(I,{children:De.map(h=>e.jsx(C,{value:h.value,children:h.label},h.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Property ID (รหัสà¹à¸£à¸à¹à¸£à¸¡à¸à¸±à¹à¸ OTA)"}),e.jsx(P,{placeholder:"à¹à¸à¹à¸ 12345678",value:n,onChange:h=>d(h.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"API Key / Token (à¸à¹à¸²à¸¡à¸µ)"}),e.jsx(P,{type:"password",placeholder:"API key สำหรัà¸à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸",value:s,onChange:h=>o(h.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸°à¸à¸¹à¸à¹à¸à¹à¸à¸à¸¢à¹à¸²à¸à¸à¸¥à¸à¸à¸ ัยà¹à¸à¸à¸²à¸à¸à¹à¸à¸¡à¸¹à¸¥"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(f,{variant:"outline",onClick:()=>x(!1),children:"ยà¸à¹à¸¥à¸´à¸"}),e.jsx(f,{onClick:()=>v.mutate(),disabled:!r||v.isPending,children:"à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸"})]})]})]})})}function We(){const{hotelClient:t}=k(),[x,l]=b.useState(!1),i=t==null?void 0:t.id,{data:r,isLoading:p}=S({queryKey:["channel-connections",i],queryFn:async()=>{const{data:n,error:d}=await y.from("channel_connections").select("*").eq("hotel_client_id",i).order("created_at",{ascending:!1});if(d)throw d;return n},enabled:!!i});return e.jsx(ue,{children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(z,{className:"h-6 w-6 text-primary"}),"Channel Manager"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸ OTA à¹à¸¥à¸°à¸à¸±à¸à¸à¸²à¸£ Room/Rate Mapping"})]}),e.jsxs(f,{onClick:()=>l(!0),size:"sm",children:[e.jsx(H,{className:"h-4 w-4 mr-1"}),"à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸"]})]}),e.jsxs(me,{defaultValue:"connections",className:"space-y-4",children:[e.jsxs(he,{children:[e.jsx(A,{value:"connections",children:"à¸à¹à¸à¸à¸à¸²à¸à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸"}),e.jsx(A,{value:"mapping",children:"Room & Rate Mapping"}),e.jsx(A,{value:"sync",children:"สà¸à¸²à¸à¸° Sync"}),e.jsx(A,{value:"logs",children:"à¸à¸£à¸°à¸§à¸±à¸à¸´ Sync"})]}),e.jsx(R,{value:"connections",className:"space-y-4",children:p?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸..."}):r!=null&&r.length?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:r.map(n=>e.jsx(Ce,{connection:n},n.id))}):e.jsxs("div",{className:"text-center py-12 border rounded-lg bg-muted/30",children:[e.jsx(z,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"ยัà¸à¹à¸¡à¹à¸¡à¸µà¸à¹à¸à¸à¸à¸²à¸à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸"}),e.jsxs(f,{variant:"outline",className:"mt-3",onClick:()=>l(!0),children:[e.jsx(H,{className:"h-4 w-4 mr-1"}),"à¹à¸à¸´à¹à¸¡à¸à¹à¸à¸à¸à¸²à¸à¹à¸£à¸"]})]})}),e.jsx(R,{value:"mapping",children:e.jsx(ke,{connections:r||[]})}),e.jsx(R,{value:"sync",children:e.jsx(qe,{})}),e.jsx(R,{value:"logs",children:e.jsx(Te,{})})]}),e.jsx(Ie,{open:x,onOpenChange:l})]})})}export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.