Skip to content
Snippets Groups Projects

progress bar issue [COMP-253][COMP-254]

Merged Saket Agrahari requested to merge feature/COMP-253-Progress-bar into develop
2 unresolved threads
2 files
+ 13
12
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -169,4 +169,4 @@ to {
> * {
pointer-events: auto;
}
`,er=({reverseOrder:e,position:n="top-center",toastOptions:r,gutter:o,children:i,containerStyle:s,containerClassName:a})=>{let{toasts:l,handlers:u}=(e=>{let{toasts:n,pausedAt:r}=((e={})=>{let[n,r]=(0,t.useState)(En);(0,t.useEffect)((()=>(Vn.push(r),()=>{let e=Vn.indexOf(r);e>-1&&Vn.splice(e,1)})),[n]);let o=n.toasts.map((t=>{var n,r;return{...e,...e[t.type],...t,duration:t.duration||(null==(n=e[t.type])?void 0:n.duration)||(null==e?void 0:e.duration)||_n[t.type],style:{...e.style,...null==(r=e[t.type])?void 0:r.style,...t.style}}}));return{...n,toasts:o}})(e);(0,t.useEffect)((()=>{if(r)return;let e=Date.now(),t=n.map((t=>{if(t.duration===1/0)return;let n=(t.duration||0)+t.pauseDuration-(e-t.createdAt);if(!(n<0))return setTimeout((()=>In.dismiss(t.id)),n);t.visible&&In.dismiss(t.id)}));return()=>{t.forEach((e=>e&&clearTimeout(e)))}}),[n,r]);let o=(0,t.useCallback)((()=>{r&&On({type:6,time:Date.now()})}),[r]),i=(0,t.useCallback)(((e,t)=>{let{reverseOrder:r=!1,gutter:o=8,defaultPosition:i}=t||{},s=n.filter((t=>(t.position||i)===(e.position||i)&&t.height)),a=s.findIndex((t=>t.id===e.id)),l=s.filter(((e,t)=>t<a&&e.visible)).length;return s.filter((e=>e.visible)).slice(...r?[l+1]:[0,l]).reduce(((e,t)=>e+(t.height||0)+o),0)}),[n]);return{toasts:n,handlers:{updateHeight:Rn,startPause:Dn,endPause:o,calculateOffset:i}}})(r);return t.createElement("div",{style:{position:"fixed",zIndex:9999,top:16,left:16,right:16,bottom:16,pointerEvents:"none",...s},className:a,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map((r=>{let s=r.position||n,a=((e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},o=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:wn()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...o}})(s,u.calculateOffset(r,{reverseOrder:e,gutter:o,defaultPosition:n}));return t.createElement(Yn,{id:r.id,key:r.id,onHeightUpdate:u.updateHeight,className:r.visible?Xn:"",style:a},"custom"===r.type?bn(r.message,r):i?i(r):t.createElement(Zn,{toast:r,position:s}))})))},tr=In,nr=n(535),rr=n(352),or=function(e){return e.Unverified="unverified",e.Verified="verified",e.Edited="edited",e}({});const ir=function(e){var n=e.surveyModel,r=e.verificationStatus;function o(e,t){var i;r.current.set(e.name,t);var s=document.createElement("button");s.type="button",s.className="sv-action-bar-item verification",s.innerHTML=t,t==or.Unverified?(s.innerHTML="No change from previous year",s.className+=" verification-required",s.onclick=function(){"display"!=n.mode&&(e.validate(),o(e,or.Verified))}):(s.innerHTML="Answer updated",s.className+=" verification-ok");var a='[data-name="'+e.name+'"]',l=null===(i=document.querySelector(a))||void 0===i?void 0:i.querySelector("h5"),u=null==l?void 0:l.querySelector(".verification");u?u.replaceWith(s):null==l||l.appendChild(s)}return n.css={question:{title:"sv-title sv-question__title sv-header-flex",titleOnError:"sv-question__title--error sv-error-color-fix"}},nr.FunctionFactory.Instance.register("validateWebsiteUrl",(function(e){var t=e[0];if(void 0===t||null==t||""==t)return!0;try{var n=new URL(t);return"http:"===n.protocol||"https:"===n.protocol}catch(e){return!1}})),n.onAfterRenderQuestion.add((function(e,t){var n=r.current.get(t.question.name);n&&o(t.question,n)})),n.onValueChanged.add((function(e,t){r.current.get(t.question.name)==or.Unverified&&o(t.question,or.Edited)})),n.onUpdateQuestionCssClasses.add((function(e,t){t.question.hideCheckboxLabels&&(t.cssClasses.root+=" hidden-checkbox-labels")})),n.onMatrixAfterCellRender.add((function(e,t){if(0==t.column.indexValue&&"item"in t.row){var n,r=t.row.item;void 0!==r.customDescription&&(null===(n=t.htmlElement.parentElement)||void 0===n||n.children[0].setAttribute("title",r.customDescription))}})),t.createElement(rr.Survey,{model:n})},sr=t.forwardRef(((e,t)=>{const[{className:n,...r},{as:o="div",bsPrefix:i,spans:s}]=function({as:e,bsPrefix:t,className:n,...r}){t=je(t,"col");const o=Me(),i=qe(),s=[],a=[];return o.forEach((e=>{const n=r[e];let o,l,u;delete r[e],"object"==typeof n&&null!=n?({span:o,offset:l,order:u}=n):o=n;const c=e!==i?`-${e}`:"";o&&s.push(!0===o?`${t}${c}`:`${t}${c}-${o}`),null!=u&&a.push(`order${c}-${u}`),null!=l&&a.push(`offset${c}-${l}`)})),[{...r,className:Se()(n,...s,...a)},{as:e,bsPrefix:t,spans:s}]}(e);return(0,Te.jsx)(o,{...r,ref:t,className:Se()(n,!s.length&&i)})}));sr.displayName="Col";const ar=sr;function lr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ur(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lr(Object(n),!0).forEach((function(t){Ft(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const cr=function(e){var n=e.surveyModel,r=e.pageNoSetter,o=ve((0,t.useState)([]),2),i=o[0],s=o[1],a=function(e){if(["checkbox","text","comment","multipletext"].includes(e.getType())){if(null!==e.value&&void 0!==e.value){if(e.value.length>0)return!0;if(Object.keys(e.value).length>0&&"multipletext"===e.getType())return void 0!==Object.values(e.value)[0]}return!1}return null!==e.value&&void 0!==e.value};(0,t.useEffect)((function(){var e=function(e){if(e&&e.pages){var t=[];e.pages.forEach((function(n){var r=n.questions.filter((function(e){return e.startWithNewLine})),o=r.length,i=r.filter(a).length,s=o-i,l=i/o;t.push({completionPercentage:100*l,unansweredPercentage:s/o*100,totalPages:e.pages.length,pageTitle:n.title})})),s(t)}};n.onValueChanged.add((function(t){e(t)})),e(n)}),[n]);var l={height:"0.5rem",transition:"width 0.3s ease"};return t.createElement(zt,{className:"survey-progress"},t.createElement(Ut,null,i.map((function(e,o){return t.createElement(ar,{xs:12,md:!0,key:o,onClick:function(){return r(o)},style:{cursor:"pointer",margin:"0.5rem"}},t.createElement("div",null,t.createElement("span",{style:{whiteSpace:"nowrap",fontSize:"1.5rem",marginRight:"0.25rem",fontWeight:"bold",color:"#2db394"}},o+1),t.createElement("span",{style:ur({whiteSpace:"nowrap"},n.currentPageNo==o&&{fontWeight:"bold"})},e.pageTitle),t.createElement("div",{style:{display:"flex",flexWrap:"wrap"}},t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.completionPercentage,"%"),backgroundColor:"#262261"})}),t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.unansweredPercentage,"%"),backgroundColor:"#cdcdcd"})}))))}))))},pr=function(e){var n=e.surveyModel,r=e.surveyActions,o=e.year,i=e.nren,s=e.children,a=ve((0,t.useState)(0),2),l=a[0],u=a[1],c=ve((0,t.useState)(!1),2),p=c[0],d=c[1],h=ve((0,t.useState)(""),2),f=h[0],g=h[1],m=ve((0,t.useState)(""),2),y=m[0],v=m[1],b=(0,t.useContext)($t).user,C=(0,t.useCallback)((function(){d("edit"==n.mode),g(n.lockedBy),u(n.currentPageNo),v(n.status)}),[n]);(0,t.useEffect)((function(){C()}),[C]);var w=function(){var e=Ce(xe().mark((function e(t){return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r[t]();case 2:C();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),x=function(e,n){return t.createElement("button",{className:"sv-btn sv-btn--navigation",onClick:function(){return w(n)}},e)},P="Save and stop editing",S="Save progress",V="Start editing",E="Complete Survey",O=function(){return t.createElement("div",{className:"survey-edit-buttons-block"},!p&&!f&&n.editAllowed&&x(V,"startEdit"),!p&&f&&f==b.name&&x("Discard any unsaved changes and release your lock","releaseLock"),p&&l===n.visiblePages.length-1&&x(E,"complete"),p&&x(P,"saveAndStopEdit"),p&&x(S,"save"))},_=parseInt(o);return t.createElement(zt,null,t.createElement(Ut,{className:"survey-content"},t.createElement("h2",null,t.createElement("span",{className:"survey-title"},o," Compendium Survey "),t.createElement("span",{className:"survey-title-nren"}," ",i," "),t.createElement("span",null," - ",y)),t.createElement("p",{style:{marginTop:"1rem"}},"To get started, click “",V,"” to end read-only mode. This is only possible when nobody else from your NREN is currently working on the survey.",t.createElement("br",null),"Where available, the survey questions are pre-filled with answers from the previous year. The survey asks about the past year, i.e. the ",o," survey asks about data from ",_-1," (or ",_-1,"/",o," if your NRENs financial year does not match the calendar year). You can edit the prefilled answer to provide new information, or press the “no change from previous year” button.",t.createElement("br",null),"Press the “",S,"“ or “",P,"“ button to save all answers in the survey. When you reach the last section of the survey (Services), you will find a “",E,"“ button which saves all answers in the survey and lets the Compendium team know that your answers are ready to be published.",t.createElement("br",null),"As long as the survey remains open, any Compendium administrator from your NREN can add answers or amend existing ones, even after using the “",E,"“ button. Different people from your NREN can contribute to the survey if needed.",t.createElement("br",null),"Some fields require specific data, such as numerical data, valid http-addresses, and in some questions, the answer has to add up to 100%. If an answer does not fulfil the set criteria, the question will turn pink and an error message will appear. Fields can be left blank if you prefer not to answer a question.",t.createElement("br",null),"If you notice any errors after the survey was closed, please contact us for correcting those."),t.createElement("p",null,"Thank you for taking the time to fill in the ",o," Compendium Survey. Any questions or requests can be sent to ",t.createElement("a",{href:"mailto:Partner-Relations@geant.org"},t.createElement("span",null,"Partner-Relations@geant.org"))),p&&t.createElement(t.Fragment,null,t.createElement("br",null),t.createElement("b",null,"Remember to click “",P,"” before leaving the page."))),t.createElement(Ut,null,O()),t.createElement(Ut,{className:"survey-content"},!p&&t.createElement("div",{className:"survey-edit-explainer"},!f&&n.editAllowed&&t.createElement("span",null,"The survey is in read-only mode; click the “Start editing“ button to start editing the answers."),!f&&!n.editAllowed&&t.createElement("span",null,"The survey is in read-only mode and can not be edited by you."),f&&f!=b.name&&"The survey is in READONLY mode and currently being edited by: "+f+". To start editing the survey, ask them to complete their edits.",f&&f==b.name&&'The survey is in READONLY mode because you started editing in another tab, browser or device. To start editing the survey, either complete those edits or click the "Discard any unsaved changes" button.')),t.createElement(Ut,null,t.createElement(cr,{surveyModel:n,pageNoSetter:function(e){u(e),n.currentPageNo=e}}),s),t.createElement(Ut,null,O()))};nr.Serializer.addProperty("itemvalue","customDescription:text"),nr.Serializer.addProperty("question","hideCheckboxLabels:boolean");const dr=function(e){var n=e.loadFrom,r=ve((0,t.useState)(),2),o=r[0],i=r[1],s=(0,t.useRef)(new Map),a=function(){let{matches:e}=t.useContext(Q),n=e[e.length-1];return n?n.params:{}}(),l=a.year,u=a.nren,c=ve((0,t.useState)("loading survey..."),2),p=c[0],d=c[1],h=(0,t.useRef)(),f=(0,t.useCallback)((function(e){return e.preventDefault(),e.returnValue=""}),[]),g=(0,t.useCallback)((function(){u&&window.navigator.sendBeacon("/api/response/unlock/"+l+"/"+u)}),[]);if((0,t.useEffect)((function(){function e(){return(e=Ce(xe().mark((function e(){var t,r,o,a;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(n+l+(u?"/"+u:""));case 2:return t=e.sent,e.next=5,t.json();case 5:if(r=e.sent,t.ok){e.next=12;break}if(!("message"in r)){e.next=11;break}throw new Error(r.message);case 11:throw new Error("Request failed with status ".concat(t.status));case 12:for(o in r.verification_status)s.current.set(o,r.verification_status[o]);(a=new nr.Model(r.model)).setVariable("surveyyear",l),a.setVariable("previousyear",parseInt(l)-1),a.showNavigationButtons=!1,a.data=r.data,a.clearIncorrectValues(!0),a.currentPageNo=r.page,a.mode=r.mode,a.lockedBy=r.locked_by,a.status=r.status,a.editAllowed=r.edit_allowed,i(a);case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(function(){return e.apply(this,arguments)})().catch((function(e){return d("Error when loading survey: "+e.message)}))}),[]),!o)return p;var m,y,v,b,C,w=function(){var e=Ce(xe().mark((function e(t,n){var r,i,a;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u){e.next=2;break}return e.abrupt("return","Saving not available in inpect/try mode");case 2:return r={lock_uuid:h.current,new_state:n,data:t.data,page:t.currentPageNo,verification_status:Object.fromEntries(s.current)},e.prev=3,e.next=6,fetch("/api/response/save/"+l+"/"+u,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(r)});case 6:return i=e.sent,e.next=9,i.json();case 9:if(a=e.sent,i.ok){e.next=12;break}return e.abrupt("return",a.message);case 12:o.mode=a.mode,o.lockedBy=a.locked_by,o.status=a.status,e.next=20;break;case 17:return e.prev=17,e.t0=e.catch(3),e.abrupt("return","Unknown Error: "+e.t0.message);case 20:case"end":return e.stop()}}),e,null,[[3,17]])})));return function(t,n){return e.apply(this,arguments)}}(),x=function(e){var t="",n=function(e,n){s.current.get(n.name)==or.Unverified&&(""==t&&(t=n.name),n.error='Please verify that last years data is correct by editing the answer or pressing the "No change from previous year" button!')};o.onValidateQuestion.add(n);var r=e();return o.onValidateQuestion.remove(n),r||(tr("Validation failed!"),o.focusQuestion(t)),r},P={save:(C=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(o,"editing");case 2:t=e.sent,tr(t?"Failed saving survey: "+t:"Survey saved!");case 4:case"end":return e.stop()}}),e)}))),function(){return C.apply(this,arguments)}),complete:(b=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!x(o.validate.bind(o,!0,!0))){e.next=6;break}return e.next=4,w(o,"completed");case 4:(t=e.sent)?tr("Failed completing survey: "+t):(tr("Survey completed!"),removeEventListener("beforeunload",f,{capture:!0}),removeEventListener("pagehide",g));case 6:case"end":return e.stop()}}),e)}))),function(){return b.apply(this,arguments)}),saveAndStopEdit:(v=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(o,"readonly");case 2:(t=e.sent)?tr("Failed saving survey: "+t):(tr("Survey saved!"),removeEventListener("beforeunload",f,{capture:!0}),removeEventListener("pagehide",g));case 4:case"end":return e.stop()}}),e)}))),function(){return v.apply(this,arguments)}),startEdit:(y=Ce(xe().mark((function e(){var t,n;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("/api/response/lock/"+l+"/"+u,{method:"POST"});case 2:return t=e.sent,e.next=5,t.json();case 5:if(n=e.sent,t.ok){e.next=9;break}return tr("Failed starting edit: "+n.message),e.abrupt("return");case 9:addEventListener("pagehide",g),addEventListener("beforeunload",f,{capture:!0}),o.data=n.data,o.clearIncorrectValues(!0),o.mode=n.mode,o.lockedBy=n.locked_by,o.status=n.status,h.current=n.lock_uuid;case 17:case"end":return e.stop()}}),e)}))),function(){return y.apply(this,arguments)}),releaseLock:(m=Ce(xe().mark((function e(){var t,n;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("/api/response/unlock/"+l+"/"+u,{method:"POST"});case 2:return t=e.sent,e.next=5,t.json();case 5:if(n=e.sent,t.ok){e.next=9;break}return tr("Failed releasing lock: "+n.message),e.abrupt("return");case 9:o.mode=n.mode,o.lockedBy=n.locked_by,o.status=n.status;case 12:case"end":return e.stop()}}),e)}))),function(){return m.apply(this,arguments)}),validatePage:function(){x(o.validatePage.bind(o))&&tr("Page validation successful!")}};return t.createElement(zt,{className:"survey-container"},t.createElement(er,null),t.createElement(pr,{surveyModel:o,surveyActions:P,year:l,nren:u},t.createElement(ir,{surveyModel:o,verificationStatus:s})))},hr=n.p+"9ab20ac1d835b50b2e01.svg",fr=function(){return t.createElement("div",{className:"external-page-nav-bar"},t.createElement(zt,null,t.createElement(Ut,null,t.createElement(ar,{xs:10},t.createElement("div",{className:"nav-wrapper"},t.createElement("nav",{className:"header-nav"},t.createElement("a",{href:"https://geant.org/"},t.createElement("img",{src:hr})),t.createElement("ul",null,t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://network.geant.org/"},"NETWORK")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/services/"},"SERVICES")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://community.geant.org/"},"COMMUNITY")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://tnc23.geant.org/"},"TNC")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/projects/"},"PROJECTS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/"},"CONNECT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://impact.geant.org/"},"IMPACT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://careers.geant.org/"},"CAREERS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://about.geant.org/"},"ABOUT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/community-news"},"NEWS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://resources.geant.org/"},"RESOURCES")))))))))},gr=function(){var e,n=(0,t.useContext)($t).user,r=J(),o=!!n.id,i=!!o&&!!n.nrens.length,s=i?n.nrens[0]:"",a=!!o&&n.permissions.admin;return t.createElement(zt,{className:"py-5 grey-container"},t.createElement(Ut,null,t.createElement("div",{className:"center-text"},t.createElement("h1",{className:"geant-header"},"THE GÉANT COMPENDIUM OF NRENS SURVEY"),t.createElement("div",{className:"wordwrap pt-4",style:{maxWidth:"75rem"}},t.createElement("p",{style:{textAlign:"left"}},"Hello,",t.createElement("br",null),"Welcome to the GÉANT Compendium Survey. NREN Compendium administrators can login ",t.createElement("a",{href:"/login"},"here")," to complete their registration to fill in the 2023 Compendium survey. Once your registration has been confirmed you will receive an email from the Compendium administration team.",t.createElement("br",null),"If you are not sure whether you are a Compendium Administrator for your NREN, please contact your GÉANT Partner Relations relationship manager.",t.createElement("br",null),"Thank you."),t.createElement("span",null,"Current registration status:"),t.createElement("br",null),t.createElement("br",null),a?t.createElement("ul",null,t.createElement("li",null,t.createElement("span",null,"You are logged in as a Compendium Administrator")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/surveys"},"here")," to access the survey management page.")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/users"},"here")," to access the user management page."))):t.createElement("ul",null,!a&&i&&(e=(new Date).getFullYear(),r("/survey/response/".concat(e,"/").concat(s)),t.createElement(t.Fragment,null)),o?t.createElement("li",null,t.createElement("span",null,"You are logged in")):t.createElement("li",null,t.createElement("span",null,"You are not logged in")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Your access to the survey has not been approved")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Once you have been approved, you will immediately be directed to the relevant survey upon visiting this page")))))))},mr=function(){return t.createElement("div",{className:"app"},t.createElement(ce,null,t.createElement(Gt,null,t.createElement(fr,null),t.createElement(se,null,t.createElement(oe,{path:"survey/admin/surveys",element:t.createElement(At,null)}),t.createElement(oe,{path:"survey/admin/users",element:t.createElement(tn,null)}),t.createElement(oe,{path:"survey/admin/inspect/:year",element:t.createElement(dr,{loadFrom:"/api/response/inspect/"})}),t.createElement(oe,{path:"survey/admin/try/:year",element:t.createElement(dr,{loadFrom:"/api/response/try/"})}),t.createElement(oe,{path:"survey/response/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/response/load/"})}),t.createElement(oe,{path:"*",element:t.createElement(gr,null)})))))};var yr=document.getElementById("root");(0,r.s)(yr).render(t.createElement(t.StrictMode,null,t.createElement(mr,null)))})()})();
\ No newline at end of file
`,er=({reverseOrder:e,position:n="top-center",toastOptions:r,gutter:o,children:i,containerStyle:s,containerClassName:a})=>{let{toasts:l,handlers:u}=(e=>{let{toasts:n,pausedAt:r}=((e={})=>{let[n,r]=(0,t.useState)(En);(0,t.useEffect)((()=>(Vn.push(r),()=>{let e=Vn.indexOf(r);e>-1&&Vn.splice(e,1)})),[n]);let o=n.toasts.map((t=>{var n,r;return{...e,...e[t.type],...t,duration:t.duration||(null==(n=e[t.type])?void 0:n.duration)||(null==e?void 0:e.duration)||_n[t.type],style:{...e.style,...null==(r=e[t.type])?void 0:r.style,...t.style}}}));return{...n,toasts:o}})(e);(0,t.useEffect)((()=>{if(r)return;let e=Date.now(),t=n.map((t=>{if(t.duration===1/0)return;let n=(t.duration||0)+t.pauseDuration-(e-t.createdAt);if(!(n<0))return setTimeout((()=>In.dismiss(t.id)),n);t.visible&&In.dismiss(t.id)}));return()=>{t.forEach((e=>e&&clearTimeout(e)))}}),[n,r]);let o=(0,t.useCallback)((()=>{r&&On({type:6,time:Date.now()})}),[r]),i=(0,t.useCallback)(((e,t)=>{let{reverseOrder:r=!1,gutter:o=8,defaultPosition:i}=t||{},s=n.filter((t=>(t.position||i)===(e.position||i)&&t.height)),a=s.findIndex((t=>t.id===e.id)),l=s.filter(((e,t)=>t<a&&e.visible)).length;return s.filter((e=>e.visible)).slice(...r?[l+1]:[0,l]).reduce(((e,t)=>e+(t.height||0)+o),0)}),[n]);return{toasts:n,handlers:{updateHeight:Rn,startPause:Dn,endPause:o,calculateOffset:i}}})(r);return t.createElement("div",{style:{position:"fixed",zIndex:9999,top:16,left:16,right:16,bottom:16,pointerEvents:"none",...s},className:a,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map((r=>{let s=r.position||n,a=((e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},o=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:wn()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...o}})(s,u.calculateOffset(r,{reverseOrder:e,gutter:o,defaultPosition:n}));return t.createElement(Yn,{id:r.id,key:r.id,onHeightUpdate:u.updateHeight,className:r.visible?Xn:"",style:a},"custom"===r.type?bn(r.message,r):i?i(r):t.createElement(Zn,{toast:r,position:s}))})))},tr=In,nr=n(535),rr=n(352),or=function(e){return e.Unverified="unverified",e.Verified="verified",e.Edited="edited",e}({});const ir=function(e){var n=e.surveyModel,r=e.verificationStatus;function o(e,t){var i;r.current.set(e.name,t);var s=document.createElement("button");s.type="button",s.className="sv-action-bar-item verification",s.innerHTML=t,t==or.Unverified?(s.innerHTML="No change from previous year",s.className+=" verification-required",s.onclick=function(){"display"!=n.mode&&(e.validate(),o(e,or.Verified))}):(s.innerHTML="Answer updated",s.className+=" verification-ok");var a='[data-name="'+e.name+'"]',l=null===(i=document.querySelector(a))||void 0===i?void 0:i.querySelector("h5"),u=null==l?void 0:l.querySelector(".verification");u?u.replaceWith(s):null==l||l.appendChild(s)}return n.css={question:{title:"sv-title sv-question__title sv-header-flex",titleOnError:"sv-question__title--error sv-error-color-fix"}},nr.FunctionFactory.Instance.register("validateWebsiteUrl",(function(e){var t=e[0];if(void 0===t||null==t||""==t)return!0;try{var n=new URL(t);return"http:"===n.protocol||"https:"===n.protocol}catch(e){return!1}})),n.onAfterRenderQuestion.add((function(e,t){var n=r.current.get(t.question.name);n&&o(t.question,n)})),n.onValueChanged.add((function(e,t){r.current.get(t.question.name)==or.Unverified&&o(t.question,or.Edited)})),n.onUpdateQuestionCssClasses.add((function(e,t){t.question.hideCheckboxLabels&&(t.cssClasses.root+=" hidden-checkbox-labels")})),n.onMatrixAfterCellRender.add((function(e,t){if(0==t.column.indexValue&&"item"in t.row){var n,r=t.row.item;void 0!==r.customDescription&&(null===(n=t.htmlElement.parentElement)||void 0===n||n.children[0].setAttribute("title",r.customDescription))}})),t.createElement(rr.Survey,{model:n})},sr=t.forwardRef(((e,t)=>{const[{className:n,...r},{as:o="div",bsPrefix:i,spans:s}]=function({as:e,bsPrefix:t,className:n,...r}){t=je(t,"col");const o=Me(),i=qe(),s=[],a=[];return o.forEach((e=>{const n=r[e];let o,l,u;delete r[e],"object"==typeof n&&null!=n?({span:o,offset:l,order:u}=n):o=n;const c=e!==i?`-${e}`:"";o&&s.push(!0===o?`${t}${c}`:`${t}${c}-${o}`),null!=u&&a.push(`order${c}-${u}`),null!=l&&a.push(`offset${c}-${l}`)})),[{...r,className:Se()(n,...s,...a)},{as:e,bsPrefix:t,spans:s}]}(e);return(0,Te.jsx)(o,{...r,ref:t,className:Se()(n,!s.length&&i)})}));sr.displayName="Col";const ar=sr;function lr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ur(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lr(Object(n),!0).forEach((function(t){Ft(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const cr=function(e){var n=e.surveyModel,r=e.pageNoSetter,o=ve((0,t.useState)([]),2),i=o[0],s=o[1],a=function(e){return!(null===e.value||void 0===e.value||""===e.value||"checkbox"===e.getType()&&0==e.value.length||"multipletext"===e.getType()&&(1===Object.keys(e.value).length&&void 0===Object.values(e.value)[0]||0===Object.keys(e.value).length))};(0,t.useEffect)((function(){var e=function(e){if(e&&e.pages){var t=[];e.pages.forEach((function(n){var r=n.questions.filter((function(e){return e.startWithNewLine})),o=r.length,i=r.filter(a).length,s=o-i,l=i/o;t.push({completionPercentage:100*l,unansweredPercentage:s/o*100,totalPages:e.pages.length,pageTitle:n.title})})),s(t)}};n.onValueChanged.add((function(t){e(t)})),e(n)}),[n]);var l={height:"0.5rem",transition:"width 0.3s ease"};return t.createElement(zt,{className:"survey-progress"},t.createElement(Ut,null,i.map((function(e,o){return t.createElement(ar,{xs:12,md:!0,key:o,onClick:function(){return r(o)},style:{cursor:"pointer",margin:"0.5rem"}},t.createElement("div",null,t.createElement("span",{style:{whiteSpace:"nowrap",fontSize:"1.5rem",marginRight:"0.25rem",fontWeight:"bold",color:"#2db394"}},o+1),t.createElement("span",{style:ur({whiteSpace:"nowrap"},n.currentPageNo==o&&{fontWeight:"bold"})},e.pageTitle),t.createElement("div",{style:{display:"flex",flexWrap:"wrap"}},t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.completionPercentage,"%"),backgroundColor:"#262261"})}),t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.unansweredPercentage,"%"),backgroundColor:"#cdcdcd"})}))))}))))},pr=function(e){var n=e.surveyModel,r=e.surveyActions,o=e.year,i=e.nren,s=e.children,a=ve((0,t.useState)(0),2),l=a[0],u=a[1],c=ve((0,t.useState)(!1),2),p=c[0],d=c[1],h=ve((0,t.useState)(""),2),f=h[0],g=h[1],m=ve((0,t.useState)(""),2),y=m[0],v=m[1],b=(0,t.useContext)($t).user,C=(0,t.useCallback)((function(){d("edit"==n.mode),g(n.lockedBy),u(n.currentPageNo),v(n.status)}),[n]);(0,t.useEffect)((function(){C()}),[C]);var w=function(){var e=Ce(xe().mark((function e(t){return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r[t]();case 2:C();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),x=function(e,n){return t.createElement("button",{className:"sv-btn sv-btn--navigation",onClick:function(){return w(n)}},e)},P="Save and stop editing",S="Save progress",V="Start editing",E="Complete Survey",O=function(){return t.createElement("div",{className:"survey-edit-buttons-block"},!p&&!f&&n.editAllowed&&x(V,"startEdit"),!p&&f&&f==b.name&&x("Discard any unsaved changes and release your lock","releaseLock"),p&&l===n.visiblePages.length-1&&x(E,"complete"),p&&x(P,"saveAndStopEdit"),p&&x(S,"save"))},_=parseInt(o);return t.createElement(zt,null,t.createElement(Ut,{className:"survey-content"},t.createElement("h2",null,t.createElement("span",{className:"survey-title"},o," Compendium Survey "),t.createElement("span",{className:"survey-title-nren"}," ",i," "),t.createElement("span",null," - ",y)),t.createElement("p",{style:{marginTop:"1rem"}},"To get started, click “",V,"” to end read-only mode. This is only possible when nobody else from your NREN is currently working on the survey.",t.createElement("br",null),"Where available, the survey questions are pre-filled with answers from the previous year. The survey asks about the past year, i.e. the ",o," survey asks about data from ",_-1," (or ",_-1,"/",o," if your NRENs financial year does not match the calendar year). You can edit the prefilled answer to provide new information, or press the “no change from previous year” button.",t.createElement("br",null),"Press the “",S,"“ or “",P,"“ button to save all answers in the survey. When you reach the last section of the survey (Services), you will find a “",E,"“ button which saves all answers in the survey and lets the Compendium team know that your answers are ready to be published.",t.createElement("br",null),"As long as the survey remains open, any Compendium administrator from your NREN can add answers or amend existing ones, even after using the “",E,"“ button. Different people from your NREN can contribute to the survey if needed.",t.createElement("br",null),"Some fields require specific data, such as numerical data, valid http-addresses, and in some questions, the answer has to add up to 100%. If an answer does not fulfil the set criteria, the question will turn pink and an error message will appear. Fields can be left blank if you prefer not to answer a question.",t.createElement("br",null),"If you notice any errors after the survey was closed, please contact us for correcting those."),t.createElement("p",null,"Thank you for taking the time to fill in the ",o," Compendium Survey. Any questions or requests can be sent to ",t.createElement("a",{href:"mailto:Partner-Relations@geant.org"},t.createElement("span",null,"Partner-Relations@geant.org"))),p&&t.createElement(t.Fragment,null,t.createElement("br",null),t.createElement("b",null,"Remember to click “",P,"” before leaving the page."))),t.createElement(Ut,null,O()),t.createElement(Ut,{className:"survey-content"},!p&&t.createElement("div",{className:"survey-edit-explainer"},!f&&n.editAllowed&&t.createElement("span",null,"The survey is in read-only mode; click the “Start editing“ button to start editing the answers."),!f&&!n.editAllowed&&t.createElement("span",null,"The survey is in read-only mode and can not be edited by you."),f&&f!=b.name&&"The survey is in READONLY mode and currently being edited by: "+f+". To start editing the survey, ask them to complete their edits.",f&&f==b.name&&'The survey is in READONLY mode because you started editing in another tab, browser or device. To start editing the survey, either complete those edits or click the "Discard any unsaved changes" button.')),t.createElement(Ut,null,t.createElement(cr,{surveyModel:n,pageNoSetter:function(e){u(e),n.currentPageNo=e}}),s),t.createElement(Ut,null,O()))};nr.Serializer.addProperty("itemvalue","customDescription:text"),nr.Serializer.addProperty("question","hideCheckboxLabels:boolean");const dr=function(e){var n=e.loadFrom,r=ve((0,t.useState)(),2),o=r[0],i=r[1],s=(0,t.useRef)(new Map),a=function(){let{matches:e}=t.useContext(Q),n=e[e.length-1];return n?n.params:{}}(),l=a.year,u=a.nren,c=ve((0,t.useState)("loading survey..."),2),p=c[0],d=c[1],h=(0,t.useRef)(),f=(0,t.useCallback)((function(e){return e.preventDefault(),e.returnValue=""}),[]),g=(0,t.useCallback)((function(){u&&window.navigator.sendBeacon("/api/response/unlock/"+l+"/"+u)}),[]);if((0,t.useEffect)((function(){function e(){return(e=Ce(xe().mark((function e(){var t,r,o,a;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(n+l+(u?"/"+u:""));case 2:return t=e.sent,e.next=5,t.json();case 5:if(r=e.sent,t.ok){e.next=12;break}if(!("message"in r)){e.next=11;break}throw new Error(r.message);case 11:throw new Error("Request failed with status ".concat(t.status));case 12:for(o in r.verification_status)s.current.set(o,r.verification_status[o]);(a=new nr.Model(r.model)).setVariable("surveyyear",l),a.setVariable("previousyear",parseInt(l)-1),a.showNavigationButtons=!1,a.data=r.data,a.clearIncorrectValues(!0),a.currentPageNo=r.page,a.mode=r.mode,a.lockedBy=r.locked_by,a.status=r.status,a.editAllowed=r.edit_allowed,i(a);case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(function(){return e.apply(this,arguments)})().catch((function(e){return d("Error when loading survey: "+e.message)}))}),[]),!o)return p;var m,y,v,b,C,w=function(){var e=Ce(xe().mark((function e(t,n){var r,i,a;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u){e.next=2;break}return e.abrupt("return","Saving not available in inpect/try mode");case 2:return r={lock_uuid:h.current,new_state:n,data:t.data,page:t.currentPageNo,verification_status:Object.fromEntries(s.current)},e.prev=3,e.next=6,fetch("/api/response/save/"+l+"/"+u,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(r)});case 6:return i=e.sent,e.next=9,i.json();case 9:if(a=e.sent,i.ok){e.next=12;break}return e.abrupt("return",a.message);case 12:o.mode=a.mode,o.lockedBy=a.locked_by,o.status=a.status,e.next=20;break;case 17:return e.prev=17,e.t0=e.catch(3),e.abrupt("return","Unknown Error: "+e.t0.message);case 20:case"end":return e.stop()}}),e,null,[[3,17]])})));return function(t,n){return e.apply(this,arguments)}}(),x=function(e){var t="",n=function(e,n){s.current.get(n.name)==or.Unverified&&(""==t&&(t=n.name),n.error='Please verify that last years data is correct by editing the answer or pressing the "No change from previous year" button!')};o.onValidateQuestion.add(n);var r=e();return o.onValidateQuestion.remove(n),r||(tr("Validation failed!"),o.focusQuestion(t)),r},P={save:(C=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(o,"editing");case 2:t=e.sent,tr(t?"Failed saving survey: "+t:"Survey saved!");case 4:case"end":return e.stop()}}),e)}))),function(){return C.apply(this,arguments)}),complete:(b=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!x(o.validate.bind(o,!0,!0))){e.next=6;break}return e.next=4,w(o,"completed");case 4:(t=e.sent)?tr("Failed completing survey: "+t):(tr("Survey completed!"),removeEventListener("beforeunload",f,{capture:!0}),removeEventListener("pagehide",g));case 6:case"end":return e.stop()}}),e)}))),function(){return b.apply(this,arguments)}),saveAndStopEdit:(v=Ce(xe().mark((function e(){var t;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(o,"readonly");case 2:(t=e.sent)?tr("Failed saving survey: "+t):(tr("Survey saved!"),removeEventListener("beforeunload",f,{capture:!0}),removeEventListener("pagehide",g));case 4:case"end":return e.stop()}}),e)}))),function(){return v.apply(this,arguments)}),startEdit:(y=Ce(xe().mark((function e(){var t,n;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("/api/response/lock/"+l+"/"+u,{method:"POST"});case 2:return t=e.sent,e.next=5,t.json();case 5:if(n=e.sent,t.ok){e.next=9;break}return tr("Failed starting edit: "+n.message),e.abrupt("return");case 9:addEventListener("pagehide",g),addEventListener("beforeunload",f,{capture:!0}),o.data=n.data,o.clearIncorrectValues(!0),o.mode=n.mode,o.lockedBy=n.locked_by,o.status=n.status,h.current=n.lock_uuid;case 17:case"end":return e.stop()}}),e)}))),function(){return y.apply(this,arguments)}),releaseLock:(m=Ce(xe().mark((function e(){var t,n;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("/api/response/unlock/"+l+"/"+u,{method:"POST"});case 2:return t=e.sent,e.next=5,t.json();case 5:if(n=e.sent,t.ok){e.next=9;break}return tr("Failed releasing lock: "+n.message),e.abrupt("return");case 9:o.mode=n.mode,o.lockedBy=n.locked_by,o.status=n.status;case 12:case"end":return e.stop()}}),e)}))),function(){return m.apply(this,arguments)}),validatePage:function(){x(o.validatePage.bind(o))&&tr("Page validation successful!")}};return t.createElement(zt,{className:"survey-container"},t.createElement(er,null),t.createElement(pr,{surveyModel:o,surveyActions:P,year:l,nren:u},t.createElement(ir,{surveyModel:o,verificationStatus:s})))},hr=n.p+"9ab20ac1d835b50b2e01.svg",fr=function(){return t.createElement("div",{className:"external-page-nav-bar"},t.createElement(zt,null,t.createElement(Ut,null,t.createElement(ar,{xs:10},t.createElement("div",{className:"nav-wrapper"},t.createElement("nav",{className:"header-nav"},t.createElement("a",{href:"https://geant.org/"},t.createElement("img",{src:hr})),t.createElement("ul",null,t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://network.geant.org/"},"NETWORK")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/services/"},"SERVICES")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://community.geant.org/"},"COMMUNITY")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://tnc23.geant.org/"},"TNC")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/projects/"},"PROJECTS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/"},"CONNECT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://impact.geant.org/"},"IMPACT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://careers.geant.org/"},"CAREERS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://about.geant.org/"},"ABOUT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/community-news"},"NEWS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://resources.geant.org/"},"RESOURCES")))))))))},gr=function(){var e,n=(0,t.useContext)($t).user,r=J(),o=!!n.id,i=!!o&&!!n.nrens.length,s=i?n.nrens[0]:"",a=!!o&&n.permissions.admin;return t.createElement(zt,{className:"py-5 grey-container"},t.createElement(Ut,null,t.createElement("div",{className:"center-text"},t.createElement("h1",{className:"geant-header"},"THE GÉANT COMPENDIUM OF NRENS SURVEY"),t.createElement("div",{className:"wordwrap pt-4",style:{maxWidth:"75rem"}},t.createElement("p",{style:{textAlign:"left"}},"Hello,",t.createElement("br",null),"Welcome to the GÉANT Compendium Survey. NREN Compendium administrators can login ",t.createElement("a",{href:"/login"},"here")," to complete their registration to fill in the 2023 Compendium survey. Once your registration has been confirmed you will receive an email from the Compendium administration team.",t.createElement("br",null),"If you are not sure whether you are a Compendium Administrator for your NREN, please contact your GÉANT Partner Relations relationship manager.",t.createElement("br",null),"Thank you."),t.createElement("span",null,"Current registration status:"),t.createElement("br",null),t.createElement("br",null),a?t.createElement("ul",null,t.createElement("li",null,t.createElement("span",null,"You are logged in as a Compendium Administrator")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/surveys"},"here")," to access the survey management page.")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/users"},"here")," to access the user management page."))):t.createElement("ul",null,!a&&i&&(e=(new Date).getFullYear(),r("/survey/response/".concat(e,"/").concat(s)),t.createElement(t.Fragment,null)),o?t.createElement("li",null,t.createElement("span",null,"You are logged in")):t.createElement("li",null,t.createElement("span",null,"You are not logged in")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Your access to the survey has not been approved")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Once you have been approved, you will immediately be directed to the relevant survey upon visiting this page")))))))},mr=function(){return t.createElement("div",{className:"app"},t.createElement(ce,null,t.createElement(Gt,null,t.createElement(fr,null),t.createElement(se,null,t.createElement(oe,{path:"survey/admin/surveys",element:t.createElement(At,null)}),t.createElement(oe,{path:"survey/admin/users",element:t.createElement(tn,null)}),t.createElement(oe,{path:"survey/admin/inspect/:year",element:t.createElement(dr,{loadFrom:"/api/response/inspect/"})}),t.createElement(oe,{path:"survey/admin/try/:year",element:t.createElement(dr,{loadFrom:"/api/response/try/"})}),t.createElement(oe,{path:"survey/response/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/response/load/"})}),t.createElement(oe,{path:"*",element:t.createElement(gr,null)})))))};var yr=document.getElementById("root");(0,r.s)(yr).render(t.createElement(t.StrictMode,null,t.createElement(mr,null)))})()})();
\ No newline at end of file
Loading