23 lines
4.5 KiB
JavaScript
23 lines
4.5 KiB
JavaScript
import{bq as $,bH as B,bI as q,bc as g,r as k,e as C,a7 as w,u as M,aB as l,aC as u,c as s,af as S,ae as _,aQ as z,aR as N,aS as I,H as x,bD as O,z as F,bP as R,fE as j,h as d,O as D,fF as V,p as m,fQ as G,br as J,j as f,bS as U,b$ as K,bT as W,bm as X}from"./bundle.8ee8d669.js";import{d as Y}from"./bundle.460af277.js";import{I as Z}from"./bundle.0d91e1f3.js";import{r as T,a as ee,P as se,b as ne}from"./bundle.ecfad986.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 te(){const e=$(),n=B(q);return async(i,t)=>(g.processing(),k("POST",C("/api/v1/designs/bulk"),{action:t,ids:i}).then(()=>{g.success(`${t}d_design`),w(["designs"]),n&&e.invalidateQueries([n])}))}function ie(){const[e]=M(),n=te();return[t=>l(t)===u.Active&&s(S,{onClick:()=>n([t.id],"archive"),icon:s(_,{element:z}),children:e("archive")}),t=>(l(t)===u.Archived||l(t)===u.Deleted)&&s(S,{onClick:()=>n([t.id],"restore"),icon:s(_,{element:N}),children:e("restore")}),t=>(l(t)===u.Active||l(t)===u.Archived)&&s(S,{onClick:()=>n([t.id],"delete"),icon:s(_,{element:I}),children:e("delete")})]}function ae(e){const n=T.useMediaQuery({query:"(min-width: 1024px)"}),{children:i}=e;return n?s(ee,{direction:"horizontal",className:"gap-4 mt-4",children:i}):s("div",{className:"flex flex-col gap-4",children:i})}function A(e){const n=T.useMediaQuery({query:"(min-width: 1024px)"}),{children:i,renderBasePanel:t}=e;return n||t?s(se,{defaultSize:50,minSize:25,children:i}):s(x,{children:i})}const oe=O(ne)`
|
|
background-color: ${e=>e.theme.backgroundColor};
|
|
&:hover {
|
|
background-color: ${e=>e.theme.hoverColor};
|
|
}
|
|
`;function re(){const e=T.useMediaQuery({query:"(min-width: 1024px)"}),n=F();return e?s(oe,{className:"flex items-center",theme:{hoverColor:"#3366CC",backgroundColor:n.$5},style:{width:"2.5px"}}):s(x,{})}/**
|
|
* 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 de(){const[e]=M(),{id:n}=R(),{isCompanySettingsActive:i}=j();return[{name:e("settings"),href:d("/settings/invoice_design/custom_designs/:id/edit",{id:n}),enabled:i},{name:e("body"),href:d("/settings/invoice_design/custom_designs/:id/edit/body",{id:n}),enabled:i},{name:e("header"),href:d("/settings/invoice_design/custom_designs/:id/edit/header",{id:n}),enabled:i},{name:e("footer"),href:d("/settings/invoice_design/custom_designs/:id/edit/footer",{id:n}),enabled:i},{name:e("includes"),href:d("/settings/invoice_design/custom_designs/:id/edit/includes",{id:n}),enabled:i},{name:e("variables"),href:d("/settings/invoice_design/custom_designs/:id/edit/variables",{id:n}),enabled:i}]}const ge=X({design:null,entity_id:"-1",entity:"invoice"});function he(){D("invoice_design");const e=ie(),n=de(),i=V(),{id:t}=R(),{data:v}=Y({id:t,enabled:!0}),[a,b]=m.useState({design:null,entity_id:"-1",entity:"invoice"}),[r,p]=m.useState(),[h,P]=m.useState(!1),[y,E]=m.useState(!1),H=()=>{h||(g.processing(),P(!0),k("PUT",C("/api/v1/designs/:id",{id:t}),a.design).then(()=>{w(["designs"]),g.success("updated_design")}).catch(o=>{var c;((c=o.response)==null?void 0:c.status)===422&&(p(o.response.data),g.dismiss())}).finally(()=>P(!1)))};return G({element:(a==null?void 0:a.design)&&s(J,{resource:a.design,onSaveClick:H,actions:e,disableSaveButton:h})},[a.design,h,i]),m.useEffect(()=>(v&&b(o=>({...o,design:v})),()=>b({design:null,entity_id:"-1",entity:"invoice"})),[v]),f(x,{children:[s(U,{tabs:n}),f(ae,{children:[s(A,{children:f("div",{className:"space-y-4 h-full max-h-[80vh] overflow-y-auto",children:[r!=null&&r.errors["design.design.body"]?f(K,{type:"danger",children:[s("p",{children:r.message}),s("small",{children:r.errors["design.design.body"]})]}):null,s(W,{context:{errors:r,isFormBusy:h,shouldRenderHTML:y,setShouldRenderHTML:E,payload:a,setPayload:b}})]})}),s(re,{}),s(A,{children:s("div",{className:"max-h-[80vh] overflow-y-scroll",children:a.design?s(Z,{link:C("/api/v1/preview?html=:renderHTML",{renderHTML:y}),resource:a,method:"POST",withToast:!0,renderAsHTML:y,onError:o=>{var c;if(((c=o.response)==null?void 0:c.status)===422&&o.response.data){const L=new TextDecoder("utf-8").decode(o.response.data),Q=JSON.parse(L);p(Q)}},onRequest:()=>p(void 0)}):null})})]})]})}export{he as default,ge as payloadAtom};
|