PageSourceSearch

https://treesthatcount.co.nz/_next/static/chunks/pages/projects/[p…/monitorings-696b4da272153661.js

js treesthatcount.co.nz collected 2026-10-02 10:16:52 UTC 11,891 bytes, 2 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9634],{81474:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/projects/[projectId]/applications/[applicationId]/planting-report/[plantingId]/monitorings",function(){return n(33529)}])},71234:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var i=n(85893);const o=e=>{let{className:t="",children:n,size:o="large",corner:a="rounded"}=e;return(0,i.jsx)("div",{className:"bg-white text-ivoryBlack transition-shadow duration-300 ease-in-out overflow-hidden mb-1 ".concat((()=>{switch(a){case"square":default:return"";case"rounded":return"rounded-[10px] "}})()," ").concat((()=>{switch(o){case"small":return"p-4";case"medium":return"p-7";case"large":return"p-5 md:p-10";default:return""}})()," ").concat(t),children:n})}},33441:function(e,t,n){"use strict";n.d(t,{F:function(){return r}});var i=n(85893),o=n(20373),a=n(7515);const r=()=>(0,i.jsx)(a.T3,{title:"Redirecting...",children:(0,i.jsx)(o.Z,{cssOverride:{display:"block"},className:"m-auto"})})},58750:function(e,t,n){"use strict";n.d(t,{m:function(){return d}});var i=n(85893),o=n(29171),a=(n(39713),n(49336)),r=n(67294),l=n(50788),s=n(82999),c=n(44156);const d=e=>{let{ButtonComponent:t=s.B,actions:n,buttonComponentProps:d,children:u,className:p="",dropdownTrigger:f="click",linkProps:v,hideChevron:m=!1}=e;const[h,x]=(0,r.useState)(!1);return(0,i.jsx)(o.Z,{animation:"slide-up",onVisibleChange:()=>x(!h),placement:"bottomRight",trigger:f,visible:h,overlay:(0,i.jsx)(a.ZP,{children:n.map(((e,t)=>{return o=t,(n=e).isSeperator?(0,i.jsx)(a.ZP.Divider,{},"divider-".concat(o)):n.href?(0,i.jsx)(a.ck,{disabled:n.disabled,className:"".concat(n.disabled?"":"hover:bg-limeBright/20!"," ").concat(n.style||""),children:n.disabled?(0,i.jsxs)("span",{className:"text-cloudGrey font-medium cursor-default",children:[n.text,n.icon]}):(0,i.jsxs)(c.h$,{color:"none",className:"flex flex-row justify-between items-center w-full text-forestDeep",href:n.href,...v,children:[n.avatar?(0,i.jsx)("span",{className:"mr-2 h-6",children:n.avatar}):null,n.text,n.icon]})},n.text):(0,i.jsx)(a.ck,{className:"".concat(n.disabled?"":"hover:bg-limeBright/20!"," ").concat(n.style||""),disabled:n.disabled,children:n.disabled?(0,i.jsxs)("span",{className:"text-cloudGrey font-medium cursor-default",children:[n.text,n.icon]}):(0,i.jsxs)(c.Hp,{color:"forestDeep",className:"flex flex-row justify-between items-center w-full",onClick:n.onClick,...v,children:[n.avatar?(0,i.jsx)("span",{className:"mr-2 h-6",children:n.avatar}):null,n.text,n.icon]})},n.text);var n,o}))}),children:(0,i.jsx)("div",{className:p,children:(0,i.jsx)(t,{...d,children:(0,i.jsxs)("div",{className:"flex items-center",children:[u,!m&&(0,i.jsx)("span",{className:"ml-1 mr[-4px]",children:h?(0,i.jsx)(l.rWj,{size:"20px"}):(0,i.jsx)(l.Ix0,{size:"20px"})})]})})})})}},11872:function(e,t,n){"use strict";n.d(t,{m:function(){return r}});var i=n(85893),o=n(67294);const a=e=>{let{isActive:t,label:n,onClick:a,value:r,disabled:l}=e;const{scrollIntoView:s,ref:c}=function(){const[e,t]=(0,o.useState)(!1),[n,i]=(0,o.useState)(null),[a,r]=(0,o.useState)(!1),l=(0,o.useCallback)((e=>{null!==e&&i(e)}),[]);(0,o.useEffect)((()=>{if(n&&!e){const e=new IntersectionObserver((e=>{let[n]=e;t((null===n||void 0===n?void 0:n.isIntersecting)||!1),r(!0)}));return e.observe(n),()=>{e.disconnect()}}}),[e,n]);const s=(0,o.useCallback)((()=>{if(!e&&n&&a){const e=n.closest(".no-scrollbar");
1if(e){const t=e.getBoundingClientRect(),i=n.getBoundingClientRect(),o=i.left+i.width/2-(t.left+t.width/2);e.scrollBy({left:o,behavior:"smooth"})}}}),[e,n,a]);return{isInViewport:e,scrollIntoView:s,ref:l}}();return(0,o.useEffect)((()=>{t&&s()}),[t,s]),(0,i.jsx)("button",{ref:c,disabled:l,className:"text-base font-bold inline-flex items-center justify-center box-border bg-transparent outline-current outline-none outline-0 m-0 cursor-pointer select-none align-middle appearance-none no-underline font-body uppercase max-w-[360px] min-w-[90px] relative min-h-[48px] shrink-0 py-3 px-4 overflow-hidden whitespace-normal text-center flex-direction-column ".concat(t?"text-forestDeep border-b-2 border-b-forestDeep pb-2.5":"text-forestDeep/80 border-0"," ").concat(l?"text-iron! pointer-events-none":""),onClick:()=>a(r),role:"tab","aria-selected":t,type:"button",children:n})},r=e=>{let{activeTab:t,ariaLabel:n,className:o="",onChange:r,tabs:l}=e;return(0,i.jsx)("div",{"aria-label":n,className:"w-full overflow-x-auto no-scrollbar min-h-[48px] ".concat(o),children:(0,i.jsx)("div",{className:"inline-block relative flex-auto whitespace-nowrap",children:(0,i.jsx)("div",{className:"flex",children:l.map((e=>(0,i.jsx)(a,{isActive:t===e.value,label:e.label,value:e.value,onClick:r,disabled:e.disabled,path:e.path},e.value)))})})})}},6740:function(e,t,n){"use strict";n.d(t,{C:function(){return h},m:function(){return v}});var i=n(85893),o=n(11163),a=n(71234),r=n(23065),l=n(11872),s=n(67294),c=n(70090),d=n(58750),u=n(27518),p=n(47754);const f=e=>{let{className:t="",planting:n}=e;const{openModal:o}=(0,c.dd)(),a=(0,s.useMemo)((()=>{const e=[];var t,i;n.WorkflowState===p.o.Draft&&e.push({text:"Edit report",href:(0,u.Hw)({routeParams:{applicationId:n.ApplicationId,plantingId:n.Id,projectId:null===(i=n.Application)||void 0===i||null===(t=i.Project)||void 0===t?void 0:t.Id}})},{text:"Delete report",onClick:()=>{o(c.w8.DeletePlanting,{plantingId:n.Id})}});return e}),[n.ApplicationId,n.Id,n.WorkflowState]);return a.length?(0,i.jsx)(d.m,{actions:a,className:t,buttonComponentProps:{variant:"outline"},children:"Actions"}):null};var v;!function(e){e.Details="details",e.Monitorings="monitorings",e.Photos="photos"}(v||(v={}));const m=e=>{let{activeTab:t,children:n,planting:s,tabs:c}=e;const d=(0,o.useRouter)();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.nL,{children:(null===s||void 0===s?void 0:s.Name)||"Planting"}),(0,i.jsxs)(a.Z,{size:"small",className:"overflow-x-scroll",children:[(0,i.jsxs)("div",{className:"flex justify-between items-center pr-4",children:[(0,i.jsx)(l.m,{className:"mx-4 mt-2",tabs:c,onChange:e=>{if(e===t)return;const n=c.find((t=>t.value===e));n&&d.push(null===n||void 0===n?void 0:n.path)},activeTab:t,ariaLabel:"Application navigation"}),(0,i.jsx)(f,{className:"ml-4",planting:s})]}),(0,i.jsx)("div",{className:"p-4",children:n})]})]})},h=e=>{const{planting:t}=e,n=function(e){var t,n,i,o,a,r;return[{label:"Planting details",value:"details",path:(0,u.gA)({routeParams:{applicationId:e.ApplicationId,plantingId:e.Id,projectId:null===(n=e.Application)||void 0===n||null===(t=n.Project)||void 0===t?void 0:t.Id}})},{label:"Monitorings",value:"monitorings",path:(0,u.f_)({routeParams:{applicationId:e.ApplicationId,plantingId:e.Id,projectId:null===(o=e.Application)||void 0===o||null===(i=o.Project)||void 0===i?void 0:i.Id}})},{label:"Photos",value:"photos",path:(0,u.Wq)({routeParams:{applicationId:e.ApplicationId,plantingId:e.Id,projectId:null===(r=e.Application)||void 0===r||null===(a=r.Project)||void 0===a?void 0:a.Id}})}]}(t);return(0,i.jsx)(m,{...e,planting:t,tabs:n})}},57460:function(e,t,n){"use strict";n.d(t,{I:function(){return p}});var i=n(85893),o=n(27060),a=n(11163),r=n(92077),l=n.n(r),s=n(67294),c=n(75850),d=n(27518),u=n(73967);const p=e=>{let{monitoringsData:t,applicationId:n,projectId:r,plantingId:p,plantingQuantity:f,isAdmin:v}=e;const m=(0,a.useRouter)(),h=v?d.gb:d.HZ,x=(0,o.Cl)(),g=(0,s.useMemo)((()=>[x.accessor("MonitoredOn",{header:"Monitoring date",cell:e=>e.getValue()?(0,u.p6)({date:e.getValue(),format:"DD/MM/YYYY",isUtc:!0}):"-"}),x.accessor("MonitoringLines",{header:"Estimated surviving trees",cell:e=>{const t=e.getValue().reduce(((e,t)=>e+t.SurvivingTrees),0);return(0,i.jsxs)("span",{children:[l()(t/f*100).format("0,0"),"%"]})}}),x.accessor("CreatedOn",{header:"Created",cell:e=>e.getValue()?(0,u.p6)({date:e.getValue(),format:"DD/MM/YYYY",isUtc:!0}):"-"})]),[t]);return(0,i.jsx)(c.i,{columns:g,data:t,onSelect:e=>
1{m.push(h({routeParams:{applicationId:n,plantingId:p,eventId:e.Id,projectId:r}}))}})}},14031:function(e,t,n){"use strict";n.d(t,{g:function(){return o}});var i=n(85893);const o=e=>{let{className:t="",...n}=e;return(0,i.jsx)("div",{className:"flex flex-col ".concat(t),...n})}},33529:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return b}});var i=n(85893),o=n(7515),a=n(11163),r=n(67294),l=n(53719),s=n(82999),c=n(24276),d=n(23065),u=n(57460),p=n(14031),f=n(89827),v=n(27518),m=n(80037),h=n(29268),x=n(47754),g=n(6740);const j=()=>{var e,t;const n=(0,a.useRouter)(),{user:o}=(0,l.a)(),{applicationId:j,plantingId:b,projectId:I}=n.query,{data:w,loading:N}=(0,f.jgB)({fetchPolicy:"network-only",variables:{plantingId:b}}),{called:y,data:k,loading:P}=(0,f.$8j)({fetchPolicy:"network-only",variables:{id:j,planterId:null===o||void 0===o||null===(e=o.Account)||void 0===e?void 0:e.PlanterId}}),C=(0,r.useMemo)((()=>{var e;return null===k||void 0===k||null===(e=k.Application)||void 0===e?void 0:e[0]}),[k]),A=(0,r.useMemo)((()=>(null===C||void 0===C?void 0:C.Plantings)||[]),[C]),M=null===w||void 0===w?void 0:w.Planting_by_pk;var D;const S=(0,r.useMemo)((()=>A.filter((e=>e.WorkflowState!==x.o.Draft)).reduce(((e,t)=>e+t.Quantity),0)),[A])>=(null!==(D=null===C||void 0===C?void 0:C.Approved)&&void 0!==D?D:0),_=!!(null===w||void 0===w||null===(t=w.MonitoringEvents)||void 0===t?void 0:t.length);return N||w?N?null:!y||P||C?(0,i.jsx)(p.g,{children:(0,i.jsx)(c.T,{isLoading:N,children:(0,i.jsxs)(g.C,{activeTab:g.m.Monitorings,planting:M,children:[_&&(S||(null===C||void 0===C?void 0:C.WorkflowState)===h.oj.Monitoring)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(u.I,{isAdmin:!1,plantingId:b,plantingQuantity:M.Quantity,applicationId:j,monitoringsData:(null===w||void 0===w?void 0:w.MonitoringEvents)||[],projectId:I}),(0,i.jsx)(s.J,{className:"mt-6 self-start",href:(0,v.gl)({routeParams:{applicationId:j,plantingId:b,projectId:I}}),children:"Add monitoring"})]}):null,S&&!_&&(0,i.jsxs)("div",{className:"px-4",children:[(0,i.jsx)(d.nv,{children:"Looks like you haven't added any monitorings for your planting yet."}),(0,i.jsx)(d.nv,{children:"Please do this on an annual basis."}),M.WorkflowState===x.o.Submitted?(0,i.jsx)(s.J,{href:(0,v.gl)({routeParams:{applicationId:j,plantingId:b,projectId:I}}),children:"Start"}):(0,i.jsx)(d.nv,{children:"Submit your planting report before monitoring."})]}),!_&&!S&&(0,i.jsx)(d.nv,{children:"You must report all of your planted trees before you can begin monitoring."})]})})}):(0,i.jsx)(m.T,{}):(0,i.jsx)(m.T,{})};var b=(0,n(33712).hN)((()=>(0,i.jsx)(o.T3,{title:"Monitorings",children:(0,i.jsx)(j,{})})))},47754:function(e,t,n){"use strict";var i;n.d(t,{o:function(){return i}}),function(e){e.Draft="Draft",e.Submitted="Submitted"}(i||(i={}))},33712:function(e,t,n){"use strict";n.d(t,{Wb:function(){return u},hN:function(){return f},j_:function(){return v},mL:function(){return p}});var i=n(85893),o=n(88100),a=n(11163),r=n(67294),l=n(13508),s=n(53719),c=n(33441),d=n(27518);const u=e=>function(){const{isLoading:t,isStaff:n}=(0,l.a)(),s=(0,a.useRouter)();(0,r.useEffect)((()=>{t||n||s.replace(d.$x)}),[n,t]);const u=(0,o.u3)(e,{onRedirecting:c.F});return(0,i.jsx)(u,{})},p=e=>function(){const{isLoading:t,isAdvisor:n,isStaff:s}=(0,l.a)(),u=(0,a.useRouter)();(0,r.useEffect)((()=>{t||n||s||u.replace(d.$x)}),[n,s,t]);const p=(0,o.u3)(e,{onRedirecting:c.F});return(0,i.jsx)(p,{})},f=(e,t)=>(0,o.u3)(e,{onRedirecting:c.F,...t}),v=e=>function(){const{user:t,isLoading:n}=(0,s.a)(),o=(0,a.useRouter)(),l=(0,r.useMemo)((()=>!n&&t&&!(null===t||void 0===t?void 0:t.Account)),[t,n]);return(0,r.useEffect)((()=>{l&&o.replace({pathname:(0,d.Yh)(),query:{returnTo:o.asPath}})}),[l,o]),n||l?null:(0,i.jsx)(e,{})}}},function(e){e.O(0,[5970,509,1255,5666,9759,9336,1317,5850,2888,9774,179],(function(){return t=81474,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
2//# sourceMappingURL=monitorings-696b4da272153661.js.map

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.