PageSourceSearch

https://keykorea.vercel.app/_next/static/chunks/pages/questions-4e674de8444a0d851a3e.js

js keykorea.vercel.app collected 2026-10-03 07:11:22 UTC 35,724 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[971],{37162:function(e,r,n){"use strict";var t=n(85893),s=n(68527),i=n(49609);r.Z=function(){return(0,t.jsx)(s.xu,{pt:"8",w:"full",children:(0,t.jsx)(s.M5,{children:(0,t.jsx)(i.$,{color:"blue.400"})})})}},98784:function(e,r,n){"use strict";n.d(r,{J:function(){return i}});var t=n(85893),s=n(68527),i=function(){return(0,t.jsxs)(s.xu,{maxH:"100px",maxW:"100px",as:"svg",id:"b21613c9-2bf0-4d37-bef0-3b193d34fc5d","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 647.63626 632.17383",children:[(0,t.jsx)("path",{d:"M687.3279,276.08691H512.81813a15.01828,15.01828,0,0,0-15,15v387.85l-2,.61005-42.81006,13.11a8.00676,8.00676,0,0,1-9.98974-5.31L315.678,271.39691a8.00313,8.00313,0,0,1,5.31006-9.99l65.97022-20.2,191.25-58.54,65.96972-20.2a7.98927,7.98927,0,0,1,9.99024,5.3l32.5498,106.32Z",transform:"translate(-276.18187 -133.91309)",fill:"#f2f2f2"}),(0,t.jsx)("path",{d:"M725.408,274.08691l-39.23-128.14a16.99368,16.99368,0,0,0-21.23-11.28l-92.75,28.39L380.95827,221.60693l-92.75,28.4a17.0152,17.0152,0,0,0-11.28028,21.23l134.08008,437.93a17.02661,17.02661,0,0,0,16.26026,12.03,16.78926,16.78926,0,0,0,4.96972-.75l63.58008-19.46,2-.62v-2.09l-2,.61-64.16992,19.65a15.01489,15.01489,0,0,1-18.73-9.95l-134.06983-437.94a14.97935,14.97935,0,0,1,9.94971-18.73l92.75-28.4,191.24024-58.54,92.75-28.4a15.15551,15.15551,0,0,1,4.40966-.66,15.01461,15.01461,0,0,1,14.32032,10.61l39.0498,127.56.62012,2h2.08008Z",transform:"translate(-276.18187 -133.91309)",fill:"#3f3d56"}),(0,t.jsx)("path",{d:"M398.86279,261.73389a9.0157,9.0157,0,0,1-8.61133-6.3667l-12.88037-42.07178a8.99884,8.99884,0,0,1,5.9712-11.24023l175.939-53.86377a9.00867,9.00867,0,0,1,11.24072,5.9707l12.88037,42.07227a9.01029,9.01029,0,0,1-5.9707,11.24072L401.49219,261.33887A8.976,8.976,0,0,1,398.86279,261.73389Z",transform:"translate(-276.18187 -133.91309)",fill:"#4299e1"}),(0,t.jsx)("circle",{cx:"190.15351",cy:"24.95465",r:"20",fill:"#4299e1"}),(0,t.jsx)("circle",{cx:"190.15351",cy:"24.95465",r:"12.66462",fill:"#fff"}),(0,t.jsx)("path",{d:"M878.81836,716.08691h-338a8.50981,8.50981,0,0,1-8.5-8.5v-405a8.50951,8.50951,0,0,1,8.5-8.5h338a8.50982,8.50982,0,0,1,8.5,8.5v405A8.51013,8.51013,0,0,1,878.81836,716.08691Z",transform:"translate(-276.18187 -133.91309)",fill:"#e6e6e6"}),(0,t.jsx)("path",{d:"M723.31813,274.08691h-210.5a17.02411,17.02411,0,0,0-17,17v407.8l2-.61v-407.19a15.01828,15.01828,0,0,1,15-15H723.93825Zm183.5,0h-394a17.02411,17.02411,0,0,0-17,17v458a17.0241,17.0241,0,0,0,17,17h394a17.0241,17.0241,0,0,0,17-17v-458A17.02411,17.02411,0,0,0,906.81813,274.08691Zm15,475a15.01828,15.01828,0,0,1-15,15h-394a15.01828,15.01828,0,0,1-15-15v-458a15.01828,15.01828,0,0,1,15-15h394a15.01828,15.01828,0,0,1,15,15Z",transform:"translate(-276.18187 -133.91309)",fill:"#3f3d56"}),(0,t.jsx)("path",{d:"M801.81836,318.08691h-184a9.01015,9.01015,0,0,1-9-9v-44a9.01016,9.01016,0,0,1,9-9h184a9.01016,9.01016,0,0,1,9,9v44A9.01015,9.01015,0,0,1,801.81836,318.08691Z",transform:"translate(-276.18187 -133.91309)",fill:"#4299e1"}),(0,t.jsx)("circle",{cx:"433.63626",cy:"105.17383",r:"20",fill:"#4299e1"}),(0,t.jsx)("circle",{cx:"433.63626",cy:"105.17383",r:"12.18187",fill:"#fff"})]})}},84144:function(e,r,n){"use strict";n.d(r,{h:function(){return c}});var t=n(55645),s=n(85893),i=n(6886),o=n(68527),c=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"6";return e&&e.response&&e.response.data?e.response.data.detail?(0,s.jsxs)(i.bZ,{marginBottom:r,status:"error",children:[(0,s.jsx)(i.zM,{})," ",e.response.data.detail]}):"object"!==typeof e.response.data||Array.isArray(e.response.data)||null==e.response.data?(0,s.jsxs)(i.bZ,{marginBottom:r,status:"error",children:[(0,s.jsx)(i.zM,{})," Internal Server Error"]}):(0,s.jsx)(i.bZ,{marginBottom:r,status:"error",children:(0,s.jsxs)(o.Kq,{children:[(0,s.jsxs)(o.Ug,{ml:"0",pl:"0",children:[(0,s.jsx)(i.zM,{}),(0,s.jsx)(o.xv,{children:"Errors in the following fields"})]}),(0,s.jsx)(o.QI,{children:Object.entries(e.response.data).map((function(e){var r=(0,t.Z)(e,2),n=r[0],i=r[1];return(0,s.jsxs)(o.HC,{ml:"14",children:[(n.charAt(0).toUpperCase()+n.slice(1)).split("_").join(" ")," ","- ",i[0]||"
1Unknown Error"]})}))})]})}):(0,s.jsxs)(i.bZ,{marginBottom:r,status:"error",children:[(0,s.jsx)(i.zM,{})," Internal Server Error"]})}},41390:function(e,r,n){"use strict";n.d(r,{s:function(){return t}});var t=function(){return!1}},40078:function(e,r,n){"use strict";n.d(r,{a:function(){return o}});var t=n(11163),s=n(41390),i=n(89789),o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/",r=(0,t.useRouter)(),n=(0,i.a)(),o=n.state,c=o.isLoading,a=o.user;return(0,s.s)()||(c||a||r.push(e),c||!a||a.isAdmin||r.push(e)),{isLoading:c}}},59941:function(e,r,n){"use strict";n.d(r,{n:function(){return d}});var t=n(809),s=n.n(t),i=n(30266),o=n(9669),c=n.n(o),a=n(88767),l=n(58747),u=function(){var e=(0,i.Z)(s().mark((function e(r){var n,t;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r.length<=0)){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,c().get("".concat(l.M,"/api/subexercises/exercise/").concat(r,"/"));case 4:return n=e.sent,t=n.data,e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),d=function(e){return(0,a.useQuery)(["subexercise","dashboard",e],(function(){return u(e)}))}},4755:function(e,r,n){"use strict";n.r(r),n.d(r,{default:function(){return Ne}});var t=n(85893),s=n(55645),i=n(67294),o=n(68527),c=n(4612),a=n(73465),l=n(11391),u=n(31570),d=n(809),f=n.n(d),x=n(30266),p=n(92809),h=n(56311),j=n(68133),g=n(6886),b=n(79042),v=n(33344),m=n(59876),y=n(79521),O=n(97375),w=n(93083),_=n(15193),C=n(55667),P=n(9669),D=n.n(P),S=n(58747),q=n(88767),Z=n(84144),k=function(){var e=(0,x.Z)(f().mark((function e(r){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().delete("".concat(S.M,"/api/questions/"),{data:{questions:r.map((function(e){return e.original.id}))}});case 2:return n=e.sent,e.abrupt("return",n.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),E=function(e){var r=e.exercise_slug,n=e.selectedItems,s=(0,O.qY)(),c=s.isOpen,a=s.onOpen,l=s.onClose,u=(0,w.pm)(),d=i.useRef(),f=(0,q.useQueryClient)(),x=(0,q.useMutation)((function(){return k(n)}),{onSuccess:function(e){f.setQueryData(["dashboard",r],(function(r){var n=new Set(e);return r.filter((function(e){return!n.has(e.id)}))})),u({title:"Deleted question".concat(n.length>1?"s":"","."),description:"You have successfully deleted the selected question".concat(n.length>1?"s":"","."),status:"success",position:"top-right",duration:4e3,isClosable:!0}),l()}}),p=x.mutate,h=x.isLoading,j=x.isError,g=x.error;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(_.zx,{onClick:a,colorScheme:"white",variant:"link",children:["Delete Selected ",n.length>1?"Items":"Item","."]}),(0,t.jsx)(C.aR,{isOpen:c,leastDestructiveRef:d,onClose:l,isCentered:!0,children:(0,t.jsx)(C.dh,{children:(0,t.jsxs)(C._T,{children:[j&&(0,t.jsx)(C.fY,{fontSize:"md",fontWeight:"normal",pb:"0",mb:"0",children:(0,Z.h)(g)}),(0,t.jsxs)(C.fY,{pt:j?"0":"6",fontSize:"lg",fontWeight:"bold",children:["Delete ",n.length," ",n.length>1?"items":"item"]}),(0,t.jsxs)(C.iP,{children:[(0,t.jsxs)(o.xv,{children:["Are you sure? This will delete the following"," ",n.length>1?"items":"item",":"]}),(0,t.jsx)(o.QI,{children:n.map((function(e,r){return(0,t.jsxs)(o.HC,{children:[e.original.subexercise_slug.subexercise_name," -"," ",e.original.question]},r)}))})]}),(0,t.jsxs)(C.xo,{children:[(0,t.jsx)(_.zx,{ref:d,onClick:l,children:"Cancel"}),(0,t.jsx)(_.zx,{colorScheme:"red",isLoading:h,onClick:p,ml:3,children:"Delete"})]})]})})})]})},A=n(58256),R=n(19501),z=n(79762),I=n(33441);function N(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function Q(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?N(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEac
1h((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var M=R.Ry({subexercise_slug:R.Z_().required("Required!"),question:R.Z_().required("Required!").max(500),translation:R.Z_().required("Required!").max(500)}),T=function(){var e=(0,x.Z)(f().mark((function e(r,n){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().put("".concat(S.M,"/api/questions/").concat(n,"/"),r);case 2:return t=e.sent,e.abrupt("return",t.data);case 4:case"end":return e.stop()}}),e)})));return function(r,n){return e.apply(this,arguments)}}(),L=function(e){var r=e.row,n=e.exercise,s=(0,O.qY)(),i=s.isOpen,c=s.onOpen,a=s.onClose,l=(0,w.pm)(),u=(0,q.useQueryClient)(),d=(0,q.useMutation)((function(e){return T(e,r.id)}),{onSuccess:function(e){u.setQueryData(["dashboard",n],(function(n){return n.map((function(n){return n.id===r.id?Q(Q(Q({},n),e),{},{subexercise_slug:Q({},n.subexercise_slug)}):n}))})),l({title:"Edited Question",description:"You have successfully edited a question",status:"success",position:"top-right",duration:4e3,isClosable:!0}),a()}}),f=d.mutate,x=d.isError,p=d.error,h=d.isLoading;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_.zx,{onClick:c,size:"sm",variant:"ghost",color:"blue.400",float:"right",children:"Edit"}),(0,t.jsxs)(C.u_,{onClose:a,isOpen:i,isCentered:!0,children:[(0,t.jsx)(C.ZA,{}),(0,t.jsx)(C.hz,{children:(0,t.jsx)(A.J9,{onSubmit:f,initialValues:{subexercise_slug:r.subexercise_slug.subexercise_slug,question:r.question,translation:r.translation},enableReinitialize:!0,validationSchema:M,children:function(e){var r=e.values;return(0,t.jsxs)(A.l0,{children:[(0,t.jsx)(C.xB,{children:"Edit Question"}),(0,t.jsx)(C.ol,{}),(0,t.jsx)(C.fe,{children:(0,t.jsxs)(o.gC,{spacing:"4",children:[x&&(0,Z.h)(p),(0,t.jsxs)(o.Kq,{spacing:4,w:"full",children:[(0,t.jsx)(A.gN,{name:"question",children:function(e){var n=e.field,s=e.form;return(0,t.jsxs)(z.NI,{isInvalid:s.errors.question&&s.touched.question,children:[(0,t.jsx)(z.lX,{children:"Question"}),(0,t.jsx)(I.g,Q(Q({},n),{},{id:"question",placeholder:"Enter question",value:r.question})),(0,t.jsx)(z.J1,{children:s.errors.question})]})}}),(0,t.jsx)(A.gN,{name:"translation",children:function(e){var n=e.field,s=e.form;return(0,t.jsxs)(z.NI,{isInvalid:s.errors.translation&&s.touched.translation,children:[(0,t.jsx)(z.lX,{children:"Translation"}),(0,t.jsx)(I.g,Q(Q({},n),{},{id:"translation",placeholder:"Enter translation",value:r.translation})),(0,t.jsx)(z.J1,{children:s.errors.translation})]})}})]})]})}),(0,t.jsx)(C.mz,{children:(0,t.jsxs)(_.hE,{children:[(0,t.jsx)(_.zx,{onClick:a,children:"Cancel"}),(0,t.jsx)(_.zx,{isLoading:h,type:"submit",variant:"solid",bgColor:"blue.400",color:"white",_hover:{bgColor:"blue.500"},children:"Edit Question"})]})})]})}})})]})]})},F=n(13356),X=n(20949),B=n(47398),H=n(98532),K=n(86730);function J(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}var U=function(e){var r=(0,K.u)();return(0,t.jsx)(H.Z,function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?J(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}({strokeColor:r.colors.blue[400],backgroundColor:(0,X.ff)("white",r.colors.gray[700])},e))},Y=n(79352),V=n(81540),W=n.n(V);function G(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function $(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?G(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):G(Object(n)).forEac
1h((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ee=function(e){var r=e.isDragAccept,n=e.isDragReject,t=e.isDragActive,s=e.defaultColor,i=e.isInvalid;return r?"#00e676":n||i?"rgb(252, 129, 129)":t?"#2196f3":s},re=function(e){var r=e.setFieldValue,n=e.isInvalid,c=i.useState(null),l=(0,s.Z)(c,2),u=l[0],d=l[1],f=i.useState(!1),x=(0,s.Z)(f,2),p=x[0],h=x[1],j=(0,X.ff)("rgb(226, 232, 240)","rgba(255, 255, 255, 0.16)");i.useEffect((function(){return function(){return r("audio_file",null)}}),[]);var g=(0,F.uI)({accept:"audio/*",onDrop:function(e){d(URL.createObjectURL(e[0])),r("audio_file",e[0])}}),b=g.getRootProps,v=g.getInputProps,m=g.isDragActive,y=g.isDragAccept,O=g.isDragReject;return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(z.NI,{children:[(0,t.jsxs)(a.mQ,{isFitted:!0,children:[(0,t.jsxs)(a.td,{children:[(0,t.jsx)(a.OK,{children:"Upload Existing Audio"}),(0,t.jsx)(a.OK,{children:"Record Audio Now"})]}),(0,t.jsxs)(a.nP,{children:[(0,t.jsx)(a.x4,{pb:"0",px:"0",children:(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(o.kC,$($({display:"flex",textAlign:"center",padding:"30px",borderRadius:"5px",color:"#d1d5db",border:"dashed",borderWidth:"2px",borderColor:ee({isDragActive:m,isDragAccept:y,isDragReject:O,defaultColor:j,isInvalid:n})},b({isDragActive:m,isDragAccept:y,isDragReject:O})),{},{children:[(0,t.jsx)("input",$({},v())),(0,t.jsx)(o.xv,{size:"sm",children:"Drag and drop some files here, or click to select files"})]}))})}),(0,t.jsx)(a.x4,{paddingX:"0",children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.xu,{width:"full",as:U,record:p,borderRadius:"5px",mb:"2",onStop:function(e){d(e.blobURL),r("audio_file",new File([e.blob],"file",{type:e.blob.type}))}}),(0,t.jsx)(o.M5,{children:(0,t.jsx)(B.u,{label:p?"Stop Recording":"Start Recording",children:(0,t.jsx)(_.hU,{fontSize:"30px",rounded:"100%",backgroundColor:p?"red.400":"blue.400",color:"white",_hover:{bgColor:p?"red.500":"blue.500"},onClick:function(){return h(!p)},icon:p?(0,t.jsx)(Y.CgQ,{}):(0,t.jsx)(Y.XBp,{})})})})]})})]})]}),u&&(0,t.jsxs)(z.NI,{mt:"2",children:[(0,t.jsx)(z.lX,{children:"Audio Preview"}),(0,t.jsx)(o.xu,{w:"full",as:W(),src:u,controls:!0})]})]})})},ne=n(43366),te=n(59941),se=n(37162);function ie(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function oe(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ie(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ie(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ce=function(){var e=(0,x.Z)(f().mark((function e(r){var n,t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new FormData,Object.keys(r).forEach((function(e){return null!=r[e]&&n.append(e,r[e])})),e.next=4,D().post("".concat(S.M,"/api/questions/"),n);case 4:return t=e.sent,e.abrupt("return",t.data);case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),ae=function(e){var r=e.onClose,n=i.useState(""),c=(0,s.Z)(n,2),a=c[0],d=c[1],f=i.useState(""),x=(0,s.Z)(f,2),p=(x[0],x[1],(0,ne.N)()),h=p.data,j=p.isLoading,g=(0,te.n)(a),b=g.data,v=g.isLoading,m=(0,w.pm)(),y=(0,q.useQueryClient)(),O=R.Ry({subexercise_slug:R.Z_().required("Required!"),question:R.Z_().required("Required!").max(500),translation:R.Z_().required("Required!").max(500),audio_file:R.nK().when(["subexercise_slug"],(function(e,r){return a.length>0&&h.find((function(e){return e.exercise_slug===a})).allow_audio_files_in_questions?r.required("Required!"):r}))}),P=(0,q.useMutation)(ce,{onSuccess:function(e){var n=b.find((function(r){return r.subexercise_slug===e.subexercise_slug})).subexercise_name;y.setQueryData(["dashboard",a],(function(r){return Array.isArray(r)?[].concat((0,u.Z)(r),[oe(oe({},e),{},{subexercise_slug:{subexercise_name:n,subexercise_slug:e.subexercise_slug}})]):[oe(oe({},e),{},{subexercise_slug:{subexercise_name:n,subexercise_slug:e.subexercise_slug}})]})),m({title:"Created Question",description:"You have successfully created a new question",status:"success",position:"top-right",duration:4e3,isClosable:!0}),r()}}),D=P.mutate,S=P.isError,k=P.error,E=P.isLoading;return(0,t.jsx)(A.J9,{initialValues:{subexercise_slug:"",question:"",translation:"",audio_file:null},onSubmit:D,enableReinitialize:!0,validationSchema:O,children:function(e){var n=e.values,i=e.setFieldValue;return(0,t.jsxs)(A.l0,{children:[(0,t.jsx)(C.fe,{children:(0,t.jsx)(o.gC,{spacing:"4",children:(0,t.jsxs)(o.Kq,{spacing:4,w:"full",children:[(0,t.jsxs)(z.NI,{children:[S&&(0,Z.h)(k),(0,t.jsx)(z.lX,{children:"Exercise Type"}),(0,t.jsx)(l.Ph,{onChange:function(e){return function(e,r){d(e.target.value),r("subexercise_slug","")}(e,i)},value:a,placeholder:"Select exercise",children:j||!h?(0,t.jsx)("option",{children:"Loading"}):Object.entries(h).map((function(e,r){var n=(0,s.Z)(e,2),i=(n[0],n[1]);return(0,t.jsx)("option",{value:i.exercise_slug,children:i.exercise_name},r)}))})]}),(0,t.jsx)(A.gN,{name:"subexercise_slug",as:"select",children:function(e){var r=e.field,n=e.form;return(0,t.jsxs)(z.NI,{isInvalid:n.errors.subexercise_slug&&n.touched.subexercise_slug,children:[(0,t.jsx)(z.lX,{children:"Subexercise Type"}),(0,t.jsx)(l.Ph,oe(oe({},r),{},{isDisabled:""===a,placeholder:"Select subexercise",children:v||!b?(0,t.jsx)(se.Z,{}):b.map((function(e,r){return(0,t.jsx)("option",{value:e.subexercise_slug,children:e.subexercise_name},r)}))})),(0,t.jsx)(z.J1,{children:n.errors.subexercise_slug})]})}}),(0,t.jsx)(A.gN,{name:"question",children:function(e){var r=e.field,s=e.form;return(0,t.jsxs)(z.NI,{isInvalid:s.errors.question&&s.touched.question,children:[(0,t.jsx)(z.lX,{children:"Question"}),(0,t.jsx)(I.g,oe(oe({},r),{},{id:"question",placeholder:"Enter question",value:n.question})),(0,t.jsx)(z.J1,{children:s.errors.question})]})}}),(0,t.jsx)(A.gN,{name:"translation",children:function(e){var r=e.field,s=e.form;return(0,t.jsxs)(z.NI,{isInvalid:s.errors.translation&&s.touched.translation,children:[(0,t.jsx)(z.lX,{children:"Translation"}),(0,t.jsx)(I.g,oe(oe({},r),{},{id:"translation",placeholder:"Enter translation",value:n.translation})),(0,t.jsx)(z.J1,{children:s.errors.translation})]})}}),a.length>0?h.find((function(e){return e.exercise_slug===a})).allow_audio_files_in_questions&&(0,t.jsx)(A.gN,{name:"audio_file",children:function(e){e.field;var r=e.form;return(0,t.jsxs)(z.NI,{isInvalid:r.errors.audio_file,children:[(0,t.jsx)(re,{isInvalid:r.errors.audio_file,setFieldValue:i}),(0,t.jsx)(z.J1,{children:r.errors.audio_file})]})}}):null]})})}),(0,t.jsx)(C.mz,{children:(0,t.jsxs)(_.hE,{mt:"4",children:[(0,t.jsx)(_.zx,{onClick:r,children:"Cancel"}),(0,t.jsx)(_.zx,{isLoading:E,variant:"solid",bgColor:"blue.400",color:"white",type:"submit",_hover:{bgColor:"blue.500"},children:"Create Question"})]})})]})}})},le=n(7869);function ue(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function de(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};
1r%2?ue(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ue(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var fe=function(e){var r=e.isDragAccept,n=e.isDragReject,t=e.isDragActive,s=e.defaultColor,i=e.isInvalid;return r?"#00e676":n||i?"rgb(252, 129, 129)":t?"#2196f3":s},xe=function(e){var r=e.setFieldValue,n=e.isInvalid,c=i.useState(null),a=(0,s.Z)(c,2),l=a[0],u=a[1],d=(0,X.ff)("rgb(226, 232, 240)","rgba(255, 255, 255, 0.16)"),f=(0,F.uI)({accept:"",onDrop:function(e){u(e[0]),function(e){var n=new FileReader;n.readAsArrayBuffer(e),n.onload=function(e){var n=e.target.result,t=le.read(n,{type:"buffer"}),s=[];t.SheetNames.forEach((function(e){var r=t.Sheets[e],n=[{exercise:e}];n.push(le.utils.sheet_to_json(r)),s.push(n)})),r("data",s)},n.onerror=function(e){reject(e)}}(e[0])}}),x=f.getRootProps,p=f.getInputProps,h=f.isDragActive,j=f.isDragAccept,g=f.isDragReject;return(0,t.jsxs)(o.xu,{children:[(0,t.jsxs)(o.kC,de(de({display:"flex",textAlign:"center",padding:"30px",borderRadius:"5px",color:"#d1d5db",border:"dashed",borderWidth:"2px",borderColor:fe({isDragActive:h,isDragAccept:j,isDragReject:g,defaultColor:d,isInvalid:n})},x({isDragActive:h,isDragAccept:j,isDragReject:g})),{},{children:[(0,t.jsx)("input",de({},p())),(0,t.jsx)(o.xv,{size:"sm",children:"Drag and drop an excel file here, or click to select a file"})]})),l&&(0,t.jsxs)(o.xv,{fontSize:"sm",mt:"2",children:[l.path," - ",l.size,"kb"]})]})},pe=n(93162);function he(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function je(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?he(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):he(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ge=R.Ry({data:R.nK().required("Required"),replace:R.Xg().required()}),be=function(){var e=(0,x.Z)(f().mark((function e(r){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().post("".concat(S.M,"/api/upload-questions/"),r);case 2:return e.abrupt("return",r);case 3:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),ve=function(){var e=(0,x.Z)(f().mark((function e(){var r,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().get("".concat(S.M,"/api/exercises/"));case 2:return r=e.sent,n=r.data,e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),me=function(){var e=(0,x.Z)(f().mark((function e(r){var n,t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().get("".concat(S.M,"/api/download-questions/").concat(r,"/"));case 2:return n=e.sent,t=n.data,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),ye=function(){var e=(0,x.Z)(f().mark((function e(r){var n,t,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!0),n={SheetNames:[],Sheets:[]},e.next=4,ve();case 4:e.sent.forEach((function(e){if(!e.allow_audio_files_in_questions){var r=le.utils.json_to_sheet([{subexercise:"",question:"",translation:""}]);n.SheetNames.push(e.exercise_name),n.Sheets[e.exercise_name]=r}})),t=le.write(n,{bookType:"xlsx",type:"array"}),s=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),pe.saveAs(s,"KeyKoreaEmptyTemplate.xlsx"),r(!1);case 10:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),Oe=function(){var e=(0,x.Z)(f().mark((function e(r){var n,t,s,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!0),n={SheetNames:[],Sheets:[]},e.next=4,ve();case 4:return t=e.sent,e.next=7,Promise.all(t.map(function(){var e=(0,x.Z)(f().mark((function e(r){var t,s,i,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.exercise_name,s=r.exercise_slug,r.allow_audio_files_in_questions){e.next=9;break}return e.next=5,me(s);case 5:i=e.sent,o=le.utils.json_to_sheet(i),n.SheetNames.push(t),n.Sheets[t]=o;case 9:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()));case 7:s=le.write(n,{bookType:"xlsx",type:"array"}),i=new Blob([s],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),pe.saveAs(i,"KeyKoreaSampleTemplate.xlsx"),r(!1);case 11:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),we=function(e){var r=e.onClose,n=(0,w.pm)(),c=(0,q.useQueryClient)(),a=i.useState(!1),l=(0,s.Z)(a,2),u=l[0],d=l[1],p=i.useState(!1),h=(0,s.Z)(p,2),b=h[0],v=h[1],m=(0,q.useMutation)(be,{onSuccess:function(){var e=(0,x.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(),n({title:"Created Questions",description:"You have successfully created new questions",status:"success",position:"top-right",duration:4e3,isClosable:!0}),e.next=4,c.refetchQueries(["dashboard"],{active:!0});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}),y=m.mutate,O=m.isError,P=m.isLoading,D=m.error;return(0,t.jsx)(A.J9,{initialValues:{data:null,replace:!1},validationSchema:ge,onSubmit:y,children:function(e){var n=e.values,s=e.setFieldValue;return(0,t.jsxs)(A.l0,{children:[(0,t.jsx)(C.fe,{children:(0,t.jsxs)(o.gC,{w:"full",textAlign:"left",spacing:"4",children:[O&&(0,Z.h)(D,0),n.replace&&(0,t.jsxs)(g.bZ,{status:"warning",children:[(0,t.jsx)(g.zM,{}),'You have selected "Replace all current questions". This option will delete all questions currently stored in the database and replace them with the new questions in the provided excel file']}),(0,t.jsx)(o.xu,{textAlign:"left",w:"full",children:(0,t.jsx)(_.zx,{onClick:function(){return ye(v)},color:"blue.400",size:"sm",variant:"ghost",children:b?"Generating...":"Download empty template"})}),(0,t.jsx)(o.xu,{textAlign:"left",w:"full",children:(0,t.jsx)(_.zx,{onClick:function(){return Oe(d)},color:"blue.400",size:"sm",variant:"ghost",children:u?"Generating...":"Download sample template"})}),(0,t.jsx)(A.gN,{name:"data",children:function(e){e.field;var r=e.form;return(0,t.jsxs)(z.NI,{isInvalid:null==n.data&&r.errors.data,children:[(0,t.jsx)(xe,{isInvalid:null==n.data&&r.errors.data,setFieldValue:s}),(0,t.jsx)(z.J1,{children:r.errors.data})]})}}),(0,t.jsx)(o.xu,{maxH:"200px",overflowY:"auto",w:"full",children:(0,t.jsx)(o.gC,{w:"full",spacing:4,children:n.data&&n.data.map((function(e){return(0,t.jsxs)(o.xu,{w:"full",children:[(0,t.jsxs)(o.xv,{children:[e[0].exercise," questions to be added:"]}),e[1].length?e[1].map((function(e){return(0,t.jsxs)(o.xv,{fontSize:"sm",children:[e.subexercise," - ",e.question," -"," ",e.translation]})})):(0,t.jsx)(o.xv,{fontSize:"sm",children:"None"})]})}))})}),(0,t.jsx)(A.gN,{name:"replace",children:function(e){var r=e.field,n=e.form;return(0,t.jsxs)(z.NI,{isInvalid:n.errors.replace&&n.touched.replace,children:[(0,t.jsx)(j.XZ,je(je({},r),{},{id:"replace",onChange:function(e){return s("replace",e.target.checked)},children:"Replace all current questions"})),(0,t.jsx)(z.J1,{children:n.errors.replace})]})}})]})}),(0,t.jsx)(C.mz,{children:(0,t.jsxs)(_.hE,{mt:"4",children:[(0,t.jsx)(_.zx,{onClick:r,children:"Cancel"}),(0,t.jsx)(_.zx,{isLoading:P,variant:"solid",bgColor:"blue.400",color:"white",type:"submit",_hover:{bgColor:"blue.500"},children:"Create Questions"})]})})]})}})},_e=function(e){var r=e.isOpen,n=(e.onOpen,e.onClose);return(0,t.jsxs)(C.u_,{onClose:n,isOpen:r,isCentered:!0,children:[(0,t.jsx)(C.ZA,{}),(0,t.jsxs)(C.hz,{children:[(0,t.jsx)(C.xB,{children:"Create Question"}),(0,t.jsx)(C.ol,{}),(0,t.jsxs)(a.mQ,{isFitted:!0,children:[(0,t.jsxs)(a.td,{mx:"5",children:[(0,t.jsx)(a.OK,{children:"Upload One"}),(0,t.jsx)(a.OK,{children:"Upload Multiple"})]}),(0,t.jsxs)(a.nP,{children:[(0,t.jsx)(a.x4,{margin:"0",children:(0,t.jsx)(ae,{onClose:n})}),(0,t.jsx)(a.x4,{margin:"0",children:(0,t.jsx)(we,{onClose:n})})]})]})]})]})};function Ce(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function Pe(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};
1r%2?Ce(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ce(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var De=function(e){var r=(0,O.qY)(),n=r.isOpen,s=r.onOpen,i=r.onClose;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_.zx,Pe(Pe({bgColor:"blue.400",color:"white",onClick:s,leftIcon:(0,t.jsx)(m.dt,{}),variant:"solid",_hover:{bgColor:"blue.500"}},e),{},{children:"Add Question"})),(0,t.jsx)(_e,{isOpen:n,onOpen:s,onClose:i})]})},Se=n(98784),qe=function(){return(0,t.jsxs)(o.gC,{pt:"5",children:[(0,t.jsx)(Se.J,{}),(0,t.jsx)(o.X6,{pt:"2",size:"sm",children:"No questions for this exercise yet"}),(0,t.jsx)(o.xv,{pb:"2",fontSize:"sm",children:"Get started by adding a new question."}),(0,t.jsx)(De,{size:"sm"})]})};function Ze(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function ke(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Ze(Object(n),!0).forEach((function(r){(0,p.Z)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Ee=i.forwardRef((function(e,r){e.indeterminate;var n=(0,h.Z)(e,["indeterminate"]),s=i.useRef(),o=r||s;return(0,t.jsx)(j.XZ,ke({isChecked:n.checked,ref:o},n))})),Ae=function(){var e=(0,x.Z)(f().mark((function e(r){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D().get("".concat(S.M,"/api/questions/exercise/").concat(r,"/"));case 2:return n=e.sent,e.abrupt("return",n.data);case 4:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),Re=function(e){var r=e.exercise_slug,n=e.filter,c=e.isDictionExercise,a=i.useState([]),l=(0,s.Z)(a,2),d=l[0],f=l[1],x=(0,q.useQuery)(["dashboard",r],(function(){return Ae(r)}),{retry:3,retryDelay:0}),p=x.data,h=x.isLoading,j=x.isError;i.useEffect((function(){f(p||[])}),[p]),i.useEffect((function(){z(n)}),[n]);var O=i.useMemo((function(){var e=[{Header:"Subexercise",accessor:"subexercise_slug.subexercise_name"},{Header:"Question",accessor:"question"},{Header:"Translation",accessor:"translation"},{Header:"Date Created",accessor:"created_at",Cell:function(e){var r=e.cell;return new Date(r.value).toDateString()}},{Header:"",accessor:"editButton",Cell:function(e){var n=e.cell;return(0,t.jsx)(L,{row:n.row.original,exercise:r})},disableSortBy:!0}];return c&&e.splice(e.length-1,0,{Header:"Audio",accessor:"audio_url",Cell:function(e){var r=e.cell;return r.value?(0,t.jsx)("audio",{controls:"controls",src:r.value}):(0,t.jsx)(o.xv,{children:" No Audio File"})}}),[e,d]}),[d]),w=(0,s.Z)(O,2),_=w[0],C=w[1],P=(0,y.useTable)({columns:_,data:C},y.useGlobalFilter,y.useSortBy,y.useRowSelect,(function(e){e.visibleColumns.push((function(e){return[{id:"selection",Header:function(e){var r=e.getToggleAllRowsSelectedProps;return(0,t.jsx)(Ee,ke({},r()))},Cell:function(e){var r=e.row;return(0,t.jsx)(Ee,ke({},r.getToggleRowSelectedProps()))}}].concat((0,u.Z)(e))}))})),D=P.getTableProps,S=P.getTableBodyProps,Z=P.headerGroups,k=P.rows,A=P.prepareRow,R=P.selectedFlatRows,z=P.setGlobalFilter;return(0,t.jsxs)(o.gC,{spacing:"4",children:[R.length&&(0,t.jsxs)(g.bZ,{status:"warning",children:[(0,t.jsx)(g.zM,{}),(0,t.jsxs)(o.xv,{children:["You have selected ",R.length," ",R.length>1?"items":"item"," to be permanently deleted."," ",(0,t.jsx)(E,{exercise_slug:r,selectedItems:R})]})]}),(0,t.jsxs)(o.xu,{overflowX:"auto",w:"100%",children:[(0,t.jsxs)(b.iA,ke(ke({},D()),{},{children:[(0,t.jsx)(b.hr,{children:Z.map((function(e,r){return(0,t.jsx)(b.Tr,ke(ke({},e.getHeaderGroupProps()),{},{children:e.headers.map((function(e,r){return(0,t.jsxs)(b.Th,ke(ke({},e.getHeaderProps(e.getSortByToggleProps())),{},{isNumeric:e.isNumeric,children:[e.render("Header"),(0,t.jsx)(v.m$.span,{pl:"4",children:e.isSorted?e.isSortedDesc?(0,t.jsx)(m.AS,{"aria-label":"sorted descending"}):(0,t.jsx)(m.$l,{"aria-label":"sorted ascending"}):null})]}),r)}))}),r)}))}),!h&&C.length>0&&(0,t.jsx)(b.p3,ke(ke({},S()),{},{children:k.map((function(e,r){return A(e),(0,t.jsx)(b.Tr,ke(ke({},e.getRowProps()),{},{children:e.cells.map((function(e,r){return(0,t.jsx)(b.Td,ke(ke({},e.getCellProps()),{},{isNumeric:e.column.isNumeric,children:e.render("Cell")}),r)}))}),r)}))}))]})),j?(0,t.jsxs)(o.gC,{mt:"8",children:[(0,t.jsx)(o.X6,{size:"md",textAlign:"center",children:"Sorry, something went wrong."}),(0,t.jsx)(o.xv,{textAlign:"center",children:"Could not fetch questions data."})]}):h?(0,t.jsx)(se.Z,{}):p&&p.length<=0?(0,t.jsx)(qe,{}):null]})]})},ze=n(40078),Ie=n(14428),Ne=function(){(0,Ie.Z)("KeyKorea - Questions Dashboard");var e=(0,ze.a)("/").isLoading,r=i.useState(""),n=(0,s.Z)(r,2),u=n[0],d=n[1],f=(0,ne.N)(),x=f.data,p=f.isLoading,h=i.useState(0),j=(0,s.Z)(h,2),g=j[0],b=j[1];return e?(0,t.jsx)(se.Z,{}):(0,t.jsx)(o.W2,{pt:"8",maxW:"container.xl",children:(0,t.jsxs)(o.gC,{spacing:2,width:"100%",align:"stretch",children:[(0,t.jsxs)(o.xu,{display:{base:"",lg:"flex"},alignItems:{base:"",lg:"flex"}
1,justifyContent:{base:"",lg:"space-between"},children:[(0,t.jsx)(o.kC,{children:(0,t.jsxs)(o.xu,{children:[(0,t.jsx)(o.X6,{children:"Question Dashboard"}),(0,t.jsx)(o.xv,{children:"Add new questions or edit and delete existing questions"})]})}),(0,t.jsxs)(o.kC,{flexDir:{base:"column",md:"row"},children:[(0,t.jsx)(o.kC,{children:(0,t.jsxs)(c.BZ,{children:[(0,t.jsx)(c.Z8,{pointerEvents:"none",children:(0,t.jsx)(m.W1,{})}),(0,t.jsx)(c.II,{w:{base:"100%",md:"xs"},mr:{base:"0",md:"4"},mt:{base:"2",md:"0"},placeholder:"Search rows...",value:u,onChange:function(e){d(e.target.value)}})]})}),(0,t.jsx)(De,{mt:{base:"2",md:"0"}})]})]}),p||!x?(0,t.jsx)(se.Z,{}):(0,t.jsxs)(a.mQ,{isLazy:!0,variant:"enclosed",index:g,onChange:function(e){b(e),d("")},children:[(0,t.jsx)(l.Ph,{onChange:function(e){return b(1*e.target.value)},display:{base:"flex",lg:"none"},children:Object.entries(x).map((function(e,r){var n=(0,s.Z)(e,2),i=(n[0],n[1]);return(0,t.jsx)("option",{value:r,children:i.exercise_name},r)}))}),(0,t.jsx)(a.td,{display:{base:"none",lg:"flex"},children:Object.entries(x).map((function(e,r){var n=(0,s.Z)(e,2),i=(n[0],n[1]);return(0,t.jsx)(a.OK,{children:i.exercise_name},r)}))}),(0,t.jsx)(a.nP,{children:Object.entries(x).map((function(e,r){var n=(0,s.Z)(e,2),i=(n[0],n[1]);return(0,t.jsx)(a.x4,{paddingX:"0",children:(0,t.jsx)(Re,{exercise_slug:i.exercise_slug,isDictionExercise:i.allow_audio_files_in_questions,filter:u})},r)}))})]})]})})}},24030:function(e,r,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/questions",function(){return n(4755)}])},18685:function(){},20067:function(){},55382:function(){},72095:function(){},72061:function(){},61219:function(){}},function(e){e.O(0,[599,849,524,937,729,667,407,92,301,683,133,356,110,774,888,179],(function(){return r=24030,e(e.s=r);var r}));var r=e.O();_N_E=r}]);

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.