PageSourceSearch

https://www.elevolt.co.ke/_next/static/chunks/7049-dd5d560e86cb59dd.js

js elevolt.co.ke collected 2026-10-04 21:46:11 UTC 7,620 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]="e29ab4da-ec61-4c8a-a7be-7771f685851e",e._sentryDebugIdIdentifier="sentry-dbid-e29ab4da-ec61-4c8a-a7be-7771f685851e")}()}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7049],{87049:function(e,s,r){r.d(s,{J:function(){return _}});var t=r(52322),l=r(42369),n=r(1973),a=r(65232),i=r(17047),d=r(93679),o=r(23825),c=r(19317),m=r(59417),u=r(99603),x=r(36160),j=r.n(x),h=r(2784),v=r(62202),y=r(47023),g=r(63798),f=r(95254),p=r(97203),b=r(88393),N=r(13980),w=r.n(N),C=r(63955);let I=e=>{let{onSubmit:s,initialData:r}=e,{handleSubmit:l,formState:{errors:n,isSubmitting:a,isValid:i},control:d}=(0,C.cI)({mode:"onChange",defaultValues:{type:(null==r?void 0:r.type)||"primary",name:(null==r?void 0:r.name)||"",email:(null==r?void 0:r.email)||"",phone:(null==r?void 0:r.phone)||"",address:(null==r?void 0:r.address)||"",city:(null==r?void 0:r.city)||"",state:(null==r?void 0:r.state)||"",country:(null==r?void 0:r.country)||""}});return(0,t.jsxs)("form",{className:"w-full max-w-xl",onSubmit:l(e=>{if(!e.phone&&!e.email&&!e.address){v.toast.error("At least one contact method is required.");return}s(e)}),children:[(0,t.jsxs)("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsx)("div",{className:"col-span-2",children:(0,t.jsx)(C.Qr,{control:d,name:"type",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(g.P,{error:null===(s=n.type)||void 0===s?void 0:s.message,label:"Contact Type",options:["primary","secondary","emergency"],...r})},rules:{required:"Type is required"}})}),(0,t.jsx)("div",{className:"col-span-2",children:(0,t.jsx)(C.Qr,{control:d,name:"name",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.name)||void 0===s?void 0:s.message,label:"Contact Name",...r})},rules:{required:"Contact Name is required"}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"email",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.email)||void 0===s?void 0:s.message,label:"Email",type:"email",...r})},rules:{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"phone",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.phone)||void 0===s?void 0:s.message,label:"Phone",type:"tel",...r})},rules:{pattern:{value:/^\d{6,}$/,message:"Invalid phone number"}}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"address",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.address)||void 0===s?void 0:s.message,label:"Address",...r})}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"city",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.city)||void 0===s?void 0:s.message,label:"City",...r})}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"state",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.state)||void 0===s?void 0:s.message,label:"State",...r})}})}),(0,t.jsx)("div",{children:(0,t.jsx)(C.Qr,{control:d,name:"country",render:e=>{var s;let{field:r}=e;return(0,t.jsx)(f.o,{error:null===(s=n.country)||void 0===s?void 0:s.message,label:"Country",...r})}})})]}),(0,t.jsx)("div",{className:"w-full mt-3 flex justify-end",children:(0,t.jsx)(y.Z,{design:"primary",disabled:a||!i,type:"submit",children:"Save"})})]})};I.propTypes={onSubmit:w().func.isRequired,initialData:w().shape({type:w().string,name:w().string,email:w().string,phone:w().string,address:w().string,city:w().string,state:w().string,country:w().string})};let A=e=>{let{userId:s,onClose:r=()=>{}}=e,[l,n]=(0,h.useState)(!1),a=(0,d.Yq)(),i=async e=>{try{await a.mutateAsync({userId:s,data:e}),v.toast.success("Contact created successfully!"),r(),n(!1)}catch(e){var t,l;(0,b.Kd)(e,"ContactForm",{}),v.toast.error((null==e?void 0:null===(l=e.response)||void 0===l?void 0:null===(t=l.data)||void 0===t?void 0:t.message)||"An error occurred while creating contact.")}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.B,{fullWidth:!0,isLoading:a.isPending,maxWidth:"600px",onClose:()=>{n(!1),r()},show:l,title:"Create New Contact",children:(0,t.jsx)(I,{initialData:{},onSubmit:i})}),(0,t.jsx)(y.Z,{beforeIcon:(0,t.jsx)(u.G,{className:" mr-1",icon:m.r8p,size:"1x"}),design:"secondary",onClick:()=>n(!0),children:"Add Contact"})]})},_=e=>{let{user:s}=e,{data:r,isLoading:x,isFetching:h,isError:y,refetch:g}=(0,d.Ln)({userId:null==s?void 0:s.uid}),f=(0,d.Jx)(),p=e=>{let r=async()=>{try{await f.mutateAsync({userId:null==s?void 0:s.uid,contactId:e.id}),await g(),v.default.success("Contact deleted successfully!")}catch(e){v.default.error("An error occurred while deleting the contact.")}};(0,i.Z)({handler:r,isLoading:f.isPending})};return(0,t.jsxs)(a.ZP,{children:[(0,t.jsx)(a.Ol,{children:(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Contacts"}),!j()(r)&&(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(A,{onClose:async()=>{await g()},userId:null==s?void 0:s.uid})})]})}),(0,t.jsxs)(a.eW,{padding:0,children:[!!f.isPending&&(0,t.jsx)(l.J,{fixed:!1}),!!(null==r?void 0:r.length)&&(0,t.jsx)(o.Z,{isFetching:h,children:r.map(e=>(0,t.jsxs)("div",{className:"flex py-4 px-4 group relative border-b",children:[(0,t.jsxs)("div",{className:"w-full flex justify-start flex-grow flex-col md:flex-row",children:[(0,t.jsxs)("div",{className:"w-full md:w-1/4",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-500 leading-none mb-1",children:"Type"}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700",children:e.type})]}),(0,t.jsxs)("div",{className:"w-full md:w-1/4",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-500 leading-none mb-1",children:"Name"}),(0,t.jsx)("p",{className:"text-sm font-medium text-gray-700",children:e.name})]}),(0,t.jsxs)("div",{className:"w-full md:w-1/4",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-500 leading-none mb-1",children:"Contact"}),!!e.email&&(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-700",children:[(0,t.jsx)(u.G,{className:"mr-2 text-blue-dark",icon:m.mSY,size:"1x"}),e.email]}),!!e.phone&&(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-700",children:[(0,t.jsx)(u.G,{className:"mr-2 text-blue-dark",icon:m.j1w,size:"1x"}),e.phone]}
1)]}),(0,t.jsxs)("div",{className:"w-full md:w-1/4",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-gray-500 leading-none mb-1",children:"Address"}),!!(e.address||e.city||e.state||e.country)&&(0,t.jsxs)("p",{className:"text-sm font-medium text-gray-700",children:[(0,t.jsx)(u.G,{className:"mr-2 text-blue-dark",icon:m.FGq,size:"1x"}),[e.address,e.city,e.state,e.country,e.postal_code].filter(Boolean).join(", ")]})]})]}),(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(c.C,{menuIcon:(0,t.jsx)(u.G,{className:"text-lg text-500 hover:text-gray-700",icon:m.iV1,size:"1x"}),menuItems:[{text:"Delete",icon:(0,t.jsx)(u.G,{className:"mr-1",icon:m.$aW}),action:e=>p(e)}],subject:e})})]},e.id))}),!(null==r?void 0:r.length)&&(0,t.jsx)("div",{className:"w-full flex flex-col bg-white p-4 rounded",children:(0,t.jsx)("div",{className:"w-full bg-blue-50 p-4 rounded border border-dashed",children:(0,t.jsx)(n.Z,{action:(0,t.jsx)(A,{userId:null==s?void 0:s.uid}),isError:y,isLoading:x,items:"contacts"})})})]})]})}}}]);

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.