From cbd27811ad152cd5d542596f8e6bbfe096412a03 Mon Sep 17 00:00:00 2001 From: Aaliya-AOT Date: Thu, 11 Jul 2024 04:46:19 -0700 Subject: [PATCH] Updates --- assets/{index-TGwCzFkL.js => index-DG9ZGTn-.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-TGwCzFkL.js => index-DG9ZGTn-.js} (92%) diff --git a/assets/index-TGwCzFkL.js b/assets/index-DG9ZGTn-.js similarity index 92% rename from assets/index-TGwCzFkL.js rename to assets/index-DG9ZGTn-.js index 571e84a..f0dbb27 100644 --- a/assets/index-TGwCzFkL.js +++ b/assets/index-DG9ZGTn-.js @@ -69,4 +69,4 @@ Error generating stack: `+o.message+` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(l=>r.set(l)),r}static accessor(t){const r=(this[na]=this[na]={accessors:{}}).accessors,l=this.prototype;function o(i){const s=zn(i);r[s]||(_m(l,i),r[s]=!0)}return g.isArray(t)?t.forEach(o):o(t),this}}ge.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);g.reduceDescriptors(ge.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});g.freezeMethods(ge);function Ro(e,t){const n=this||gr,r=t||n,l=ge.from(r.headers);let o=r.data;return g.forEach(e,function(s){o=s.call(n,o,l.normalize(),t?t.status:void 0)}),l.normalize(),o}function Yf(e){return!!(e&&e.__CANCEL__)}function kn(e,t,n){O.call(this,e??"canceled",O.ERR_CANCELED,t,n),this.name="CanceledError"}g.inherits(kn,O,{__CANCEL__:!0});function qf(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new O("Request failed with status code "+n.status,[O.ERR_BAD_REQUEST,O.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Pm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Nm(e,t){e=e||10;const n=new Array(e),r=new Array(e);let l=0,o=0,i;return t=t!==void 0?t:1e3,function(u){const a=Date.now(),c=r[o];i||(i=a),n[l]=u,r[l]=a;let d=o,m=0;for(;d!==l;)m+=n[d++],d=d%e;if(l=(l+1)%e,l===o&&(o=(o+1)%e),a-ir)return l&&(clearTimeout(l),l=null),n=s,e.apply(null,arguments);l||(l=setTimeout(()=>(l=null,n=Date.now(),e.apply(null,arguments)),r-(s-n)))}}const Cl=(e,t,n=3)=>{let r=0;const l=Nm(50,250);return Rm(o=>{const i=o.loaded,s=o.lengthComputable?o.total:void 0,u=i-r,a=l(u),c=i<=s;r=i;const d={loaded:i,total:s,progress:s?i/s:void 0,bytes:u,rate:a||void 0,estimated:a&&s&&c?(s-i)/a:void 0,event:o,lengthComputable:s!=null};d[t?"download":"upload"]=!0,e(d)},n)},Tm=Be.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function l(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=l(window.location.href),function(i){const s=g.isString(i)?l(i):i;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}(),Lm=Be.hasStandardBrowserEnv?{write(e,t,n,r,l,o){const i=[e+"="+encodeURIComponent(t)];g.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),g.isString(r)&&i.push("path="+r),g.isString(l)&&i.push("domain="+l),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Om(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Gf(e,t){return e&&!Om(t)?jm(e,t):t}const ra=e=>e instanceof ge?{...e}:e;function Ht(e,t){t=t||{};const n={};function r(a,c,d){return g.isPlainObject(a)&&g.isPlainObject(c)?g.merge.call({caseless:d},a,c):g.isPlainObject(c)?g.merge({},c):g.isArray(c)?c.slice():c}function l(a,c,d){if(g.isUndefined(c)){if(!g.isUndefined(a))return r(void 0,a,d)}else return r(a,c,d)}function o(a,c){if(!g.isUndefined(c))return r(void 0,c)}function i(a,c){if(g.isUndefined(c)){if(!g.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function s(a,c,d){if(d in t)return r(a,c);if(d in e)return r(void 0,a)}const u={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:s,headers:(a,c)=>l(ra(a),ra(c),!0)};return g.forEach(Object.keys(Object.assign({},e,t)),function(c){const d=u[c]||l,m=d(e[c],t[c],c);g.isUndefined(m)&&d!==s||(n[c]=m)}),n}const bf=e=>{const t=Ht({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:l,xsrfCookieName:o,headers:i,auth:s}=t;t.headers=i=ge.from(i),t.url=Zf(Gf(t.baseURL,t.url),e.params,e.paramsSerializer),s&&i.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):"")));let u;if(g.isFormData(n)){if(Be.hasStandardBrowserEnv||Be.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((u=i.getContentType())!==!1){const[a,...c]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];i.setContentType([a||"multipart/form-data",...c].join("; "))}}if(Be.hasStandardBrowserEnv&&(r&&g.isFunction(r)&&(r=r(t)),r||r!==!1&&Tm(t.url))){const a=l&&o&&Lm.read(o);a&&i.set(l,a)}return t},Dm=typeof XMLHttpRequest<"u",zm=Dm&&function(e){return new Promise(function(n,r){const l=bf(e);let o=l.data;const i=ge.from(l.headers).normalize();let{responseType:s}=l,u;function a(){l.cancelToken&&l.cancelToken.unsubscribe(u),l.signal&&l.signal.removeEventListener("abort",u)}let c=new XMLHttpRequest;c.open(l.method.toUpperCase(),l.url,!0),c.timeout=l.timeout;function d(){if(!c)return;const w=ge.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),v={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:w,config:e,request:c};qf(function(p){n(p),a()},function(p){r(p),a()},v),c=null}"onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(d)},c.onabort=function(){c&&(r(new O("Request aborted",O.ECONNABORTED,l,c)),c=null)},c.onerror=function(){r(new O("Network Error",O.ERR_NETWORK,l,c)),c=null},c.ontimeout=function(){let y=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";const v=l.transitional||Jf;l.timeoutErrorMessage&&(y=l.timeoutErrorMessage),r(new O(y,v.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,l,c)),c=null},o===void 0&&i.setContentType(null),"setRequestHeader"in c&&g.forEach(i.toJSON(),function(y,v){c.setRequestHeader(v,y)}),g.isUndefined(l.withCredentials)||(c.withCredentials=!!l.withCredentials),s&&s!=="json"&&(c.responseType=l.responseType),typeof l.onDownloadProgress=="function"&&c.addEventListener("progress",Cl(l.onDownloadProgress,!0)),typeof l.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Cl(l.onUploadProgress)),(l.cancelToken||l.signal)&&(u=w=>{c&&(r(!w||w.type?new kn(null,e,c):w),c.abort(),c=null)},l.cancelToken&&l.cancelToken.subscribe(u),l.signal&&(l.signal.aborted?u():l.signal.addEventListener("abort",u)));const m=Pm(l.url);if(m&&Be.protocols.indexOf(m)===-1){r(new O("Unsupported protocol "+m+":",O.ERR_BAD_REQUEST,e));return}c.send(o||null)})},Fm=(e,t)=>{let n=new AbortController,r;const l=function(u){if(!r){r=!0,i();const a=u instanceof Error?u:this.reason;n.abort(a instanceof O?a:new kn(a instanceof Error?a.message:a))}};let o=t&&setTimeout(()=>{l(new O(`timeout ${t} of ms exceeded`,O.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u&&(u.removeEventListener?u.removeEventListener("abort",l):u.unsubscribe(l))}),e=null)};e.forEach(u=>u&&u.addEventListener&&u.addEventListener("abort",l));const{signal:s}=n;return s.unsubscribe=i,[s,()=>{o&&clearTimeout(o),o=null}]},Am=function*(e,t){let n=e.byteLength;if(!t||n{const o=Mm(e,t,l);let i=0;return new ReadableStream({type:"bytes",async pull(s){const{done:u,value:a}=await o.next();if(u){s.close(),r();return}let c=a.byteLength;n&&n(i+=c),s.enqueue(new Uint8Array(a))},cancel(s){return r(s),o.return()}},{highWaterMark:2})},oa=(e,t)=>{const n=e!=null;return r=>setTimeout(()=>t({lengthComputable:n,total:e,loaded:r}))},Xl=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ed=Xl&&typeof ReadableStream=="function",Ri=Xl&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Im=ed&&(()=>{let e=!1;const t=new Request(Be.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})(),ia=64*1024,Ti=ed&&!!(()=>{try{return g.isReadableStream(new Response("").body)}catch{}})(),_l={stream:Ti&&(e=>e.body)};Xl&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!_l[t]&&(_l[t]=g.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new O(`Response type '${t}' is not supported`,O.ERR_NOT_SUPPORT,r)})})})(new Response);const Um=async e=>{if(e==null)return 0;if(g.isBlob(e))return e.size;if(g.isSpecCompliantForm(e))return(await new Request(e).arrayBuffer()).byteLength;if(g.isArrayBufferView(e))return e.byteLength;if(g.isURLSearchParams(e)&&(e=e+""),g.isString(e))return(await Ri(e)).byteLength},Bm=async(e,t)=>{const n=g.toFiniteNumber(e.getContentLength());return n??Um(t)},Hm=Xl&&(async e=>{let{url:t,method:n,data:r,signal:l,cancelToken:o,timeout:i,onDownloadProgress:s,onUploadProgress:u,responseType:a,headers:c,withCredentials:d="same-origin",fetchOptions:m}=bf(e);a=a?(a+"").toLowerCase():"text";let[w,y]=l||o||i?Fm([l,o],i):[],v,k;const p=()=>{!v&&setTimeout(()=>{w&&w.unsubscribe()}),v=!0};let f;try{if(u&&Im&&n!=="get"&&n!=="head"&&(f=await Bm(c,r))!==0){let _=new Request(t,{method:"POST",body:r,duplex:"half"}),P;g.isFormData(r)&&(P=_.headers.get("content-type"))&&c.setContentType(P),_.body&&(r=la(_.body,ia,oa(f,Cl(u)),null,Ri))}g.isString(d)||(d=d?"cors":"omit"),k=new Request(t,{...m,signal:w,method:n.toUpperCase(),headers:c.normalize().toJSON(),body:r,duplex:"half",withCredentials:d});let h=await fetch(k);const S=Ti&&(a==="stream"||a==="response");if(Ti&&(s||S)){const _={};["status","statusText","headers"].forEach(T=>{_[T]=h[T]});const P=g.toFiniteNumber(h.headers.get("content-length"));h=new Response(la(h.body,ia,s&&oa(P,Cl(s,!0)),S&&p,Ri),_)}a=a||"text";let C=await _l[g.findKey(_l,a)||"text"](h,e);return!S&&p(),y&&y(),await new Promise((_,P)=>{qf(_,P,{data:C,headers:ge.from(h.headers),status:h.status,statusText:h.statusText,config:e,request:k})})}catch(h){throw p(),h&&h.name==="TypeError"&&/fetch/i.test(h.message)?Object.assign(new O("Network Error",O.ERR_NETWORK,e,k),{cause:h.cause||h}):O.from(h,h&&h.code,e,k)}}),Li={http:lm,xhr:zm,fetch:Hm};g.forEach(Li,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const sa=e=>`- ${e}`,Vm=e=>g.isFunction(e)||e===null||e===!1,td={getAdapter:e=>{e=g.isArray(e)?e:[e];const{length:t}=e;let n,r;const l={};for(let o=0;o`adapter ${s} `+(u===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since : `+o.map(sa).join(` `):" "+sa(o[0]):"as no adapter specified";throw new O("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:Li};function To(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new kn(null,e)}function ua(e){return To(e),e.headers=ge.from(e.headers),e.data=Ro.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),td.getAdapter(e.adapter||gr.adapter)(e).then(function(r){return To(e),r.data=Ro.call(e,e.transformResponse,r),r.headers=ge.from(r.headers),r},function(r){return Yf(r)||(To(e),r&&r.response&&(r.response.data=Ro.call(e,e.transformResponse,r.response),r.response.headers=ge.from(r.response.headers))),Promise.reject(r)})}const nd="1.7.2",Os={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Os[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const aa={};Os.transitional=function(t,n,r){function l(o,i){return"[Axios v"+nd+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,s)=>{if(t===!1)throw new O(l(i," has been removed"+(n?" in "+n:"")),O.ERR_DEPRECATED);return n&&!aa[i]&&(aa[i]=!0,console.warn(l(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,s):!0}};function $m(e,t,n){if(typeof e!="object")throw new O("options must be an object",O.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let l=r.length;for(;l-- >0;){const o=r[l],i=t[o];if(i){const s=e[o],u=s===void 0||i(s,o,e);if(u!==!0)throw new O("option "+o+" must be "+u,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O("Unknown option "+o,O.ERR_BAD_OPTION)}}const Oi={assertOptions:$m,validators:Os},ot=Oi.validators;class Ft{constructor(t){this.defaults=t,this.interceptors={request:new ta,response:new ta}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let l;Error.captureStackTrace?Error.captureStackTrace(l={}):l=new Error;const o=l.stack?l.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ht(this.defaults,n);const{transitional:r,paramsSerializer:l,headers:o}=n;r!==void 0&&Oi.assertOptions(r,{silentJSONParsing:ot.transitional(ot.boolean),forcedJSONParsing:ot.transitional(ot.boolean),clarifyTimeoutError:ot.transitional(ot.boolean)},!1),l!=null&&(g.isFunction(l)?n.paramsSerializer={serialize:l}:Oi.assertOptions(l,{encode:ot.function,serialize:ot.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&g.merge(o.common,o[n.method]);o&&g.forEach(["delete","get","head","post","put","patch","common"],y=>{delete o[y]}),n.headers=ge.concat(i,o);const s=[];let u=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(u=u&&v.synchronous,s.unshift(v.fulfilled,v.rejected))});const a=[];this.interceptors.response.forEach(function(v){a.push(v.fulfilled,v.rejected)});let c,d=0,m;if(!u){const y=[ua.bind(this),void 0];for(y.unshift.apply(y,s),y.push.apply(y,a),m=y.length,c=Promise.resolve(n);d{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const i=new Promise(s=>{r.subscribe(s),o=s}).then(l);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,s){r.reason||(r.reason=new kn(o,i,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new js(function(l){t=l}),cancel:t}}}function Wm(e){return function(n){return e.apply(null,n)}}function Qm(e){return g.isObject(e)&&e.isAxiosError===!0}const ji={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ji).forEach(([e,t])=>{ji[t]=e});function rd(e){const t=new Ft(e),n=Ff(Ft.prototype.request,t);return g.extend(n,Ft.prototype,t,{allOwnKeys:!0}),g.extend(n,t,null,{allOwnKeys:!0}),n.create=function(l){return rd(Ht(e,l))},n}const V=rd(gr);V.Axios=Ft;V.CanceledError=kn;V.CancelToken=js;V.isCancel=Yf;V.VERSION=nd;V.toFormData=Jl;V.AxiosError=O;V.Cancel=V.CanceledError;V.all=function(t){return Promise.all(t)};V.spread=Wm;V.isAxiosError=Qm;V.mergeConfig=Ht;V.AxiosHeaders=ge;V.formToJSON=e=>Xf(g.isHTMLForm(e)?new FormData(e):e);V.getAdapter=td.getAdapter;V.HttpStatusCode=ji;V.default=V;const xn="http://localhost:8080",Km=`${xn}/addTask`,Zm=`${xn}/displayTask`,Jm=`${xn}/editTask`,Xm=`${xn}/updateTaskStatus`,Ym=`${xn}/deleteTask`,qm=`${xn}/clearCompleted`,Gm=async e=>{console.log(e);const{title:t,description:n,duedate:r}=e;try{return await V.post(`${Km}`,{title:t,description:n,duedate:r})}catch(l){console.error(l)}},bm=()=>V.get(`${Zm}`),e1=async(e,t)=>{try{return await V.put(`${Xm}`,{id:e,taskstatus:t})}catch(n){console.log(n)}},t1=async e=>{console.log(e);const{id:t,title:n,description:r,duedate:l}=e;try{const o=await V.put(`${Jm}`,{id:t,title:n,description:r,duedate:l});return console.log("Inside task services: ",o),o}catch(o){console.error(o)}},n1=async e=>{try{return await V.delete(`${Ym}`,{data:{id:e}})}catch(t){console.error(t)}},r1=async()=>{try{const e=await V.delete(`${qm}`);return console.log("delete response : ",e),e}catch(e){console.error(e)}};function l1({onClose:e,modalType:t,task:n,setMode:r}){const[l,o]=L.useState(""),[i,s]=L.useState(""),[u,a]=L.useState("");L.useEffect(()=>{t==="Edit"&&n?(o(n.title),s(n.description),a(n.duedate)):(o(""),s(""),a(""))},[t,n]);const c=async d=>{d.preventDefault();const m={title:l,description:i,duedate:u};console.log(m);try{if(t==="Add"){const w=await Gm(m);r(!0),console.log(w)}else if(t==="Edit"){const w=await t1({...m,id:n.id});r(!0),console.log("edit inside modal",w)}}catch(w){console.log(w)}e()};return x.jsxs("div",{className:"modal-container",children:[x.jsxs("div",{className:"modal-header",children:[x.jsx("h2",{className:"modal-title",children:t==="Add"?"Add Task":"Edit Task"}),x.jsx("button",{id:"top-cancel-btn",onClick:e,children:x.jsx("img",{src:zf})})]}),x.jsx("form",{onSubmit:c,children:x.jsxs("div",{className:"modal-content",children:[x.jsxs("div",{className:"task-title-field",children:[x.jsx("label",{htmlFor:"task-name",className:"task-name-label",children:"Title *"}),x.jsx("input",{type:"text",placeholder:"eg. Create two ad banners",id:"task-name",value:l,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>o(d.target.value)})]}),x.jsxs("div",{className:"task-description-field",children:[x.jsx("label",{htmlFor:"task-detail",className:"task-detail-label",children:"Description"}),x.jsx("textarea",{id:"task-detail",placeholder:"Add your task description.",value:i,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>s(d.target.value)})]}),x.jsxs("div",{className:"task-date-field",children:[x.jsx("label",{htmlFor:"task-date",className:"task-date-label",children:"Due Date"}),x.jsx("input",{id:"task-date",type:"date",value:u,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>a(d.target.value)})]}),x.jsxs("div",{className:"task-btn-field",children:[x.jsx("button",{id:"cancel-btn",onClick:e,children:"Cancel"}),x.jsx("button",{type:"submit",id:"add-task-btn",children:t==="Add"?"Add Task":"Update Task"})]})]})})]})}const o1="data:image/svg+xml,%3csvg%20width='11'%20height='12'%20viewBox='0%200%2011%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='5.5'%20cy='6'%20r='5.5'%20fill='%23EBB705'/%3e%3c/svg%3e",i1="data:image/svg+xml,%3csvg%20width='11'%20height='12'%20viewBox='0%200%2011%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='5.5'%20cy='6'%20r='5.5'%20fill='%2326AD13'/%3e%3c/svg%3e",s1="data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10.8711%206.01927L11.7569%206.90519L3.03369%2015.6296H2.14789V14.7437L10.8711%206.01927ZM14.3373%200.222229C14.0966%200.222229%2013.8463%200.318525%2013.6633%200.501488L11.9013%202.26371L15.512%205.87482L17.2739%204.1126C17.6494%203.73704%2017.6494%203.13038%2017.2739%202.75482L15.0209%200.501488C14.8283%200.308896%2014.5876%200.222229%2014.3373%200.222229ZM10.8711%203.29408L0.222229%2013.9444V17.5556H3.83284L14.4817%206.90519L10.8711%203.29408Z'%20fill='%237E7E7F'/%3e%3crect%20x='1.55554'%20y='15.1129'%20width='13.5159'%20height='1.63043'%20transform='rotate(-45%201.55554%2015.1129)'%20fill='%237E7E7F'/%3e%3c/svg%3e",u1="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.77796%200.095928C7.75264%200.581004%207.74014%201.78805%208.75921%202.26185C8.97803%202.36338%209.15933%202.36902%2011.979%202.36902C14.7549%202.36902%2014.9862%202.35774%2015.2175%202.26185C16.2428%201.83318%2016.2553%200.581004%2015.2363%200.107209C15.0174%200.00568104%2014.8361%204.07696e-05%2011.9852%204.07696e-05C9.3594%200.00568104%208.94052%200.0169621%208.77796%200.095928Z'%20fill='%23D04444'/%3e%3cpath%20d='M2.40076%203.60423C0.775245%203.63807%200.706474%203.65499%200.356363%203.98778C-0.118788%204.43901%20-0.118788%205.14971%200.356363%205.60094C0.675214%205.90552%200.831513%205.95065%201.77556%205.97885L2.65084%206.00705L2.6821%2013.6216L2.71336%2021.2362L2.87591%2021.6141C3.33856%2022.6858%204.17007%2023.436%205.35795%2023.8533L5.77683%2024H11.935H18.0932L18.5309%2023.8759C19.7062%2023.5375%2020.6378%2022.7253%2021.1192%2021.6141L21.2817%2021.2362L21.313%2013.6216L21.3443%206.00705L22.2195%205.97885C23.1636%205.95065%2023.3199%205.90552%2023.6387%205.60094C24.2577%205.01434%2024.0576%204.10623%2023.2199%203.70576L22.9698%203.58731L13.4355%203.58167C8.19009%203.57603%203.22602%203.58731%202.40076%203.60423ZM18.6872%2013.2606C18.6872%2018.6021%2018.6684%2020.5481%2018.6121%2020.7455C18.5121%2021.1065%2018.0745%2021.5013%2017.6743%2021.5915C17.2555%2021.6874%206.73963%2021.6874%206.32075%2021.5915C5.92062%2021.5013%205.48299%2021.1065%205.38295%2020.7455C5.32669%2020.5481%205.30793%2018.6021%205.30793%2013.2606V6.03525H11.9975H18.6872V13.2606Z'%20fill='%23D04444'/%3e%3cpath%20d='M8.88382%208.46628C8.59622%208.54525%208.14608%208.96264%208.0648%209.22774C8.02104%209.37439%207.99603%2010.7281%207.99603%2013.2606V17.0679L8.15858%2017.3669C8.57747%2018.1227%209.68407%2018.2581%2010.303%2017.6207C10.4781%2017.4402%2010.5719%2017.2766%2010.6219%2017.0736C10.6719%2016.8705%2010.6844%2015.6522%2010.6719%2013.0294L10.6531%209.27851L10.4781%209.01341C10.1717%208.53961%209.47776%208.30271%208.88382%208.46628Z'%20fill='%23D04444'/%3e%3cpath%20d='M14.0544%208.56248C13.8105%208.67529%2013.6667%208.79373%2013.5292%208.99679L13.3416%209.26753L13.3229%2013.0241C13.3104%2015.7484%2013.3229%2016.8652%2013.3729%2017.0852C13.4729%2017.5025%2013.8981%2017.8917%2014.3482%2017.9876C14.9609%2018.123%2015.5548%2017.8748%2015.8362%2017.3672L15.9987%2017.0682V13.2666C15.9987%2010.4182%2015.98%209.4029%2015.9237%209.22805C15.8237%208.9291%2015.4173%208.56248%2015.0859%208.47223C14.6858%208.36506%2014.417%208.38762%2014.0544%208.56248Z'%20fill='%23D04444'/%3e%3c/svg%3e",a1="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16%202H15V0H13V2H5V0H3V2H2C0.89%202%200.00999999%202.9%200.00999999%204L0%2018C0%2019.1%200.89%2020%202%2020H16C17.1%2020%2018%2019.1%2018%2018V4C18%202.9%2017.1%202%2016%202ZM16%2018H2V8H16V18ZM16%206H2V4H16V6ZM6%2012H4V10H6V12ZM10%2012H8V10H10V12ZM14%2012H12V10H14V12ZM6%2016H4V14H6V16ZM10%2016H8V14H10V16ZM14%2016H12V14H14V16Z'%20fill='%23667085'/%3e%3c/svg%3e",c1="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3025_2857)'%3e%3cpath%20d='M19%204H18V2H16V4H8V2H6V4H5C3.89%204%203.01%204.9%203.01%206L3%2020C3%2021.1%203.89%2022%205%2022H19C20.1%2022%2021%2021.1%2021%2020V6C21%204.9%2020.1%204%2019%204ZM19%2020H5V10H19V20ZM19%208H5V6H19V8ZM9%2014H7V12H9V14ZM13%2014H11V12H13V14ZM17%2014H15V12H17V14ZM9%2018H7V16H9V18ZM13%2018H11V16H13V18ZM17%2018H15V16H17V18Z'%20fill='%23C03503'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3025_2857'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function ca({task:e,toggleStatus:t,editModal:n,deleteToggleModal:r}){const l=()=>{t(e.id,!e.taskstatus)};function o(a){const c=new Date(a),d=c.getDate(),w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()],y=c.getFullYear();return`${d} ${w} ${y}`}const i={backgroundColor:"#C035030F",padding:"2px 8px",borderRadius:"4px",width:"fit-content"},s={color:"#C03503"},u=new Date(e.duedate)n(e),children:x.jsx("img",{src:s1})}),x.jsx("button",{id:"delete-btn",onClick:()=>r(e),children:x.jsx("img",{src:u1})})]})]}),x.jsx("p",{className:"task-description",children:e==null?void 0:e.description}),x.jsxs("div",{className:"task-due-date-container",style:u?i:{},children:[x.jsx("img",{src:u?c1:a1}),x.jsxs("p",{className:"task-due-date",style:u?s:{},children:["by ",o(e==null?void 0:e.duedate)]})]})]})]})}function f1({tasks:e,toggleStatus:t,searchText:n,sortOption:r,editModal:l,deleteToggleModal:o,clearCompletedTask:i}){const s=e.filter(c=>c.title.toLowerCase().includes(n.toLowerCase())).sort((c,d)=>r==="Newest First"?new Date(d.duedate)-new Date(c.duedate):new Date(c.duedate)-new Date(d.duedate)),u=s.filter(c=>!c.taskstatus),a=s.filter(c=>c.taskstatus);return x.jsxs("div",{className:"main-task-container",children:[x.jsxs("div",{className:"active-list-container",children:[x.jsx("span",{className:"task-heading",children:"Active Tasks"}),u.map(c=>x.jsx(ca,{task:c,toggleStatus:t,editModal:l,deleteToggleModal:o},c.id))]}),x.jsxs("div",{className:"completed-list-container",children:[x.jsxs("div",{className:"completed-title",children:[x.jsx("span",{className:"task-heading",children:"Completed Tasks"}),x.jsx("button",{id:"clear-completed-btn",onClick:i,children:"Clear Completed Tasks"})]}),a.map(c=>x.jsx(ca,{task:c,toggleStatus:t,editModal:l,deleteToggleModal:o},c.id))]})]})}const d1="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3020_1245)'%3e%3cpath%20d='M19.7656%2018.5523L14.2047%2012.939C15.4652%2011.3509%2016.069%209.34003%2015.8919%207.32021C15.7148%205.3004%2014.7702%203.42529%2013.2526%202.08075C11.735%200.736206%209.75969%200.0245126%207.73325%200.0921182C5.70681%200.159724%203.78336%201.00149%202.35871%202.44419C0.934053%203.88689%200.11657%205.82078%200.0744788%207.84791C0.0323873%209.87504%200.768889%2011.8412%202.13243%2013.3418C3.49597%2014.8424%205.38282%2015.7633%207.4047%2015.9149C9.42659%2016.0666%2011.4297%2015.4375%2013.0018%2014.1571L18.5256%2019.7342C18.682%2019.8978%2018.8967%2019.993%2019.123%2019.9989C19.3492%2020.0047%2019.5686%2019.9209%2019.7332%2019.7657C19.8152%2019.6882%2019.881%2019.5953%2019.927%2019.4924C19.973%2019.3894%2019.9982%2019.2784%2020.0012%2019.1657C20.0042%2019.053%2019.9849%2018.9408%2019.9445%2018.8356C19.9041%2018.7303%2019.8433%2018.6341%2019.7656%2018.5523ZM7.97617%2014.2257C6.52836%2014.2257%205.12536%2013.7236%204.00621%2012.8051C2.88706%2011.8866%202.121%2010.6085%201.83855%209.18852C1.5561%207.76854%201.77473%206.29455%202.45721%205.01769C3.13968%203.74083%204.24376%202.74011%205.58135%202.18602C6.91893%201.63193%208.40725%201.55877%209.79272%201.97898C11.1782%202.3992%2012.3751%203.2868%2013.1795%204.49056C13.984%205.69432%2014.3461%207.13976%2014.2043%208.5806C14.0625%2010.0214%2013.4255%2011.3685%2012.4019%2012.3924C11.822%2012.9754%2011.1323%2013.4376%2010.3726%2013.7523C9.61295%2014.067%208.79842%2014.2279%207.97617%2014.2257Z'%20fill='%23939393'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3020_1245'%3e%3crect%20width='19.9951'%20height='19.9999'%20fill='white'%20transform='translate(0.00488281%206.10352e-05)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function p1({onSearch:e,onSort:t}){const n=l=>{e(l.target.value)},r=l=>{t(l.target.value)};return x.jsxs("div",{className:"task-filter",children:[x.jsxs("div",{className:"search-task",children:[x.jsx("input",{type:"text",id:"search-bar",placeholder:"Search by task name",onChange:n}),x.jsx("img",{src:d1,alt:"search-icon"})]}),x.jsxs("div",{className:"sort-task",children:[x.jsx("span",{className:"sort-label",children:"Sort by :"}),x.jsx("div",{className:"sort-dropdown-container",children:x.jsxs("select",{className:"sort-dropdown",id:"sort-dropdown",onChange:r,children:[x.jsx("option",{value:"Newest First",children:"Newest First"}),x.jsx("option",{value:"Oldest First",children:"Oldest First"})]})})]})]})}function h1({onClose:e,onDelete:t,task:n}){return x.jsxs("div",{className:"delete-modal-container",children:[x.jsx("div",{className:"delete-modal-close",children:x.jsx("button",{id:"close-btn",onClick:e,children:x.jsx("img",{src:zf})})}),x.jsxs("div",{className:"delete-modal-content",children:[x.jsx("div",{className:"delete-modal-title",children:x.jsx("h3",{className:"delete-title",children:"Delete Task?"})}),x.jsx("div",{className:"delete-modal-body",children:x.jsx("p",{className:"delete-message",children:"Are you sure you want to delete this task?"})}),x.jsxs("div",{className:"delete-modal-footer",children:[x.jsx("button",{id:"delete-modal-cancel",onClick:e,children:"Cancel"}),x.jsx("button",{id:"delete-modal-confirm",onClick:()=>t(n.id),children:"Delete"})]})]})]})}function m1(){const[e,t]=L.useState(!1),[n,r]=L.useState([]),[l,o]=L.useState(!1),[i,s]=L.useState(!1),[u,a]=L.useState(""),[c,d]=L.useState("Newest First"),[m,w]=L.useState("Add"),[y,v]=L.useState(null),k=()=>{o(!l)},p=D=>{v(D),s(!i)},f=()=>{w("Add"),v(null),k()},h=D=>{w("Edit"),v(D),k()};L.useEffect(()=>{bm().then(D=>{r(D.data)}).catch(D=>{console.log(D)}),t(!1)},[e]);const S=async(D,z)=>{try{await e1(D,z),t(!0)}catch(Se){console.log(Se)}},C=D=>{a(D)},_=D=>{d(D)},P=async D=>{try{await n1(D),t(!0),p()}catch(z){console.error("Failed to delete task:",z)}},T=async()=>{try{await r1(),t(!0)}catch(D){console.log(D)}};return x.jsxs("div",{className:"main-container",children:[x.jsx(wh,{toggleModal:f}),x.jsx(p1,{onSearch:C,onSort:_}),x.jsx(f1,{searchText:u,tasks:n,toggleStatus:S,sortOption:c,editModal:h,deleteToggleModal:p,clearCompletedTask:T}),l&&x.jsx(l1,{onClose:k,modalType:m,task:y,setMode:t}),i&&x.jsx(h1,{onClose:p,task:y,onDelete:P})]})}function y1(){return x.jsx(gh,{basename:"/react-todo-v2",children:x.jsx(mh,{children:x.jsx(Df,{path:"/",element:x.jsx(m1,{})})})})}Lo.createRoot(document.getElementById("root")).render(x.jsx(Ea.StrictMode,{children:x.jsx(y1,{})})); +`+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ht(this.defaults,n);const{transitional:r,paramsSerializer:l,headers:o}=n;r!==void 0&&Oi.assertOptions(r,{silentJSONParsing:ot.transitional(ot.boolean),forcedJSONParsing:ot.transitional(ot.boolean),clarifyTimeoutError:ot.transitional(ot.boolean)},!1),l!=null&&(g.isFunction(l)?n.paramsSerializer={serialize:l}:Oi.assertOptions(l,{encode:ot.function,serialize:ot.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&g.merge(o.common,o[n.method]);o&&g.forEach(["delete","get","head","post","put","patch","common"],y=>{delete o[y]}),n.headers=ge.concat(i,o);const s=[];let u=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(u=u&&v.synchronous,s.unshift(v.fulfilled,v.rejected))});const a=[];this.interceptors.response.forEach(function(v){a.push(v.fulfilled,v.rejected)});let c,d=0,m;if(!u){const y=[ua.bind(this),void 0];for(y.unshift.apply(y,s),y.push.apply(y,a),m=y.length,c=Promise.resolve(n);d{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](l);r._listeners=null}),this.promise.then=l=>{let o;const i=new Promise(s=>{r.subscribe(s),o=s}).then(l);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,s){r.reason||(r.reason=new kn(o,i,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new js(function(l){t=l}),cancel:t}}}function Wm(e){return function(n){return e.apply(null,n)}}function Qm(e){return g.isObject(e)&&e.isAxiosError===!0}const ji={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ji).forEach(([e,t])=>{ji[t]=e});function rd(e){const t=new Ft(e),n=Ff(Ft.prototype.request,t);return g.extend(n,Ft.prototype,t,{allOwnKeys:!0}),g.extend(n,t,null,{allOwnKeys:!0}),n.create=function(l){return rd(Ht(e,l))},n}const V=rd(gr);V.Axios=Ft;V.CanceledError=kn;V.CancelToken=js;V.isCancel=Yf;V.VERSION=nd;V.toFormData=Jl;V.AxiosError=O;V.Cancel=V.CanceledError;V.all=function(t){return Promise.all(t)};V.spread=Wm;V.isAxiosError=Qm;V.mergeConfig=Ht;V.AxiosHeaders=ge;V.formToJSON=e=>Xf(g.isHTMLForm(e)?new FormData(e):e);V.getAdapter=td.getAdapter;V.HttpStatusCode=ji;V.default=V;const xn="https://todo-backend-3gxa.onrender.com",Km=`${xn}/addTask`,Zm=`${xn}/displayTask`,Jm=`${xn}/editTask`,Xm=`${xn}/updateTaskStatus`,Ym=`${xn}/deleteTask`,qm=`${xn}/clearCompleted`,Gm=async e=>{console.log(e);const{title:t,description:n,duedate:r}=e;try{return await V.post(`${Km}`,{title:t,description:n,duedate:r})}catch(l){console.error(l)}},bm=()=>V.get(`${Zm}`),e1=async(e,t)=>{try{return await V.put(`${Xm}`,{id:e,taskstatus:t})}catch(n){console.log(n)}},t1=async e=>{console.log(e);const{id:t,title:n,description:r,duedate:l}=e;try{const o=await V.put(`${Jm}`,{id:t,title:n,description:r,duedate:l});return console.log("Inside task services: ",o),o}catch(o){console.error(o)}},n1=async e=>{try{return await V.delete(`${Ym}`,{data:{id:e}})}catch(t){console.error(t)}},r1=async()=>{try{const e=await V.delete(`${qm}`);return console.log("delete response : ",e),e}catch(e){console.error(e)}};function l1({onClose:e,modalType:t,task:n,setMode:r}){const[l,o]=L.useState(""),[i,s]=L.useState(""),[u,a]=L.useState("");L.useEffect(()=>{t==="Edit"&&n?(o(n.title),s(n.description),a(n.duedate)):(o(""),s(""),a(""))},[t,n]);const c=async d=>{d.preventDefault();const m={title:l,description:i,duedate:u};console.log(m);try{if(t==="Add"){const w=await Gm(m);r(!0),console.log(w)}else if(t==="Edit"){const w=await t1({...m,id:n.id});r(!0),console.log("edit inside modal",w)}}catch(w){console.log(w)}e()};return x.jsxs("div",{className:"modal-container",children:[x.jsxs("div",{className:"modal-header",children:[x.jsx("h2",{className:"modal-title",children:t==="Add"?"Add Task":"Edit Task"}),x.jsx("button",{id:"top-cancel-btn",onClick:e,children:x.jsx("img",{src:zf})})]}),x.jsx("form",{onSubmit:c,children:x.jsxs("div",{className:"modal-content",children:[x.jsxs("div",{className:"task-title-field",children:[x.jsx("label",{htmlFor:"task-name",className:"task-name-label",children:"Title *"}),x.jsx("input",{type:"text",placeholder:"eg. Create two ad banners",id:"task-name",value:l,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>o(d.target.value)})]}),x.jsxs("div",{className:"task-description-field",children:[x.jsx("label",{htmlFor:"task-detail",className:"task-detail-label",children:"Description"}),x.jsx("textarea",{id:"task-detail",placeholder:"Add your task description.",value:i,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>s(d.target.value)})]}),x.jsxs("div",{className:"task-date-field",children:[x.jsx("label",{htmlFor:"task-date",className:"task-date-label",children:"Due Date"}),x.jsx("input",{id:"task-date",type:"date",value:u,style:t==="Add"?{color:"#A3A3A3"}:{color:"#282829"},onChange:d=>a(d.target.value)})]}),x.jsxs("div",{className:"task-btn-field",children:[x.jsx("button",{id:"cancel-btn",onClick:e,children:"Cancel"}),x.jsx("button",{type:"submit",id:"add-task-btn",children:t==="Add"?"Add Task":"Update Task"})]})]})})]})}const o1="data:image/svg+xml,%3csvg%20width='11'%20height='12'%20viewBox='0%200%2011%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='5.5'%20cy='6'%20r='5.5'%20fill='%23EBB705'/%3e%3c/svg%3e",i1="data:image/svg+xml,%3csvg%20width='11'%20height='12'%20viewBox='0%200%2011%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='5.5'%20cy='6'%20r='5.5'%20fill='%2326AD13'/%3e%3c/svg%3e",s1="data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10.8711%206.01927L11.7569%206.90519L3.03369%2015.6296H2.14789V14.7437L10.8711%206.01927ZM14.3373%200.222229C14.0966%200.222229%2013.8463%200.318525%2013.6633%200.501488L11.9013%202.26371L15.512%205.87482L17.2739%204.1126C17.6494%203.73704%2017.6494%203.13038%2017.2739%202.75482L15.0209%200.501488C14.8283%200.308896%2014.5876%200.222229%2014.3373%200.222229ZM10.8711%203.29408L0.222229%2013.9444V17.5556H3.83284L14.4817%206.90519L10.8711%203.29408Z'%20fill='%237E7E7F'/%3e%3crect%20x='1.55554'%20y='15.1129'%20width='13.5159'%20height='1.63043'%20transform='rotate(-45%201.55554%2015.1129)'%20fill='%237E7E7F'/%3e%3c/svg%3e",u1="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.77796%200.095928C7.75264%200.581004%207.74014%201.78805%208.75921%202.26185C8.97803%202.36338%209.15933%202.36902%2011.979%202.36902C14.7549%202.36902%2014.9862%202.35774%2015.2175%202.26185C16.2428%201.83318%2016.2553%200.581004%2015.2363%200.107209C15.0174%200.00568104%2014.8361%204.07696e-05%2011.9852%204.07696e-05C9.3594%200.00568104%208.94052%200.0169621%208.77796%200.095928Z'%20fill='%23D04444'/%3e%3cpath%20d='M2.40076%203.60423C0.775245%203.63807%200.706474%203.65499%200.356363%203.98778C-0.118788%204.43901%20-0.118788%205.14971%200.356363%205.60094C0.675214%205.90552%200.831513%205.95065%201.77556%205.97885L2.65084%206.00705L2.6821%2013.6216L2.71336%2021.2362L2.87591%2021.6141C3.33856%2022.6858%204.17007%2023.436%205.35795%2023.8533L5.77683%2024H11.935H18.0932L18.5309%2023.8759C19.7062%2023.5375%2020.6378%2022.7253%2021.1192%2021.6141L21.2817%2021.2362L21.313%2013.6216L21.3443%206.00705L22.2195%205.97885C23.1636%205.95065%2023.3199%205.90552%2023.6387%205.60094C24.2577%205.01434%2024.0576%204.10623%2023.2199%203.70576L22.9698%203.58731L13.4355%203.58167C8.19009%203.57603%203.22602%203.58731%202.40076%203.60423ZM18.6872%2013.2606C18.6872%2018.6021%2018.6684%2020.5481%2018.6121%2020.7455C18.5121%2021.1065%2018.0745%2021.5013%2017.6743%2021.5915C17.2555%2021.6874%206.73963%2021.6874%206.32075%2021.5915C5.92062%2021.5013%205.48299%2021.1065%205.38295%2020.7455C5.32669%2020.5481%205.30793%2018.6021%205.30793%2013.2606V6.03525H11.9975H18.6872V13.2606Z'%20fill='%23D04444'/%3e%3cpath%20d='M8.88382%208.46628C8.59622%208.54525%208.14608%208.96264%208.0648%209.22774C8.02104%209.37439%207.99603%2010.7281%207.99603%2013.2606V17.0679L8.15858%2017.3669C8.57747%2018.1227%209.68407%2018.2581%2010.303%2017.6207C10.4781%2017.4402%2010.5719%2017.2766%2010.6219%2017.0736C10.6719%2016.8705%2010.6844%2015.6522%2010.6719%2013.0294L10.6531%209.27851L10.4781%209.01341C10.1717%208.53961%209.47776%208.30271%208.88382%208.46628Z'%20fill='%23D04444'/%3e%3cpath%20d='M14.0544%208.56248C13.8105%208.67529%2013.6667%208.79373%2013.5292%208.99679L13.3416%209.26753L13.3229%2013.0241C13.3104%2015.7484%2013.3229%2016.8652%2013.3729%2017.0852C13.4729%2017.5025%2013.8981%2017.8917%2014.3482%2017.9876C14.9609%2018.123%2015.5548%2017.8748%2015.8362%2017.3672L15.9987%2017.0682V13.2666C15.9987%2010.4182%2015.98%209.4029%2015.9237%209.22805C15.8237%208.9291%2015.4173%208.56248%2015.0859%208.47223C14.6858%208.36506%2014.417%208.38762%2014.0544%208.56248Z'%20fill='%23D04444'/%3e%3c/svg%3e",a1="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16%202H15V0H13V2H5V0H3V2H2C0.89%202%200.00999999%202.9%200.00999999%204L0%2018C0%2019.1%200.89%2020%202%2020H16C17.1%2020%2018%2019.1%2018%2018V4C18%202.9%2017.1%202%2016%202ZM16%2018H2V8H16V18ZM16%206H2V4H16V6ZM6%2012H4V10H6V12ZM10%2012H8V10H10V12ZM14%2012H12V10H14V12ZM6%2016H4V14H6V16ZM10%2016H8V14H10V16ZM14%2016H12V14H14V16Z'%20fill='%23667085'/%3e%3c/svg%3e",c1="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3025_2857)'%3e%3cpath%20d='M19%204H18V2H16V4H8V2H6V4H5C3.89%204%203.01%204.9%203.01%206L3%2020C3%2021.1%203.89%2022%205%2022H19C20.1%2022%2021%2021.1%2021%2020V6C21%204.9%2020.1%204%2019%204ZM19%2020H5V10H19V20ZM19%208H5V6H19V8ZM9%2014H7V12H9V14ZM13%2014H11V12H13V14ZM17%2014H15V12H17V14ZM9%2018H7V16H9V18ZM13%2018H11V16H13V18ZM17%2018H15V16H17V18Z'%20fill='%23C03503'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3025_2857'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function ca({task:e,toggleStatus:t,editModal:n,deleteToggleModal:r}){const l=()=>{t(e.id,!e.taskstatus)};function o(a){const c=new Date(a),d=c.getDate(),w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()],y=c.getFullYear();return`${d} ${w} ${y}`}const i={backgroundColor:"#C035030F",padding:"2px 8px",borderRadius:"4px",width:"fit-content"},s={color:"#C03503"},u=new Date(e.duedate)n(e),children:x.jsx("img",{src:s1})}),x.jsx("button",{id:"delete-btn",onClick:()=>r(e),children:x.jsx("img",{src:u1})})]})]}),x.jsx("p",{className:"task-description",children:e==null?void 0:e.description}),x.jsxs("div",{className:"task-due-date-container",style:u?i:{},children:[x.jsx("img",{src:u?c1:a1}),x.jsxs("p",{className:"task-due-date",style:u?s:{},children:["by ",o(e==null?void 0:e.duedate)]})]})]})]})}function f1({tasks:e,toggleStatus:t,searchText:n,sortOption:r,editModal:l,deleteToggleModal:o,clearCompletedTask:i}){const s=e.filter(c=>c.title.toLowerCase().includes(n.toLowerCase())).sort((c,d)=>r==="Newest First"?new Date(d.duedate)-new Date(c.duedate):new Date(c.duedate)-new Date(d.duedate)),u=s.filter(c=>!c.taskstatus),a=s.filter(c=>c.taskstatus);return x.jsxs("div",{className:"main-task-container",children:[x.jsxs("div",{className:"active-list-container",children:[x.jsx("span",{className:"task-heading",children:"Active Tasks"}),u.map(c=>x.jsx(ca,{task:c,toggleStatus:t,editModal:l,deleteToggleModal:o},c.id))]}),x.jsxs("div",{className:"completed-list-container",children:[x.jsxs("div",{className:"completed-title",children:[x.jsx("span",{className:"task-heading",children:"Completed Tasks"}),x.jsx("button",{id:"clear-completed-btn",onClick:i,children:"Clear Completed Tasks"})]}),a.map(c=>x.jsx(ca,{task:c,toggleStatus:t,editModal:l,deleteToggleModal:o},c.id))]})]})}const d1="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3020_1245)'%3e%3cpath%20d='M19.7656%2018.5523L14.2047%2012.939C15.4652%2011.3509%2016.069%209.34003%2015.8919%207.32021C15.7148%205.3004%2014.7702%203.42529%2013.2526%202.08075C11.735%200.736206%209.75969%200.0245126%207.73325%200.0921182C5.70681%200.159724%203.78336%201.00149%202.35871%202.44419C0.934053%203.88689%200.11657%205.82078%200.0744788%207.84791C0.0323873%209.87504%200.768889%2011.8412%202.13243%2013.3418C3.49597%2014.8424%205.38282%2015.7633%207.4047%2015.9149C9.42659%2016.0666%2011.4297%2015.4375%2013.0018%2014.1571L18.5256%2019.7342C18.682%2019.8978%2018.8967%2019.993%2019.123%2019.9989C19.3492%2020.0047%2019.5686%2019.9209%2019.7332%2019.7657C19.8152%2019.6882%2019.881%2019.5953%2019.927%2019.4924C19.973%2019.3894%2019.9982%2019.2784%2020.0012%2019.1657C20.0042%2019.053%2019.9849%2018.9408%2019.9445%2018.8356C19.9041%2018.7303%2019.8433%2018.6341%2019.7656%2018.5523ZM7.97617%2014.2257C6.52836%2014.2257%205.12536%2013.7236%204.00621%2012.8051C2.88706%2011.8866%202.121%2010.6085%201.83855%209.18852C1.5561%207.76854%201.77473%206.29455%202.45721%205.01769C3.13968%203.74083%204.24376%202.74011%205.58135%202.18602C6.91893%201.63193%208.40725%201.55877%209.79272%201.97898C11.1782%202.3992%2012.3751%203.2868%2013.1795%204.49056C13.984%205.69432%2014.3461%207.13976%2014.2043%208.5806C14.0625%2010.0214%2013.4255%2011.3685%2012.4019%2012.3924C11.822%2012.9754%2011.1323%2013.4376%2010.3726%2013.7523C9.61295%2014.067%208.79842%2014.2279%207.97617%2014.2257Z'%20fill='%23939393'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3020_1245'%3e%3crect%20width='19.9951'%20height='19.9999'%20fill='white'%20transform='translate(0.00488281%206.10352e-05)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function p1({onSearch:e,onSort:t}){const n=l=>{e(l.target.value)},r=l=>{t(l.target.value)};return x.jsxs("div",{className:"task-filter",children:[x.jsxs("div",{className:"search-task",children:[x.jsx("input",{type:"text",id:"search-bar",placeholder:"Search by task name",onChange:n}),x.jsx("img",{src:d1,alt:"search-icon"})]}),x.jsxs("div",{className:"sort-task",children:[x.jsx("span",{className:"sort-label",children:"Sort by :"}),x.jsx("div",{className:"sort-dropdown-container",children:x.jsxs("select",{className:"sort-dropdown",id:"sort-dropdown",onChange:r,children:[x.jsx("option",{value:"Newest First",children:"Newest First"}),x.jsx("option",{value:"Oldest First",children:"Oldest First"})]})})]})]})}function h1({onClose:e,onDelete:t,task:n}){return x.jsxs("div",{className:"delete-modal-container",children:[x.jsx("div",{className:"delete-modal-close",children:x.jsx("button",{id:"close-btn",onClick:e,children:x.jsx("img",{src:zf})})}),x.jsxs("div",{className:"delete-modal-content",children:[x.jsx("div",{className:"delete-modal-title",children:x.jsx("h3",{className:"delete-title",children:"Delete Task?"})}),x.jsx("div",{className:"delete-modal-body",children:x.jsx("p",{className:"delete-message",children:"Are you sure you want to delete this task?"})}),x.jsxs("div",{className:"delete-modal-footer",children:[x.jsx("button",{id:"delete-modal-cancel",onClick:e,children:"Cancel"}),x.jsx("button",{id:"delete-modal-confirm",onClick:()=>t(n.id),children:"Delete"})]})]})]})}function m1(){const[e,t]=L.useState(!1),[n,r]=L.useState([]),[l,o]=L.useState(!1),[i,s]=L.useState(!1),[u,a]=L.useState(""),[c,d]=L.useState("Newest First"),[m,w]=L.useState("Add"),[y,v]=L.useState(null),k=()=>{o(!l)},p=D=>{v(D),s(!i)},f=()=>{w("Add"),v(null),k()},h=D=>{w("Edit"),v(D),k()};L.useEffect(()=>{bm().then(D=>{r(D.data)}).catch(D=>{console.log(D)}),t(!1)},[e]);const S=async(D,z)=>{try{await e1(D,z),t(!0)}catch(Se){console.log(Se)}},C=D=>{a(D)},_=D=>{d(D)},P=async D=>{try{await n1(D),t(!0),p()}catch(z){console.error("Failed to delete task:",z)}},T=async()=>{try{await r1(),t(!0)}catch(D){console.log(D)}};return x.jsxs("div",{className:"main-container",children:[x.jsx(wh,{toggleModal:f}),x.jsx(p1,{onSearch:C,onSort:_}),x.jsx(f1,{searchText:u,tasks:n,toggleStatus:S,sortOption:c,editModal:h,deleteToggleModal:p,clearCompletedTask:T}),l&&x.jsx(l1,{onClose:k,modalType:m,task:y,setMode:t}),i&&x.jsx(h1,{onClose:p,task:y,onDelete:P})]})}function y1(){return x.jsx(gh,{basename:"/react-todo-v2",children:x.jsx(mh,{children:x.jsx(Df,{path:"/",element:x.jsx(m1,{})})})})}Lo.createRoot(document.getElementById("root")).render(x.jsx(Ea.StrictMode,{children:x.jsx(y1,{})})); diff --git a/index.html b/index.html index ec982f9..37f156d 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@ Task Manager - +