whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> /home/qbizpnmr/arif.umairtax.com/public/Locations-BEKOnmxb.js
import{b as D,r as S,e as B,u as z,t as A,p as u,be as T,j as s,ad as q,cx as _,dY as Q,cz as V,bC as R,ae as W,bf as h,$ as M,bS as G,a as H,d6 as U,aW as X,aX as Y,cq as Z,_ as J,a0 as K,C as I,cb as L,b2 as P,dZ as ee,d_ as se,bm as le,H as E}from"./bundle.OlIVtvc7.js";/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function ae(){return D("/api/v1/locations/create",()=>S("GET",B("/api/v1/locations/create")).then(o=>o.data.data),{staleTime:1/0})}function oe({isModalOpen:o,setIsModalOpen:F,blankLocation:t,clientId:v,currentEditingLocation:m,setCurrentEditingLocation:f}){var k,C,g,N;const[n]=z(),a=A(),[b,j]=u.useState(!1),[d,c]=u.useState(),[l,y]=u.useState(t),p=()=>{F(!1),m&&f(null)},w=()=>{b||(h.processing(),c(void 0),j(!0),S("POST",B("/api/v1/locations"),{...l,client_id:v}).then(()=>{h.success("created_location"),M(["clients"]),p()}).catch(e=>{var r;((r=e.response)==null?void 0:r.status)===422&&(c(e.response.data),h.dismiss())}).finally(()=>j(!1)))},$=()=>{b||(h.processing(),c(void 0),j(!0),S("PUT",B("/api/v1/locations/:id",{id:m==null?void 0:m.id}),l).then(()=>{h.success("updated_location"),M(["clients"]),f(null)}).catch(e=>{var r;((r=e.response)==null?void 0:r.status)===422&&(c(e.response.data),h.dismiss())}).finally(()=>j(!1)))},i=(e,r)=>{if(!l)return;const x=T.cloneDeep(l);T.set(x,r,e),y(x)};return u.useEffect(()=>{var e;y(m||T.cloneDeep({...t,country_id:((e=a==null?void 0:a.settings)==null?void 0:e.country_id)||""}))},[o]),s.jsx(q,{title:n(m?"edit_location":"add_location"),visible:o,onClose:p,overflowVisible:!0,size:"regular",children:s.jsxs("div",{className:"flex flex-col space-y-4",children:[s.jsx(_,{label:n("name"),value:(l==null?void 0:l.name)||"",onValueChange:e=>i(e,"name"),errorMessage:d==null?void 0:d.errors.name}),s.jsx(_,{label:n("address1"),value:(l==null?void 0:l.address1)||"",onValueChange:e=>i(e,"address1"),errorMessage:d==null?void 0:d.errors.address1}),s.jsx(_,{label:n("address2"),value:(l==null?void 0:l.address2)||"",onValueChange:e=>i(e,"address2"),errorMessage:d==null?void 0:d.errors.address2}),s.jsx(_,{label:n("city"),value:(l==null?void 0:l.city)||"",onValueChange:e=>i(e,"city"),errorMessage:d==null?void 0:d.errors.city}),s.jsx(_,{label:n("state"),value:(l==null?void 0:l.state)||"",onValueChange:e=>i(e,"state"),errorMessage:d==null?void 0:d.errors.state}),s.jsx(_,{label:n("postal_code"),value:(l==null?void 0:l.postal_code)||"",onValueChange:e=>i(e,"postal_code"),errorMessage:d==null?void 0:d.errors.postal_code}),s.jsx(Q,{label:n("country"),value:(l==null?void 0:l.country_id)||"",onChange:e=>i(e,"country_id"),errorMessage:d==null?void 0:d.errors.country_id}),((k=a==null?void 0:a.custom_fields)==null?void 0:k.location1)&&s.jsx(V,{field:"location1",defaultValue:l==null?void 0:l.custom_value1,value:a.custom_fields.location1,onValueChange:e=>i(e,"custom_value1"),noExternalPadding:!0,labelOnTop:!0}),((C=a==null?void 0:a.custom_fields)==null?void 0:C.location2)&&s.jsx(V,{field:"location2",defaultValue:l==null?void 0:l.custom_value2,value:a.custom_fields.location2,onValueChange:e=>i(e,"custom_value2"),noExternalPadding:!0,labelOnTop:!0}),((g=a==null?void 0:a.custom_fields)==null?void 0:g.location3)&&s.jsx(V,{field:"location3",defaultValue:l==null?void 0:l.custom_value3,value:a.custom_fields.location3,onValueChange:e=>i(e,"custom_value3"),noExternalPadding:!0,labelOnTop:!0}),((N=a==null?void 0:a.custom_fields)==null?void 0:N.location4)&&s.jsx(V,{field:"location4",defaultValue:l==null?void 0:l.custom_value4,value:a.custom_fields.location4,onValueChange:e=>i(e,"custom_value4"),noExternalPadding:!0,labelOnTop:!0}),s.jsx("div",{className:"pt-1",children:s.jsx(R,{label:n("shipping_address"),checked:!!(l!=null&&l.is_shipping_location),onValueChange:e=>i(e,"is_shipping_location")})}),s.jsx("div",{className:"w-full pt-4",children:s.jsx(W,{className:"w-full",type:"primary",behavior:"button",onClick:m?$:w,disabled:b,disableWithoutIcon:!0,children:n("save")})})]})})}const O=E.div` background-color: ${o=>o.theme.backgroundColor}; &:hover { background-color: ${o=>o.theme.hoverBackgroundColor}; } `,te=E.div` border-color: ${o=>o.theme.borderColor}; `,de=E.div` background-color: ${o=>o.theme.backgroundColor}; &:hover { background-color: ${o=>o.theme.hoverBackgroundColor}; } `;function ne(){const[o]=z(),{id:F}=G(),t=H(),v=U(),m=X(),f=Y(),n=Z(),{client:a,setErrors:b}=n,{data:j}=ae(),d=J(K),[c,l]=u.useState(!1),[y,p]=u.useState(!1),[w,$]=u.useState(""),[i,k]=u.useState([]),[C,g]=u.useState(null),N=e=>{!c&&e&&(h.processing(),b(void 0),l(!0),S("DELETE",B("/api/v1/locations/:id",{id:e})).then(()=>{h.success("deleted_location"),M(["clients"])}).catch(r=>{var x;((x=r.response)==null?void 0:x.status)===422&&(b(r.response.data),h.dismiss())}).finally(()=>{l(!1),$(""),d(!1)}))};return u.useEffect(()=>{k((a==null?void 0:a.locations)||[])},[a==null?void 0:a.locations]),u.useEffect(()=>{p(!!C)},[C]),F?s.jsxs(s.Fragment,{children:[s.jsx(I,{title:o("locations"),className:"shadow-sm",style:{borderColor:t.$24},headerStyle:{borderColor:t.$20},children:s.jsx("div",{className:"px-4 sm:px-6 py-2",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[s.jsxs(de,{className:"flex flex-col space-y-2 items-center justify-center border-dashed border p-6 rounded-md cursor-pointer min-h-48",theme:{backgroundColor:t.$1,hoverBackgroundColor:t.$20,borderColor:t.$24},onClick:()=>p(!0),children:[s.jsx(L,{size:"2rem",color:t.$3}),s.jsx("span",{children:o("add_location")})]}),i.map((e,r)=>{var x;return s.jsxs(te,{theme:{borderColor:t.$24},className:"px-3 py-4 flex justify-between space-x-4 border rounded-md min-h-48",children:[s.jsxs("div",{className:"flex flex-col flex-1 truncate justify-between",children:[s.jsx("span",{className:"text-lg font-semibold truncate mb-2 mt-1",children:e.name}),s.jsxs("div",{className:"flex flex-col space-y-1 text-sm",children:[s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[o("address"),":"," "]}),e.address1,e.address1&&e.address2&&`, ${e.address2}`]}),s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[o("city"),": "]}),e.city||"",e.state&&`${e.city?", ":""}${e.state}`,e.postal_code&&`${e.state?" ":""}${e.postal_code}`]}),s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[o("country"),":"," "]}),(x=m(e.country_id))==null?void 0:x.name]}),s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[o("shipping"),":"," "]}),e.is_shipping_location?o("yes"):o("no")]}),e.custom_value1&&s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[v("location1").label(),":"," "]}),f("location1",e.custom_value1)]}),e.custom_value2&&s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[v("location2").label(),":"," "]}),f("location2",e.custom_value2)]}),e.custom_value3&&s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[v("location3").label(),":"," "]}),f("location3",e.custom_value3)]}),e.custom_value4&&s.jsxs("div",{children:[s.jsxs("span",{style:{color:t.$16},children:[v("location4").label(),":"," "]}),f("location4",e.custom_value4)]})]})]}),s.jsxs("div",{className:"flex flex-col justify-between",children:[s.jsx(O,{className:P("flex items-center justify-center w-8 h-8 rounded-lg border",{"cursor-not-allowed opacity-75":c,"cursor-pointer":!c}),style:{borderColor:t.$24},theme:{hoverBackgroundColor:t.$20,backgroundColor:t.$1},onClick:()=>!c&&g(e),children:s.jsx(ee,{size:"1rem",color:"#2176FF"})}),s.jsx(O,{className:P("flex items-center justify-center w-8 h-8 rounded-lg border",{"cursor-not-allowed opacity-75":c,"cursor-pointer":!c}),style:{borderColor:t.$24},theme:{hoverBackgroundColor:t.$20,backgroundColor:t.$1},onClick:()=>{$(e.id),setTimeout(()=>{d(!0)},100)},children:s.jsx(se,{size:"1rem",color:"red"})})]})]},r)})]})})}),s.jsx(le,{onClick:()=>N(w),disabledButton:c,title:o("delete_location"),message:o("delete_location_confirmation")}),s.jsx(oe,{isModalOpen:y,setIsModalOpen:p,blankLocation:j,clientId:a==null?void 0:a.id,currentEditingLocation:C,setCurrentEditingLocation:g})]}):s.jsx(I,{title:o("locations"),className:"shadow-sm",style:{borderColor:t.$24},headerStyle:{borderColor:t.$20},children:s.jsxs("div",{className:"px-6 text-sm",children:[o("save_to_add_locations"),"."]})})}export{ne as default};
Copyright ©2021 || Defacer Indonesia