PageSourceSearch

https://www.elevolt.co.ke/_next/static/chunks/pages/hr/[tenant]/e-…/templates/[id]-97fdd3072435cd78.js

js elevolt.co.ke collected 2026-10-04 21:47:19 UTC 9,472 bytes, 1 lines download raw bytes

1try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},s=(new e.Error).stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="05c09dd3-b1d2-48d0-884f-67b4a98b866e",e._sentryDebugIdIdentifier="sentry-dbid-05c09dd3-b1d2-48d0-884f-67b4a98b866e")}()}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8768,1490],{98657:function(e,s,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/hr/[tenant]/e-signatures/templates/[id]",function(){return a(30322)}])},30322:function(e,s,a){"use strict";a.r(s);var t=a(52322),l=a(16049),n=a(1973),i=a(47023),d=a(65232),r=a(95254),c=a(62372),o=a(77590),m=a(22319),x=a(82781),g=a(3508),p=a(84475),u=a(59417),h=a(99603),j=a(5632),f=a(13980),y=a.n(f),b=a(2784),N=a(62202),v=a(67780),k=a(6239),w=a(79337);let C=e=>{let{user:s,tenantName:a,templateId:p}=e,f=(0,j.useRouter)(),[y,C]=(0,b.useState)(!1),[_,T]=(0,b.useState)({}),[Z,I]=(0,b.useState)(!1),{data:E,isLoading:P,error:F}=(0,m.Au)({templateId:p,enabled:!!p}),{data:L}=(0,m.J5)({templateId:p,enabled:!!p&&y}),{data:S=[],isLoading:D}=(0,m.tk)(),G=(0,m.mB)({onSuccess:()=>{N.default.success("Template updated successfully"),I(!1)},onError:e=>{var s,a;N.default.error((null===(a=e.response)||void 0===a?void 0:null===(s=a.data)||void 0===s?void 0:s.message)||"Failed to update template")}});(0,b.useMemo)(()=>{E&&0===Object.keys(_).length&&T({name:E.name||"",description:E.description||"",category:E.category||""})},[E,_]);let O=(null==E?void 0:E.signature_fields)||[],W=(0,x.HP)(O),z=(0,b.useCallback)((e,s)=>{T(a=>({...a,[e]:s})),I(!0)},[]),q=(0,b.useCallback)(()=>{G.mutate({templateId:p,data:_})},[p,_,G]),A=(0,b.useCallback)(()=>{f.push("/hr/".concat(a,"/e-signatures/templates"))},[f,a]),R=(0,b.useMemo)(()=>[...S.map(e=>({value:e.slug||e.id||e,label:e.name||e}))],[S]),M=(0,b.useCallback)(e=>{T({..._,category:(null==e?void 0:e.value)||""}),I(!0)},[_]),X=(0,b.useCallback)(e=>{T({..._,category:e}),I(!0)},[_]),B=(null==E?void 0:E.status)==="active",H=O.some(e=>"signature"===e.field_type),J=_.category?R.find(e=>e.value===_.category)||{value:_.category,label:_.category}:null,K=[{href:"/hr/".concat(a,"/e-signatures"),name:"E-Signatures",nodeType:"Link"},{href:"/hr/".concat(a,"/e-signatures/templates"),name:"Templates",nodeType:"Link"},{href:"/hr/".concat(a,"/e-signatures/templates/").concat(p),name:(null==E?void 0:E.name)||"Edit Template",nodeType:"Link"}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.Z,{title:"".concat((0,o.kC)((0,o.parseUnderScore)(a))," - Edit Template")}),(0,t.jsxs)("main",{"aria-label":"Edit Signature Template",className:"container flex flex-col gap-4 mx-auto px-4 md:px-8 lg:px-12 pb-6",role:"main",children:[(0,t.jsx)("div",{children:(0,t.jsx)(l.Z,{home:"/hr/".concat(a,"/"),links:K})}),!!P&&(0,t.jsx)(d.ZP,{children:(0,t.jsx)(d.eW,{children:(0,t.jsx)(n.Z,{design:"wrapped",isLoading:!0,message:"Loading template..."})})}),!!(!P&&F)&&(0,t.jsx)(d.ZP,{children:(0,t.jsx)(d.eW,{children:(0,t.jsx)(n.Z,{description:"The template could not be found or you don't have permission to access it.",design:"wrapped",message:"Failed to load template"})})}),!!(!P&&!F&&E)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold",children:E.name}),(0,t.jsx)("p",{className:"text-gray-500 mt-1",children:"Edit template details and signature fields"})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)("span",{className:"px-2 py-1 rounded-full text-sm font-medium ".concat(B?"bg-green-100 text-green-800":"bg-gray-100 text-gray-600"),children:B?"Active":"Draft"})})]}),!H&&(0,t.jsx)("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(h.G,{className:"text-amber-500",icon:u.eHv}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-amber-900",children:"Template requires signature field"}),(0,t.jsx)("p",{className:"text-sm text-amber-700",children:"Add at least one signature field to activate this template."})]})]})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,t.jsxs)("div",{className:"lg:col-span-2 space-y-6",children:[(0,t.jsxs)(d.ZP,{children:[(0,t.jsx)(d.Ol,{heading:"Template Details"}),(0,t.jsx)(d.eW,{children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",htmlFor:"name",children:"Template Name"}),(0,t.jsx)(r.o,{id:"name",name:"name",onChange:e=>z("name",e.target.value),value:_.name||""})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",htmlFor:"description",children:"Description"}),(0,t.jsx)(c.K,{id:"description",name:"description",onChange:e=>z("description",e.target.value),rows:3,value:_.description||""})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",htmlFor:"template-category",children:"Category"}),(0,t.jsx)(v.Z,{className:"c-react-select",classNamePrefix:"crs",formatCreateLabel:e=>'Create "'.concat(e,'"'),inputId:"template-category",isClearable:!0,isLoading:D,name:"category",onChange:M,onCreateOption:X,options:R,placeholder:"Select or create a category...",value:J}),(0,t.jsx)("p",{className:"text-gray-500 text-xs mt-1",children:"Categorize your template for easier organization. Type to create a new category."})]})]})})]}),(0,t.jsxs)(d.ZP,{children:[(0,t.jsx)(d.Ol,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-xl font-semibold",children:"Signature Fields"}),(0,t.jsx)(i.Z,{beforeIcon:(0,t.jsx)(h.G,{className:"mr-2",icon:y?u.f8k:u.Xcf}),design:y?"primary":"secondary",onClick:()=>C(!y),size:"sm",children:y?"Done Editing":"Edit Fields"})]})}),(0,t.jsxs)(d.eW,{children:[!!(y&&L)&&(0,t.jsx)(g.Gq,{initialData:{templateId:p,signatureFields:O,signerRoles:W,pdfInfo:L},children:(0,t.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,t.jsx)(k.Z,{pageInfo:L,templateId:p})})}),!!(y&&!L)&&(0,t.jsx)(n.Z,{design:"wrapped",isLoading:!0,message:"Loading document..."}),!y&&(0,t.jsx)(t.Fragment,{children:0===O.length?(0,t.jsx)(n.Z,{action:(0,t.jsx)(i.Z,{design:"primary",onClick:()=>C(!0),size:"sm",children:"Add Fields"}),description:"Click 'Edit Fields' to add signature fields to your template.",design:"wrapped",message:"No fields added"}):(0,t.jsx)("div",{className:"space-y-3",children:W.map(e=>{let s=O.filter(s=>s.signer_role===e),a=(0,x.h6)(W,e);return(0,t.jsxs)("div",{className:"border rounded-lg p-3",style:{borderLeftWidth:4,borderLeftColor:a},children:[(0,t.jsx)("h4",{className:"font-medium capitalize mb-2",children:e}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{let s=(0,x.Ql)(e.field_type);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-gray-100 text-gray-700 text-sm rounded",children:[!!(null==s?void 0:s.icon)&&(0,t.jsx)(h.G,{className:"text-xs",icon:s.icon,style:{color:s.color}}),e.field_label,!!e.required&&(0,t.jsx)("span",{className:"text-red-500",children:"*"})]},e.id||e.field_label)})})]},e)})})})]})]})]}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(d.ZP,{children:[(0,t.jsx)(d.Ol,{heading:"Template Info"}),(0,t.jsx)(d.eW,{children:(0,t.jsxs)("dl",{className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.G,{className:"text-gray-400",icon:u.cwv}),(0,t.jsx)("dt",{className:"text-gray-500",children:"Pages:"}),(0,t.jsx)("dd",{className:"font-medium",children:(null==L?void 0:L.page_count)||(null==E?void 0:E.page_count)||"—"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.G,{className:"text-gray-400",icon:u.IwR}),(0,t.jsx)("dt",{className:"text-gray-500",children:"Fields:"}),(0,t.jsx)("dd",{className:"font-medium",children:O.length})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(h.G,{className:"text-gray-400 mt-0.5",icon:u.IwR}),(0,t.jsx)("dt",{className:"text-gray-500",children:"Roles:"}),(0,t.jsx)("dd",{children:0===W.length?(0,t.jsx)("span",{className:"text-gray-400",children:"None"}):(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:W.map(e=>(0,t.jsx)("span",{className:"px-1.5 py-0.5 text-xs rounded capitalize",style:{backgroundColor:"".concat((0,x.h6)(W,e),"20"),color:(0,x.h6)(W,e)},children:e},e))})})]})]})})]}),(0,t.jsx)(d.ZP,{children:(0,t.jsx)(d.eW,{children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(i.Z,{beforeIcon:G.isPending?(0,t.jsx)(h.G,{className:"mr-2 animate-spin",icon:u.LM3}):null,className:"w-full",design:"primary",disabled:!Z||G.isPending,onClick:q,children:G.isPending?"Saving...":"Save Changes"}),(0,t.jsx)(i.Z,{className:"w-full",design:"secondary",onClick:A,children:"Back to Templates"})]})})})]})]})]})]})]})};C.getInitialProps=async e=>{let s=e.query.tenant,a=e.query.id;return!s&&e.res?{notFound:!0}:{tenantName:s,templateId:a}},C.propTypes={user:y().object,tenantName:y().string,templateId:y().string},s.default=(0,p.withAuthSync)(C)}},function(e){e.O(0,[4976,2362,5351,9603,9436,9400,4933,2642,9788,7214,2888,9774,179],function(){return e(e.s=98657)}),_N_E=e.O()}]);

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.