PageSourceSearch

https://letshubon.com/assets/js/index-CR2Xd3gE.js

js letshubon.com collected 2026-09-24 19:20:43 UTC 32,020 bytes, 1 lines download raw bytes

1import{a as j,j as e,x as be,n as je,L as ne}from"./vendor-BEUer1XH.js";import{g as ve}from"./category.api-eHgYhx1x.js";import{u as ke,d as Se,c as Ie,b as Ne,e as we,f as Oe,h as Ce,i as Pe,j as Fe,k as Ae,l as Ee,m as He,n as qe,o as Te,p as Me,q as Ve}from"./hub.api-QvfEmAyg.js";import{g as Re}from"./hub_group.api-Dr6N6_Mm.js";import{g as Ke}from"./storage_type.api-DKh_-ULS.js";import{D as G}from"./DeleteOutlined-BR3viz2f.js";import{E as ue}from"./EditOutlined-zMoOxsKH.js";import{E as Le}from"./EyeOutlined-BBHl2ktf.js";import{u as K}from"./useQuery-BhaiNdUJ.js";import{u as z}from"./useMutation-KANBv_r7.js";import{i as L,d as N}from"./utils-w1iDNRBg.js";import{C as $e}from"./index-_xoAewD-.js";import{I as me}from"./index-CsvSiRX6.js";import{aU as Be,b as Ue,aB as ze,y as pe,n as Qe,cb as We,D as Q,T as he,B as M,a2 as W}from"./index-DENArrSa.js";import{F as p}from"./index-BYqFq3zo.js";import{M as J}from"./index-BFXII9Et.js";import{I as O}from"./index-CW5BAikS.js";import{F as X}from"./Table-DVvNjDQl.js";import{A as Ye}from"./index-BqoSzrcK.js";import{S as fe}from"./index-DQHdZsHa.js";import{D as V,p as P,m as R,i as Ge}from"./format.date-nJSPwOdY.js";import{g as ye}from"./PurePanel-CbtVgttN.js";import{D as _e}from"./index-CicvpzNy.js";import{M as Je}from"./index-DoV0blCP.js";import{S as $}from"./index-Cn9ZDzL8.js";import{C as Y}from"./index-pp2-ToLR.js";import{T as Xe}from"./index-BnMR4Z1r.js";import{L as Ze}from"./index-xmoZg6gj.js";import{u as De}from"./useUpdateQuery-CBQx1ptH.js";import{b as et,d as tt,P as st,n as nt,w as it,p as ot}from"./format.phone-BhePyXg2.js";import{B as rt}from"./Breadcrumb-DW4w8HQp.js";import{T as lt}from"./index-Boju0Jh-.js";import"./index-C9C5-gxl.js";import"./index-CrRiyByw.js";import"./EyeOutlined-D647LYEE.js";import"./addEventListener-DapjV_MG.js";import"./LeftOutlined-CpjQE-vN.js";import"./RightOutlined-9GOMZsx1.js";import"./CloseOutlined-ArQtM8bV.js";import"./image.compressor-CWG2CkHV.js";import"./collapse-BbEVqHco.js";import"./useBreakpoint-BBrUbbpN.js";import"./mediaQueryUtil-BSyvLspT.js";import"./useForm-DrUwT_4T.js";import"./Input-CD5EvbY1.js";import"./Search-cPbr6bPB.js";import"./SearchOutlined-DVVMytpw.js";import"./DownOutlined-CeXDrnPO.js";import"./dropdown-qHy0AlcK.js";import"./Dropdown-CDCCRALY.js";import"./index-BzPrgs7b.js";import"./EllipsisOutlined-Djar-icM.js";import"./Overflow-CAQIMHA2.js";import"./index-B3fdPxRr.js";import"./Pagination-B4vWHmlc.js";import"./index-CCT_oRJ6.js";import"./index-CUWDS_la.js";import"./index-Dw3gOJax.js";import"./gapSize-U1swVQyS.js";import"./weekday-DCQWGhN8.js";import"./ClockCircleOutlined-f775a1e4.js";const{Option:ie}=$;function oe(t){return(t==null?void 0:t.type)&&(t.type.isSelectOption||t.type.isSelectOptGroup)}const at=(t,s)=>{var o,a;const{prefixCls:f,className:I,popupClassName:k,dropdownClassName:h,children:g,dataSource:c,dropdownStyle:x,dropdownRender:v,popupRender:A,onDropdownVisibleChange:u,onOpenChange:b,styles:_,classNames:i}=t,l=Be(g),d=((o=_==null?void 0:_.popup)===null||o===void 0?void 0:o.root)||x,m=((a=i==null?void 0:i.popup)===null||a===void 0?void 0:a.root)||k||h,n=A||v,r=b||u;let y;l.length===1&&j.isValidElement(l[0])&&!oe(l[0])&&([y]=l);const F=y?()=>y:void 0;let E;l.length&&oe(l[0])?E=g:E=c?c.map(w=>{if(j.isValidElement(w))return w;switch(typeof w){case"string":return j.createElement(ie,{key:w,value:w},w);case"object":{const{value:q}=w;return j.createElement(ie,{key:q,value:q},w.text)}default:return}}):[];const{getPrefixCls:S}=j.useContext(Ue),C=S("select",f),[H]=ze("SelectLike",d==null?void 0:d.zIndex);return j.createElement($,Object.assign({ref:s,suffixIcon:null},pe(t,["dataSource","dropdownClassName","popupClassName"]),{prefixCls:C,classNames:{popup:{root:m},root:i==null?void 0:i.root},styles:{popup:{root:Object.assign(Object.assign({},d),{zIndex:H})},root:_==null?void 0:_.root},className:Qe(`${C}-auto-complete`,I),mode:$.SECRET_COMBOBOX_MODE_DO_NOT_USE,popupRender:n,onOpenChange:r,getInputElement:F}),E)},ge=j.forwardRef(at),{Option:dt}=$,ct=ye(ge,"dropdownAlign",t=>pe(t,["visible"])),Z=ge;Z.Option=dt;Z._InternalPanelDoNotUseOrYouWillBeFired=ct;var ut=function(t,s){var o={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&s.indexOf(a)<0&&(o[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var f=0,a=Object.getOwnPropertySymbols(t);f<a.length;f++)s.indexOf(a[f])<0&&Object.prototype.propertyIsEnumerable.call(t,a[f])&&(o[a[f]]=t[a[f]]);return o};const{TimePicker:mt,RangePicker:pt}=_e,ht=j.forwardRef((t,s)=>j.createElement(pt,Object.assign({},t,{picker:"time",mode:void 0,ref:s}))),T=j.forwardRef((t,s)=>{var{addon:o,renderExtraFooter:a,variant:f,bordered:I}=t,k=ut(t,["addon","renderExtraFooter","variant","bordered"]);const[h]=We("timePicker",f,I),g=j.useMemo(()=>
1{if(a)return a;if(o)return o},[o,a]);return j.createElement(mt,Object.assign({},k,{mode:void 0,ref:s,renderExtraFooter:g,variant:h}))}),xe=ye(T,"popupAlign",void 0,"picker");T._InternalPanelDoNotUseOrYouWillBeFired=xe;T.RangePicker=ht;T._InternalPanelDoNotUseOrYouWillBeFired=xe;function B(t){"@babel/helpers - typeof";return B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},B(t)}function re(t,s){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(f){return Object.getOwnPropertyDescriptor(t,f).enumerable})),o.push.apply(o,a)}return o}function le(t){for(var s=1;s<arguments.length;s++){var o=arguments[s]!=null?arguments[s]:{};s%2?re(Object(o),!0).forEach(function(a){ft(t,a,o[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):re(Object(o)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(o,a))})}return t}function ft(t,s,o){return(s=yt(s))in t?Object.defineProperty(t,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[s]=o,t}function yt(t){var s=_t(t,"string");return B(s)=="symbol"?s:s+""}function _t(t,s){if(B(t)!="object"||!t)return t;var o=t[Symbol.toPrimitive];if(o!==void 0){var a=o.call(t,s);if(B(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function gt(t,s,o){s&&s.defaultCountry&&!et(s.defaultCountry,o)&&(s=le(le({},s),{},{defaultCountry:void 0}));try{return tt(t,s,o)}catch(a){if(!(a instanceof st))throw a}}function U(t){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},U(t)}function ae(t,s){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(f){return Object.getOwnPropertyDescriptor(t,f).enumerable})),o.push.apply(o,a)}return o}function de(t){for(var s=1;s<arguments.length;s++){var o=arguments[s]!=null?arguments[s]:{};s%2?ae(Object(o),!0).forEach(function(a){xt(t,a,o[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):ae(Object(o)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(o,a))})}return t}function xt(t,s,o){return(s=bt(s))in t?Object.defineProperty(t,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[s]=o,t}function bt(t){var s=jt(t,"string");return U(s)=="symbol"?s:s+""}function jt(t,s){if(U(t)!="object"||!t)return t;var o=t[Symbol.toPrimitive];if(o!==void 0){var a=o.call(t,s);if(U(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function vt(){var t=nt(arguments),s=t.text,o=t.options,a=t.metadata;o=de(de({},o),{},{extract:!1});var f=gt(s,o,a);return f&&f.isValid()||!1}function kt(){return it(vt,arguments)}const{Text:St}=he,It=({hubData:t})=>{const{notification:s}=Q.useApp(),[o]=p.useForm(),[a,f]=j.useState(!1),[I,k]=j.useState(null),{data:h,isLoading:g,isError:c,refetch:x}=K({queryKey:["hub-coupon",t],queryFn:()=>Ne({id:t==null?void 0:t.id}),select:n=>{var r;return(r=n==null?void 0:n.hub_coupons)==null?void 0:r.map(y=>({...y,key:y.id}))},retry:0}),v=n=>{f(n),n||(o.resetFields(),k(null))},A=()=>o.setFieldValue("image",""),u=n=>{o.setFieldValue("image",n)},{mutate:b,isPending:_}=z({mutationFn:n=>n.has("coupon_id")?ke(n):n.has("delete_id")?Se(n):Ie(n),onSettled:(n,r,y)=>{var H,w,q,D,ee,te;const F=y.get("coupon_id"),E=y.get("delete_id"),S=y.get("title");let C=`Coupon ${S} has been added`;if(F&&(C=`Coupon ${S} has been updated`),E&&(C=(H=n==null?void 0:n.data)==null?void 0:H.message),s.success({message:C}),E||o.resetFields(),v(!1),x(),r&&L(r)){let se=r==null?void 0:r.message;(q=(w=r==null?void 0:r.response)==null?void 0:w.data)!=null&&q.error&&(se=(te=(ee=(D=r==null?void 0:r.response)==null?void 0:D.data)==null?void 0:ee.details)==null?void 0:te.message),s.error({message:se})}}}),i=async()=>{const n=await o.validateFields();if(n){const r=new FormData;n.coupon_id&&r.append("coupon_id",n.coupon_id),n.id&&r.append("id",n.id),r.append("title",n.title),n.description!==null&&r.append("description",n.description),n.fine_print!==null&&r.append("fine_print",n.fine_print),n.c
1ode!==null&&r.append("code",n.code),r.append("redeem_expiry_days",n.redeem_expiry_days),n.image&&r.append("image",n.image),b(r)}},l=(n,r)=>{const y=new FormData;n&&y.append("id",String(n)),r&&y.append("delete_id",String(r)),b(y)},d=(n,r)=>{k(r.image_url),v(!0),o.setFieldsValue({...r,id:n,coupon_id:r.id})},m=[{title:"ID",dataIndex:"id",key:"id"},{title:"Image",align:"center",dataIndex:"image_url",key:"image_url",render:n=>e.jsx(Ye,{shape:"square",size:{xs:12,sm:16,md:24,lg:32,xl:40,xxl:64},src:e.jsx($e,{width:200,src:n,preview:{mask:e.jsx(Le,{})}})})},{title:"Title",dataIndex:"title",key:"title"},{title:"Code",dataIndex:"code",key:"code"},{title:"Description",dataIndex:"description",key:"description"},{title:"Fine Print",dataIndex:"fine_print",key:"fine_print"},{title:"Action",dataIndex:"id",key:"action",align:"center",render:(n,r)=>e.jsxs(fe,{align:"center",children:[e.jsx(M,{type:"text",icon:e.jsx(ue,{}),onClick:()=>t?d(Number(t.id),r):{}}),e.jsx(M,{danger:!0,type:"text",icon:e.jsx(G,{}),onClick:()=>t?l(Number(t.id),n):{}})]})}];return c?e.jsx("section",{className:"container my-4 text-center",children:e.jsx(St,{children:"No Found Hub"})}):e.jsxs("section",{className:"container my-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("p",{className:"text-sm text-right",children:[h==null?void 0:h.length," results found"]}),e.jsx(M,{type:"primary",onClick:()=>v(!0),children:"Add Hub Coupon"}),e.jsx(J,{title:"Coupon Form",open:a,onOk:i,onCancel:()=>v(!1),okText:"Submit",okButtonProps:{loading:_},children:e.jsxs(p,{requiredMark:!1,form:o,name:"form-hub-coupon",initialValues:{id:t==null?void 0:t.id,image:"",title:"",description:"",fine_print:"",code:"",redeem_expiry_days:0},autoComplete:"off",layout:"vertical",children:[e.jsx(p.Item,{name:"coupon_id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{name:"id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{label:"Coupon Image",name:"image",children:e.jsx(me,{height:"100%",...I&&{initialValue:[I]},onImageChange:u,onImageRemove:A})}),e.jsx(p.Item,{label:"Title",name:"title",rules:[{required:!0,message:"This field is required!"}],children:e.jsx(O,{placeholder:"Input title"})}),e.jsx(p.Item,{label:"Description",name:"description",children:e.jsx(O.TextArea,{rows:3,placeholder:"Input description"})}),e.jsx(p.Item,{label:"Fine Print",name:"fine_print",children:e.jsx(O.TextArea,{rows:3,placeholder:`Default fine print : This coupon must be used immediately while picking up or dropping off packages at ${t.name}`})}),e.jsx(p.Item,{label:"Code",name:"code",children:e.jsx(O,{placeholder:"Input code"})}),e.jsx(p.Item,{label:"Expiry Days",name:"redeem_expiry_days",rules:[{required:!0,message:"This field is required!"}],children:e.jsx(O,{placeholder:"Input expiry days",type:"number"})})]})})]}),e.jsx(X,{loading:g||_,bordered:!0,columns:m,dataSource:h,pagination:!1})]})},Nt=({hubData:t,deliveryData:s})=>{const{notification:o}=Q.useApp(),[a]=p.useForm(),f=W();j.useEffect(()=>{if(!s)return;const g=V.map(c=>{const x=s.find(v=>String(v.day).toLowerCase()===c.label.toLowerCase());return{day:c.label,open_hour:x!=null&&x.open_hour?N(x.open_hour,P):null,close_hour:x!=null&&x.close_hour?N(x.close_hour,P):null,hub_delivery_break_hour:x!=null&&x.hub_delivery_break_hour?{start_hour:x.hub_delivery_break_hour.start_hour?N(x.hub_delivery_break_hour.start_hour,P):null,end_hour:x.hub_delivery_break_hour.end_hour?N(x.hub_delivery_break_hour.end_hour,P):null}:null}});a.setFieldsValue({id:t==null?void 0:t.id,hub_delivery_hours:g})},[t,s,a]);const{mutate:I,isPending:k}=z({mutationFn:g=>we(g),onSettled:(g,c)=>{var x,v,A,u,b;if(g!=null&&g.hub_delivery_hours)o.success({message:"Hub delivery hours is updated"}),f.invalidateQueries({queryKey:["hub-delivery-hour"]}),f.invalidateQueries({queryKey:["hub"]});else if(c&&L(c)){let _=c==null?void 0:c.message;(v=(x=c==null?void 0:c.response)==null?void 0:x.data)!=null&&v.error&&(_=(b=(u=(A=c==null?void 0:c.response)==null?void 0:A.data)==null?void 0:u.details)==null?void 0:b.message),o.error({message:_})}}}),h=g=>{g.hub_delivery_hours=g.hub_delivery_hours.map(c=>{var x;return{...c,open_hour:c.open_hour?N(c.open_hour).format(P):"",close_hour:c.close_hour?N(c.close_hour).format(P):"",day:Number((x=V.find(v=>v.label.toLowerCase()===String(c.day).toLowerCase()))==null?void 0:x.value),hub_delivery_break_hour:c.hub_delivery_break_hour?{...c.hub_delivery_break_hour,start_hour:c.hub_delivery_break_hour.start_hour?N(c.hub_delivery_break_hour.start_hour).format(P):"",end_hour:c.hub_delivery_break_hour.end_hour?N(c.hub_delivery_break_hour.end_hour).format(P):""}:null}}),I(g)};return e.jsx("section",{children:e.jsxs(p,{requiredMark:!1,name:"form-hub-delivery-hour",initialValues:{id:t==null?void 0:t.id,hub_delivery_hours:s},form:a,onFinish:h,autoComplete:"off",layout:"vertical",children:[(t==null?void 0:t.id)&&e.jsx(p.Item,{name:"id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("div",{className:"flex-grow md:flex-1",children:[e.jsx("p",{className:"mb-3",children:"Delivery Hours"}),e.jsxs("p",{className:"mb-3 text-sm",children:[e.jsx("strong",{children:"Note:"})," Close hours must be greater than open hours."]}),V.map((g,c)=>e.jsxs(j.Fragment,{children:[e.jsx("p",{children:g.label}),e.jsx(p.Item,{name:["hub_delivery_hours",c,"day"],noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(p.Item,{name:["hub_delivery_hours",c,"open_hour"],className:"w-full",children:e.jsx(T,{format:R,placeholder:"Select time",className:"w-full"})}),"-",e.jsx(p.Item,{name:["hub_delivery_hours",c,"close_hour"],className:"w-full",children:e.jsx(T,{format:R,placeholder:"Select time",className:"w-full"})})]})]},c))]}),e.jsxs("div",{className:"flex-grow md:flex-1",children:[e.jsx("p",{className:"mb-3",children:"Delivery Break Hours"}),e.jsxs("p",{className:"mb-3 text-sm",children:[e.jsx("strong",{children:"Note:"})," End hours must be greater than start hours."]}),V.map((g,c)=>e.jsxs(j.Fragment,{children:[e.jsx("p",{children:g.label}),e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(p.Item,{name:["hub_delivery_hours",c,"hub_delivery_break_hour","start_hour"],className:"w-full",children:e.jsx(T,{format:R,className:"w-full",placeholder:"Select time"})}),"-",e.jsx(p.Item,{name:["hub_delivery_hours",c,"hub_delivery_break_hour","end_hour"],className:"w-full",children:e.jsx(T,{format:R,className:"w-full",placeholder:"Select time"})})]})]},c))]})]}
1),e.jsx(p.Item,{children:e.jsx(M,{type:"primary",htmlType:"submit",loading:k,disabled:k,children:"Update"})})]})})},wt=t=>{const[s,o]=j.useState([]);return j.useEffect(()=>{if(!t){o([]);return}new google.maps.places.AutocompleteService().getPlacePredictions({input:t},f=>{o(f||[])})},[t]),s},Ot=({placeholder:t,sizeInput:s,onSelect:o,className:a,style:f,...I})=>{const[k,h]=j.useState(""),g=wt(k),c=j.useMemo(()=>g.map(v=>({...v,label:v.description,value:v.description,place_id:v.place_id})),[g]),x=v=>{const A=g.find(u=>u.description===v);A&&o&&new google.maps.places.PlacesService(document.createElement("div")).getDetails({placeId:A.place_id},(b,_)=>{_===google.maps.places.PlacesServiceStatus.OK&&b&&o(v,b)})};return e.jsx(Z,{className:a,style:f,options:c,onSelect:x,onSearch:v=>h(v),...I,children:e.jsx(O,{size:s,placeholder:t,allowClear:!0})})},Ct=({hubData:t,categoryData:s,hubGroupData:o})=>{const a=be(),{notification:f}=Q.useApp(),[I]=p.useForm(),k=W(),[h,g]=j.useState(t),[c,x]=j.useState({lat:37.33548,lng:-121.893028});j.useEffect(()=>{var n,r;t!=null&&t.id&&(g(t),I.setFieldsValue(t));const d=(n=t==null?void 0:t.address)==null?void 0:n.latitude,m=(r=t==null?void 0:t.address)==null?void 0:r.longitude;m&&d&&x({lat:Number(d),lng:Number(m)})},[t,I]);const v=()=>I.setFieldValue("image",""),A=d=>{I.setFieldValue("image",d)},{mutate:u,isPending:b}=z({mutationFn:d=>{const m=d.get("status"),n=d.get("id");return m==="active"?Oe(d):m==="inactive"?Ce(d):n?Pe(d):Fe(d)}}),_=d=>{const m=new FormData;if(d.hub_hours&&d.hub_hours.map(n=>{var y;const r={...n,day:Number((y=V.find(F=>F.label.toLowerCase()===n.day))==null?void 0:y.value),open_hour:n.open_hour?N(n.open_hour).format(P):"",close_hour:n.close_hour?N(n.close_hour).format(P):"",hub_break_hour:n.hub_break_hour&&n.hub_break_hour.start_hour&&n.hub_break_hour.end_hour?{...n.hub_break_hour,start_hour:n.hub_break_hour.start_hour?N(n.hub_break_hour.start_hour).format(P):"",end_hour:n.hub_break_hour.end_hour?N(n.hub_break_hour.end_hour).format(P):""}:null};m.append("hub_hours[]",JSON.stringify(r))}),d.category_ids)for(const n in d.category_ids){const r=d.category_ids[n];m.append("category_ids[]",r.toString())}if(d.hub_group_ids){for(const n in d.hub_group_ids)if(d.hub_group_ids[n]){const r=d.hub_group_ids[n];m.append("hub_group_ids[]",r)}}d.image&&m.append("image",d.image),d.id&&m.append("id",d.id.toString()),m.append("name",d.name),m.append("address",d.address.full_address),m.append("latitude",d.latitude),m.append("longitude",d.longitude),m.append("contact",d.contact),m.append("is_warehouse",d.is_warehouse?d.is_warehouse:"false"),u(m,{onSettled:(n,r)=>{var y,F,E,S,C,H,w;if(n!=null&&n.hub)f.success({message:`${(y=n.hub)==null?void 0:y.name} has been updated`}),k.invalidateQueries({queryKey:["hub"]}),k.invalidateQueries({queryKey:["hub-delivery-hour"]}),a(`/admin/hub-list/${(F=n==null?void 0:n.hub)==null?void 0:F.id}`);else if(r&&L(r)){let q=r==null?void 0:r.message;(S=(E=r==null?void 0:r.response)==null?void 0:E.data)!=null&&S.error&&(q=(w=(H=(C=r==null?void 0:r.response)==null?void 0:C.data)==null?void 0:H.details)==null?void 0:w.message),f.error({message:q})}}})},i=(d,m)=>{if(d&&m&&m.geometry&&m.geometry.location){const n=m.geometry.location.lat(),r=m.geometry.location.lng();I.setFieldsValue({latitude:n,longitude:r}),x({lat:n,lng:r})}},l=(d,m)=>{const n=new FormData;n.append("id",m.toString()),n.append("status",d),u(n,{onSettled:(r,y)=>{var F,E,S,C,H,w;if(r){let q="Status has changed to active";d==="active"&&(q=`${(F=r.hub)==null?void 0:F.name} status has changed to inactive`),f.success({message:q}),g(r.hub),k.invalidateQueries({queryKey:["hub"]})}else if(y&&L(y)){let q=y==null?void 0:y.message;(S=(E=y==null?void 0:y.response)==null?void 0:E.data)!=null&&S.error&&(q=(w=(H=(C=y==null?void 0:y.response)==null?void 0:C.data)==null?void 0:H.details)==null?void 0:w.message),f.error({message:q})}}})};return e.jsxs(p,{requiredMark:!1,name:"form-hub-detail",initialValues:h,form:I,onFinish:_,autoComplete:"off",layout:"vertical",children:[(h==null?void 0:h.id)&&e.jsx(p.Item,{name:"id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsxs("div",{className:"flex flex-wrap gap-4 mb-8",children:[e.jsxs("div",{className:"flex-grow 
1space-y-4 md:flex-1",children:[e.jsx(p.Item,{name:"is_warehouse",valuePropName:"checked",children:e.jsx(Y,{children:"Is a Warehouse?"})}),e.jsx(p.Item,{label:"Hub Image",name:"image",children:e.jsx(me,{height:"100%",...(h==null?void 0:h.image_url)&&{initialValue:[h==null?void 0:h.image_url]},onImageChange:A,onImageRemove:v})}),!(t!=null&&t.id)&&e.jsx(p.Item,{label:"Hub Groups",name:"hub_group_ids",rules:[{required:!0,message:"Please input hub group!"}],children:e.jsx($,{mode:"multiple",allowClear:!0,placeholder:"Select hub groups",options:o==null?void 0:o.map(d=>({value:d.id,label:d.name,key:d.id}))})}),e.jsx(p.Item,{label:"Hub Name",name:"name",rules:[{required:!0,message:"Please input hub name!"}],children:e.jsx(O,{placeholder:"Input hub name"})}),e.jsx(p.Item,{label:"Hub Contact",name:"contact",rules:[{required:!0,message:"Please input hub contact!"}],children:e.jsx(O,{placeholder:"Input hub contact"})}),e.jsx(p.Item,{label:"Select Hub Category",name:"category_ids",rules:[{required:!0,message:"Please select hub category!"}],children:e.jsx(Y.Group,{className:"gap-3",children:(s||[]).map((d,m)=>e.jsx(Y,{value:d.id,children:d.name},m))})}),e.jsx(p.Item,{label:"Hub Address",name:["address","full_address"],rules:[{required:!0,message:"Please input hub address!"}],children:e.jsx(Ot,{placeholder:"Search for a place",sizeInput:"large",onSelect:(d,m)=>i(d,m),className:"w-full"})}),e.jsx(p.Item,{name:"latitude",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{name:"longitude",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(Je,{center:c,height:"30vh"})]}),e.jsxs("div",{className:"flex-grow md:flex-1",children:[e.jsx("p",{className:"mb-3",children:"Operational Hours"}),e.jsxs("p",{className:"mb-3 text-sm",children:[e.jsx("strong",{children:"Note:"})," Close hours must be greater than open hours."]}),V.map((d,m)=>e.jsxs(j.Fragment,{children:[e.jsx("p",{children:d.label}),e.jsx(p.Item,{name:["hub_hours",m,"day"],noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(p.Item,{name:["hub_hours",m,"open_hour"],className:"w-full",children:e.jsx(T,{format:R,placeholder:"Select time",className:"w-full"})}),"-",e.jsx(p.Item,{name:["hub_hours",m,"close_hour"],className:"w-full",children:e.jsx(T,{format:R,placeholder:"Select time",className:"w-full"})})]})]},m))]}),e.jsxs("div",{className:"flex-grow md:flex-1",children:[e.jsx("p",{className:"mb-3",children:"Operational Break Hours"}),e.jsxs("p",{className:"mb-3 text-sm",children:[e.jsx("strong",{children:"Note:"})," End hours must be greater than start hours."]}),V.map((d,m)=>{const n=(t==null?void 0:t.hub_hours.findIndex(r=>r.day===d.label.toLowerCase()))||m;return e.jsxs(j.Fragment,{children:[e.jsx("p",{children:d.label}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(p.Item,{name:["hub_hours",Number(n),"hub_break_hour","start_hour"],className:"w-full",children:e.jsx(T,{format:R,className:"w-full",placeholder:"Select time"})}),"-",e.jsx(p.Item,{name:["hub_hours",Number(n),"hub_break_hour","end_hour"],className:"w-full",children:e.jsx(T,{format:R,className:"w-full",placeholder:"Select time"})})]})]},m)})]})]}),e.jsxs("div",{className:"flex justify-between gap-4",children:[(t==null?void 0:t.id)&&e.jsx(p.Item,{children:e.jsx(M,{type:"primary",danger:(h==null?void 0:h.status)==="active",onClick:()=>l(h==null?void 0:h.status,h.id),loading:b,disabled:b,children:(h==null?void 0:h.status)==="active"?"Deactivate":"Reactivate"})}),e.jsx(p.Item,{children:e.jsx(M,{type:"primary",htmlType:"submit",loading:b,disabled:b,children:h!=null&&h.id?"Update Hub":"Create Hub"})})]})]})},Pt=({hubData:t})=>{const{notification:s}=Q.useApp(),[o]=p.useForm(),[a,f]=j.useState(!1),I=W(),[k,h]=j.useState(((t==null?void 0:t.holiday_infos)||[]).map(i=>({...i,key:i.id})));j.useEffect(()=>{h(((t==null?void 0:t.holiday_infos)||[]).map(i=>({...i,key:i.id})))},[t]);const g=i=>f(i),c=k.map(i=>N(i.date)),x=i=>c.some(l=>l.isSame(i,"day")),v=[{title:"ID",dataIndex:"id",key:"id"},{title:"Date",dataIndex:"date",key:"date"},{title:"Note",dataIndex:"note",key:"note"},{title:"Action",dataIndex:"id",key:"action",render:i=>e.jsx(M,{danger:!0,type:"text",icon:e.jsx(G,{}),onClick:()=>t?_(Number(t.id),i):{}})}],A=async()=>{const i=await o.validateFields();i&&(i.date=N(i.date).format(Ge),u(i))},{mutate:u,isPending:b}=z({mutationFn:i=>i.delete_id?Ae(i):Ee(i),onSettled:(i,l,d)=>{var m,n,r,y,F,E;if(l){if(L(l)){let S=l==null?void 0:l.message;(n=(m=l==null?void 0:l.response)==null?void 0:m.data)!=null&&n.error&&(S=(F=(y=(r=l==null?void 0:l.response)==null?void 0:r.data)==null?void 0:y.details)==null?void 0:F.message),s.error({message:S})}}else{const S=i==null?void 0:i.hub_holiday_info;let C=[],H="Holiday hub has been added";S?(C=[...k,{...S,key:S.id}],o.resetFields()):(C=k.filter(w=>w.id!==d.delete_id),H=(E=i==null?void 0:i.data)==null?void 0:E.message),h(C),s.success({message:H}),g(!1),I.invalidateQueries({queryKey:["hub"]})}}}),_=(i,l)=>{u({id:i,delete_id:l})};return e.jsxs("section",{className:"container my-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("p",{className:"text-sm text-right",children:[k==null?void 0:k.length," results found"]}
1),e.jsx(M,{type:"primary",onClick:()=>g(!0),children:"Add Hub Holiday"}),e.jsx(J,{title:"Holiday Form",open:a,onOk:A,onCancel:()=>g(!1),okText:"Submit",okButtonProps:{loading:b},children:e.jsxs(p,{requiredMark:!1,form:o,name:"form-hub-holiday",initialValues:t,autoComplete:"off",layout:"vertical",children:[e.jsx(p.Item,{name:"id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{label:"Pick Holiday Dates",name:"date",children:e.jsx(_e,{className:"w-full",disabledDate:x})}),e.jsx(p.Item,{label:"Note",name:"note",children:e.jsx(O.TextArea,{placeholder:"Input holiday note"})})]})})]}),e.jsx(X,{loading:b,bordered:!0,columns:v,dataSource:k,pagination:!1})]})},Ft=({hubData:t,storageTypeData:s})=>{const{notification:o}=Q.useApp(),[a]=p.useForm(),[f,I]=j.useState(!1),k=W(),[h,g]=j.useState(((t==null?void 0:t.storages)||[]).map(i=>({...i,key:i.id})));j.useEffect(()=>{g(((t==null?void 0:t.storages)||[]).map(i=>({...i,key:i.id})))},[t]);const c=i=>I(i),x=[{title:"ID",dataIndex:"id",key:"id"},{title:"Type",dataIndex:["type","title"],key:"type"},{title:"Capacity",dataIndex:"capacity",key:"capacity"},{title:"Action",dataIndex:"id",key:"action",render:(i,l)=>e.jsxs(fe,{align:"center",children:[e.jsx(M,{type:"text",icon:e.jsx(ue,{}),onClick:()=>t?_(Number(t.id),l):{}}),e.jsx(M,{danger:!0,type:"text",icon:e.jsx(G,{}),onClick:()=>t?b(Number(t.id),i):{}})]})}],v=async()=>{const i=await a.validateFields();i&&A(i)},{mutate:A,isPending:u}=z({mutationFn:i=>i.type?He(i):i.delete_id?qe(i):Te(i),onSettled:(i,l,d)=>{var m,n,r,y,F,E;if(l){if(L(l)){let S=l==null?void 0:l.message;(n=(m=l==null?void 0:l.response)==null?void 0:m.data)!=null&&n.error&&(S=(F=(y=(r=l==null?void 0:l.response)==null?void 0:r.data)==null?void 0:y.details)==null?void 0:F.message),o.error({message:S})}}else{const S=i==null?void 0:i.storage;let C=[],H="Hub storage has been updated";S?(C=[...h,{...S,key:S.id}],a.resetFields()):(C=h.filter(w=>w.id!==d.delete_id),H=(E=i==null?void 0:i.data)==null?void 0:E.message),g(C),o.success({message:H}),c(!1),k.invalidateQueries({queryKey:["hub"]})}}}),b=(i,l)=>{A({hub_id:i,delete_id:l})},_=(i,l)=>{var d;c(!0),a.setFieldsValue({...l,id:i,storage_id:l.id,storage_type_id:(d=l.type)==null?void 0:d.id})};return e.jsxs("section",{className:"container my-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("p",{className:"text-sm text-right",children:[h==null?void 0:h.length," results found"]}),e.jsx(M,{type:"primary",onClick:()=>c(!0),children:"Add Hub Storage"}),e.jsx(J,{title:"Storage Form",open:f,onOk:v,onCancel:()=>c(!1),okText:"Submit",okButtonProps:{loading:u},children:e.jsxs(p,{requiredMark:!1,form:a,name:"form-hub-holiday",initialValues:t,autoComplete:"off",layout:"vertical",children:[e.jsx(p.Item,{name:"hub_id",noStyle:!0,hidden:!0,initialValue:t==null?void 0:t.id,children:e.jsx(O,{})}),e.jsx(p.Item,{name:"storage_id",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{name:"type",noStyle:!0,hidden:!0,children:e.jsx(O,{})}),e.jsx(p.Item,{name:"storage_type_id",label:"Hub Storage Type",rules:[{required:!0,message:"Please input storage type!"}],children:e.jsx($,{options:s==null?void 0:s.map(i=>({label:i.title,value:i.id,key:i.id})),placeholder:"Select storage type"})}),e.jsx(p.Item,{name:"capacity",label:"Capacity",className:"w-full",rules:[{required:!0,message:"Please input capacity!"}],children:e.jsx(Xe,{placeholder:"Input capacity",className:"w-full"})})]})})]}),e.jsx(X,{loading:u,bordered:!0,columns:x,dataSource:h,pagination:!1})]})},{Text:ce}=he,Rs=()=>{const{id:t}=je(),s=!!(t&&t!=="create"),[o,a]=De({default:"details"}),{data:f,isLoading:I,isError:k}=K({queryKey:["hub",t],queryFn:()=>s?Me(String(t)):{},select:({hub:u})=>{var b,_;return{...u,longitude:(b=u==null?void 0:u.address)==null?void 0:b.longitude,latitude:(_=u==null?void 0:u.address)==null?void 0:_.latitude,category_ids:u==null?void 0:u.categories.map(i=>i.id),contact:u!=null&&u.contact&&kt(u==null?void 0:u.contact)?ot(u==null?void 0:u.contact):u==null?void 0:u.contact,hub_hours:V.map(i=>{var d,m,n,r,y;const l=(d=u==null?void 0:u.hub_hours)==null?void 0:d.find(F=>F.day.toLowerCase()===i.label.toLowerCase());return{...l,day:i.label.toLowerCase(),open_hour:l!=null&&l.open_hour?N(l.open_hour,P):"",close_hour:l!=null&&l.open_hour?N(l.close_hour,P):"",hub_break_hour:l!=null&&l.hub_break_hour?{...l.hub_break_hour,start_hour:(m=l==null?void 0:l.hub_break_hour)!=null&&m.start_hour?N((n=l==null?void 0:l.hub_break_hour)==null?void 0:n.start_hour,P):"",end_hour:(r=l==null?void 0:l.hub_break_hour)!=null&&r.end_hour?N((y=l==null?void 0:l.hub_break_hour)==null?void 0:y.end_hour,P):""}:""}})}},retry:0}),{data:h}=K({queryKey:["category"],queryFn:()=>ve({sort_by:"asc"}),select:u=>{var b;return(b=u.categories)==null?void 0:b.map((_,i)=>({..._,key:i}))},retry:0}),{data:g}=K({queryKey:["hub-group"],queryFn:()=>Re({sort_by:"latest"}),select:u=>u.hub_groups,retry:0}),{data:c}=K({queryKey:["storage-type"],queryFn:Ke,select:u=>{var b;return(b=u.storage_types)==null?void 0:b.map((_,i)=>({..._,key:i}))},retry:0}),{data:x}=K({queryKey:["hub-delivery-hour"],queryFn:()=>s?Ve(t):{},select:u=>{var b;return(b=u.hub_delivery_hours)==null?void 0:b.map(_=>({..._,open_hour:_.open_hour?N(_.open_hour,P):"",close_hour:_.close_hour?N(_.close_hour,P):"",hub_delivery_break_hour:_.hub_delivery_break_hour?{..._.hub_delivery_break_hour,start_hour:_.hub_delivery_break_hour.start_hour?N(_.hub_delivery_break_hour.start_hour,P):"",end_hour:_.hub_delivery_break_hour.end_hour?N(_.hub_delivery_break_hour.end_hour,P):""}:null}))},retry:0}),v=[{key:"details",label:"Details",children:e.jsx(Ct,{hubData:f,categoryData:h,hubGroupData:g})},{key:"holiday",label:"Holiday",children:e.jsx(Pt,{hubData:f}),disabled:!s},{key:"coupon",label:"Coupon",children:e.jsx(It,{hubData:f}),disabled:!s},{key:"storages",label:"Storages",children:e.jsx(Ft,{hubData:f,storageTypeData:c}),disabled:!s},{key:"delivery_hours",label:"Delivery Hours",children:e.jsx(Nt,{hubData:f,deliveryData:x}),disabled:!s}],A=u=>{a(b=>({...b,default:u}))};return e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"container",children:e.jsx(rt,{style:{margin:"16px 0"},items:[{title:e.jsx(ne,{to:"/admin",children:"..."})},{title:e.jsx(ne,{to:"/admin/hub-list",children:"Hub List"})},{title:e.jsx(ce,{className:"capitalize",children:t})}]})}),I?e.jsx(Ze,{className:"flex items-center justify-center w-full h-1/2"}):k?e.jsx("section",{className:"container text-center",children:e.jsx(ce,{children:"No Found Hub Detail"})}):e.jsx("section",{className:"container mb-4",children:e.jsx(lt,{defaultActiveKey:o.default,items:v,onChange:A})})]})};export{Rs 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.