{"size": 8844, "ext": "js", "max_stars_repo_path": "client/build/static/js/11.bdd9ef7c.chunk.js", "max_stars_repo_name": "techterrain-dev/shopping-cart", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/build/static/js/11.bdd9ef7c.chunk.js", "max_issues_repo_name": "techterrain-dev/shopping-cart", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/build/static/js/11.bdd9ef7c.chunk.js", "max_forks_repo_name": "techterrain-dev/shopping-cart", "max_forks_repo_forks_event_min_datetime": "2021-11-29T06:09:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T06:09:12.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 4422.0, "max_line_length": 8798, "alphanum_fraction": 0.6809136137}
(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[11],{53:function(t,e,s){"use strict";s(1);var n=s(0);e.a=function(t){var e=t.magnify?"fa-".concat(t.magnify,"x"):"",s=["*","*","*","*","*"].map((function(s,n){return"<i data-stars=".concat(n+1,' class="').concat(t.rating>n?"fas ".concat(e," fa-star text-warning"):"far ".concat(e," fa-star text-secondary"),'"></i>')}));return Object(n.jsx)("div",{onClick:function(e){Number(t.rating)<1&&"function"===typeof t.updateRating&&t.updateRating(e.target.dataset.stars)},dangerouslySetInnerHTML:{__html:s.join("")}})}},82:function(t,e,s){"use strict";s.r(e);var n,a=s(16),c=s(8),r=s.n(c),i=s(12),l=s(3),o=s(1),d=s(6),u=s(52),j=s(5),b=s(14),f=s(9),O=s(26),p=s(53),x=s(0);e.default=function(){var t=Object(j.b)(),e=Object(l.a)(t,2),s=e[0],c=s.isAdmin,h=s.items,m=s.org,v=s.userId,E=e[1],g=Object(o.useState)([]),A=Object(l.a)(g,2),y=A[0],I=A[1],R=Object(o.useState)(""),D=Object(l.a)(R,2),C=D[0],w=D[1],k=Object(d.h)().orderStatus,N=Object(o.useRef)({});function L(){return S.apply(this,arguments)}function S(){return(S=Object(i.a)(r.a.mark((function t(){var e,s,n,a;return r.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("[loadOrders] items: orderStatus(".concat(k,") ")),t.next=3,Object(b.a)("/api/orders/".concat(k.replace("LIVE","")));case 3:if(e=t.sent,s=e.status,n=e.data,a=e.message,s){t.next=10;break}return E({type:"USER_LOGOUT",message:a}),t.abrupt("return");case 10:I(n),a&&E({type:"ALERT_MESSAGE",message:a});case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function P(){return(P=Object(i.a)(r.a.mark((function t(e,s,n){var c,i,l,o;return r.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.preventDefault(),!((c=N.current["_".concat(s)].value.trim()).length<3)){t.next=4;break}return t.abrupt("return");case 4:return N.current["_".concat(s)].value="",t.next=7,Object(b.a)("/api/orders/add-note/".concat(n),"put",{note:c});case 7:i=t.sent,i.status,l=i.data,i.message,(o=Object(a.a)(y))[s].notes=l.notes,I(o),E({type:"ALERT_MESSAGE",message:"Response sent"});case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function T(){return(T=Object(i.a)(r.a.mark((function t(e,s,n){var c,i,l;return r.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.preventDefault(),!((c=N.current["_".concat(s)].value.trim()).length<3)){t.next=4;break}return t.abrupt("return");case 4:return N.current["_".concat(s)].value="",t.next=7,Object(b.a)("/api/orders/".concat(n),"put",{statusInfo:c});case 7:i=t.sent,i.status,i.message,(l=Object(a.a)(y))[s].statusInfo=c,I(l),E({type:"ALERT_MESSAGE",message:"Updated status"});case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function G(t,e,s,n){return _.apply(this,arguments)}function _(){return(_=Object(i.a)(r.a.mark((function t(e,s,n,c){var i,l;return r.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.preventDefault(),window.confirm("Are you ready to change status to ".concat(c))){t.next=3;break}return t.abrupt("return");case 3:return"CANCELLED"===c&&window.confirm("Should we consider ABANDONED instead of cancelled?")&&(c="ABANDONED"),t.next=6,Object(b.a)("/api/orders/".concat(n),"put",{status:c});case 6:i=t.sent,i.status,i.message,(l=Object(a.a)(y))[s].status=c,I(l),E({type:"ALERT_MESSAGE",message:"Updated status"});case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return Object(o.useEffect)((function(){c&&(L(),n&&clearInterval(n),n=setInterval(L,15e3))}),[c,k]),Object(o.useEffect)((function(){return function(){n&&clearInterval(n)}}),[]),Object(x.jsx)("form",{children:Object(x.jsxs)("div",{class:"card",children:[Object(x.jsxs)("div",{class:"card-header",children:[Object(x.jsxs)("h4",{children:[m.name,"'s"]}),Object(x.jsxs)("select",{onChange:function(t){t.preventDefault(),E({type:"UPDATE_REDIRECT_GO",redirectUrl:"/admin/orders/".concat(t.target.value)})},defaultValue:k,class:"form-select",children:[Object(x.jsx)("option",{value:"LIVE",children:"Active Orders"}),Object(x.jsx)("option",{value:"CANCELLED",children:"Cancelled Orders"}),Object(x.jsx)("option",{value:"ABANDONED",children:"Abandoned Orders"}),Object(x.jsx)("option",{value:"COMPLETED",children:"Complete Orders"})]})]}),Object(x.jsx)("div",{class:"card-body row",children:y.length<1?Object(x.jsxs)("div",{class:"alert alert-warning ml-5 mr-5",children:[Object(x.jsx)("h2",{children:"No orders currently!"}),Object(x.jsx)("i",{children:"This page will update every minute with changes in orders."})]}):y&&y.map((function(t,e){return Object(x.jsx)(x.Fragment,{children:Object(x.jsx)("div",{class:"col-12 col-md-6 col-lg-4 mb-3",children:Object(x.jsxs)("div",{class:"card h-100",children:[Object(x.jsxs)("div",{class:"card-body",children:[Object(x.jsxs)("h5",{children:[t.orderCode,Object(x.jsxs)("small",{class:"text-muted float-end",children:[" ",Object(x.jsx)("i",{class:"far fa-clock"}),["PREPARING","READY","DELIVERING"].indexOf(t.status)>-1?u.DateTime.fromISO(t.orderAt).toRelative():u.DateTime.fromISO(t.updatedAt).toRelative()]})]})," ",["PREPARING","READY","DELIVERING"].indexOf(t.status)>-1&&Object(x.jsxs)("div",{class:"text-warning",children:[t.statusInfo&&Object(x.jsxs)("small",{class:"text-primary",children:[Object(x.jsx)("i",{class:"fas fa-info"})," ",t.statusInfo," / "]}),"Pick Up Order"]}),t.cart.length>0&&t.cart.map((function(t){return Object(x.jsx)(O.a,{items:h,cartItem:t,adminView:!0})})),Object(x.jsx)("div",{class:"row",children:Object(x.jsxs)("div",{class:"col item-layout mb-1",children:["\xa0",Object(x.jsx)("small",{class:"text-muted mx-5",children:"Total:"}),Object(x.jsx)("div",{class:"item-total",children:Object(x.jsx)("span",{class:"badge rounded-pill bg-warning text-dark mx-3",children:t.total?Object(f.a)(t.total):"-"})})]})}),t.contactInfo&&Object(x.jsxs)("div",{class:"mt-3 mb-3 border bg-light",children:[Object(x.jsxs)("span",{class:"badge rounded-pill bg-warning text-dark",children:[Object(x.jsx)("i",{class:"fas fa-receipt"})," Payment Required: ",t.contactInfo.name]}),Object(x.jsx)("small",{children:Object(x.jsxs)("ul",{children:[Object(x.jsxs)("li",{children:["Phone: ",Object(x.jsx)("a",{href:"tel:".concat(t.contactInfo.phone),children:t.contactInfo.phone})]}),Object(x.jsxs)("li",{children:["Email: ",Object(x.jsx)("a",{href:"tel:".concat(t.contactInfo.email),children:t.contactInfo.email})]})]})})]}),t.rating>0&&Object(x.jsx)(p.a,{rating:t.rating}),["PREPARING","READY","DELIVERING"].indexOf(t.status)>-1&&Object(x.jsxs)(x.Fragment,{children:[t.notes&&t.notes.map((function(e,s){return Object(x.jsx)("div",{onClick:function(){return e=t.orderCode,void w(C!==e?e:"");var e},className:C===t.orderCode||s>=t.notes.length-2?"":"d-none",children:e.userId===v?Object(x.jsxs)("div",{class:"text-secondary",children:[Object(x.jsx)("i",{class:"fas fa-reply",title:u.DateTime.fromSeconds(e.timestamp-1).toRelative()})," ",e.note]}):Object(x.jsxs)("div",{class:"text-success",children:[Object(x.jsx)("i",{class:"fas fa-comments",title:u.DateTime.fromSeconds(e.timestamp-1).toRelative()})," ",e.note]})})})),Object(x.jsxs)("div",{class:"input-group",children:[Object(x.jsx)("button",{onClick:function(s){return function(t,e,s){return P.apply(this,arguments)}(s,e,t.orderId)},class:"btn btn-outline-success",children:Object(x.jsx)("i",{class:"fas fa-reply"})}),Object(x.jsx)("input",{ref:function(t){return N.current["_".concat(e)]=t},type:"text",class:"form-control",placeholder:"Reply / Status Update"}),Object(x.jsx)("button",{onClick:function(s){return function(t,e,s){return T.apply(this,arguments)}(s,e,t.orderId)},class:"btn btn-primary",children:Object(x.jsx)("i",{class:"fas fa-exclamation"})})]})]})]}),Object(x.jsxs)("div",{class:"card-footer",children:[["PREPARING","READY"].indexOf(t.status)>-1&&Object(x.jsx)("button",{onClick:function(s){return G(s,e,t.orderId,"CANCELLED")},class:"btn btn-sm btn-outline-secondary",children:Object(x.jsx)("i",{class:"far fa-trash-alt"})}),"PREPARING"===t.status&&Object(x.jsxs)("button",{onClick:function(s){return G(s,e,t.orderId,"READY")},class:"btn btn-primary float-end",children:[Object(x.jsx)("i",{class:"fas fa-tasks"})," Ready"]}),"READY"===t.status&&Object(x.jsxs)("button",{onClick:function(s){return G(s,e,t.orderId,"COMPLETED")},class:"btn btn-success float-end",children:[Object(x.jsx)("i",{class:"fas fa-check"})," Picked-Up"]}),"COMPLETED"===t.status&&Object(x.jsx)("div",{class:"btn btn-outline-secondary float-end",children:"Completed"}),"CANCELLED"===t.status&&Object(x.jsxs)("div",{class:"btn btn-outline-danger float-end",children:[Object(x.jsx)("i",{class:"fas fa-times"})," Cancelled"]}),"ABANDONED"===t.status&&Object(x.jsxs)("div",{class:"btn btn-outline-danger float-end",children:[Object(x.jsx)("i",{class:"far fa-trash-alt"})," Abandoned"]})]})]})},t.orderCode)})}))})]})})}}}]);
//# sourceMappingURL=11.bdd9ef7c.chunk.js.map