From 219f59d0931eef0bff2e182b1bcc605cfb15a907 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Thu, 23 Aug 2018 07:24:02 +0200 Subject: [PATCH] wip --- .gitignore | 1 - dist/css/tool.css | 0 dist/js/tool.js | 1 + 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 dist/css/tool.css create mode 100644 dist/js/tool.js diff --git a/.gitignore b/.gitignore index c1b0aac..736232a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/dist /.idea /vendor /node_modules diff --git a/dist/css/tool.css b/dist/css/tool.css new file mode 100644 index 0000000..e69de29 diff --git a/dist/js/tool.js b/dist/js/tool.js new file mode 100644 index 0000000..ffc14f7 --- /dev/null +++ b/dist/js/tool.js @@ -0,0 +1 @@ +!function(t){var e={};function s(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,s),a.l=!0,a.exports}s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=3)}([function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var s=function(t,e){var s=t[1]||"",n=t[3];if(!n)return s;if(e&&"function"==typeof btoa){var a=(r=n,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),i=n.sources.map(function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"});return[s].concat(i).concat([a]).join("\n")}var r;return[s].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+s+"}":s}).join("")},e.i=function(t,s){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},a=0;as.parts.length&&(n.parts.length=s.parts.length)}else{var r=[];for(a=0;a "+t._s(t.subscription.current_period_end))])])]):t._e(),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40 remove-bottom-border"},[s("div",{staticClass:"w-1/4 py-4"},[s("h4",{staticClass:"font-normal text-80"},[t._v("Status")])]),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t.subscription.on_grace_period?s("span",[t._v("On Grace Period")]):t._e(),t._v(" "),t.subscription.cancelled||t.subscription.cancel_at_period_end?s("span",{staticClass:"text-danger"},[t._v("Cancelled")]):t._e(),t._v(" "),!t.subscription.active||t.subscription.cancelled||t.subscription.cancel_at_period_end?t._e():s("span",[t._v("Active")]),t._v("\n ยท\n "),s("a",{staticClass:"text-primary no-underline",attrs:{href:"/nova/cashier-tool/user/"+t.resourceId}},[t._v("\n Manage\n ")])])])]):t._e()])],1)},staticRenderFns:[]}},function(t,e,s){var n=s(2)(s(14),s(15),!1,function(t){s(12)},null,null);t.exports=n.exports},function(t,e,s){var n=s(13);"string"==typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);s(1)("b82feae8",n,!0,{})},function(t,e,s){(t.exports=s(0)(!1)).push([t.i,"",""])},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={props:["userId"],data:function(){return{loading:!0,user:null,subscription:null,cards:[],invoices:[],charges:[],plans:[],newPlan:""}},mounted:function(){this.loadUserData()},methods:{loadUserData:function(){var t=this;axios.get("/nova-cashier-tool-api/user/"+this.userId).then(function(e){t.user=e.data.user,t.subscription=e.data.subscription,t.cards=e.data.cards,t.invoices=e.data.invoices,t.charges=e.data.charges,t.plans=e.data.plans,t.newPlan=e.data.subscription?e.data.subscription.stripe_plan:null,t.loading=!1})},refundCharge:function(t){var e=this;this.loading=!0,axios.post("/nova-cashier-tool-api/user/"+this.userId+"/refund/"+t).then(function(t){e.$toasted.show("Refunded successfully!",{type:"success"}),e.loadUserData()}).catch(function(t){e.$toasted.show(t.response.data.message,{type:"error"})})},cancelSubscription:function(){var t=this;this.loading=!0,axios.post("/nova-cashier-tool-api/user/"+this.userId+"/cancel").then(function(e){t.$toasted.show("Cancelled successfully!",{type:"success"}),t.loadUserData()}).catch(function(e){t.$toasted.show(e.response.data.message,{type:"error"})})},resumeSubscription:function(){var t=this;this.loading=!0,axios.post("/nova-cashier-tool-api/user/"+this.userId+"/resume").then(function(e){t.$toasted.show("Resumed successfully!",{type:"success"}),t.loadUserData()}).catch(function(e){t.$toasted.show(e.response.data.message,{type:"error"})})},updateSubscription:function(){var t=this;this.loading=!0,axios.post("/nova-cashier-tool-api/user/"+this.userId+"/update",{plan:this.newPlan}).then(function(e){t.$toasted.show("Updated successfully!",{type:"success"}),t.loadUserData()}).catch(function(e){t.$toasted.show(e.response.data.message,{type:"error"})})}}}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",[s("heading",{staticClass:"mb-6"},[t._v("Cashier Manager")]),t._v(" "),t.loading?s("card",{staticClass:"bg-90 flex flex-col items-center justify-center",staticStyle:{"min-height":"300px"}},[s("svg",{staticClass:"spin fill-80 mb-6",attrs:{width:"69",height:"72",viewBox:"0 0 23 24",xmlns:"http://www.w3.org/2000/svg"}},[s("path",{attrs:{d:"M20.12 20.455A12.184 12.184 0 0 1 11.5 24a12.18 12.18 0 0 1-9.333-4.319c4.772 3.933 11.88 3.687 16.36-.738a7.571 7.571 0 0 0 0-10.8c-3.018-2.982-7.912-2.982-10.931 0a3.245 3.245 0 0 0 0 4.628 3.342 3.342 0 0 0 4.685 0 1.114 1.114 0 0 1 1.561 0 1.082 1.082 0 0 1 0 1.543 5.57 5.57 0 0 1-7.808 0 5.408 5.408 0 0 1 0-7.714c3.881-3.834 10.174-3.834 14.055 0a9.734 9.734 0 0 1 .03 13.855zM4.472 5.057a7.571 7.571 0 0 0 0 10.8c3.018 2.982 7.912 2.982 10.931 0a3.245 3.245 0 0 0 0-4.628 3.342 3.342 0 0 0-4.685 0 1.114 1.114 0 0 1-1.561 0 1.082 1.082 0 0 1 0-1.543 5.57 5.57 0 0 1 7.808 0 5.408 5.408 0 0 1 0 7.714c-3.881 3.834-10.174 3.834-14.055 0a9.734 9.734 0 0 1-.015-13.87C5.096 1.35 8.138 0 11.5 0c3.75 0 7.105 1.68 9.333 4.319C16.06.386 8.953.632 4.473 5.057z","fill-rule":"evenodd"}})]),t._v(" "),s("h1",{staticClass:"text-white text-4xl text-90 font-light mb-6"},[t._v("Loading...")]),t._v(" "),s("p",{staticClass:"text-white-50% text-lg"},[t._v("\n Fetching subscription information from Stripe. Might take a few moments.\n ")])]):t._e(),t._v(" "),t.loading||t.subscription?t._e():s("div",{staticClass:"card mb-6 py-3 px-6"},[s("p",{staticClass:"text-90"},[t._v("User has no subscription.")])]),t._v(" "),!t.loading&&t.subscription?s("div",{staticClass:"card mb-6 py-3 px-6"},[s("div",{staticClass:"flex border-b border-40"},[t._m(0),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t._v(t._s(t.user.name)+" ("+t._s(t.user.email)+")")])])]),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40"},[t._m(1),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t._v(t._s(t.subscription.created_at))])])]):t._e(),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40"},[t._m(2),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("select",{directives:[{name:"model",rawName:"v-model",value:t.newPlan,expression:"newPlan"}],staticClass:"form-control form-select",on:{change:function(e){var s=Array.prototype.filter.call(e.target.options,function(t){return t.selected}).map(function(t){return"_value"in t?t._value:t.value});t.newPlan=e.target.multiple?s:s[0]}}},[s("option",{attrs:{value:"",disabled:"disabled",selected:"selected"}},[t._v("Choose New Plan")]),t._v(" "),t._l(t.plans,function(e){return s("option",{domProps:{value:e.id}},[t._v("\n "+t._s(e.id)+" ("+t._s(e.price/100)+" "+t._s(e.currency)+" / "+t._s(e.interval)+")\n ")])})],2),t._v(" "),t.newPlan&&t.newPlan!=t.subscription.stripe_plan&&t.subscription.active&&!t.subscription.cancel_at_period_end?s("button",{staticClass:"btn btn-sm btn-outline",on:{click:function(e){t.updateSubscription()}}},[t._v("\n Update Plan\n ")]):t._e()])]):t._e(),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40"},[t._m(3),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t._v(t._s(t.subscription.plan_amount/100)+" ("+t._s(t.subscription.plan_currency)+") / "+t._s(t.subscription.plan_interval))])])]):t._e(),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40"},[t._m(4),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t._v(t._s(t.subscription.current_period_start)+" => "+t._s(t.subscription.current_period_end))])])]):t._e(),t._v(" "),t.subscription?s("div",{staticClass:"flex border-b border-40 remove-bottom-border"},[t._m(5),t._v(" "),s("div",{staticClass:"w-3/4 py-4"},[s("p",{staticClass:"text-90"},[t.subscription.on_grace_period?s("span",[t._v("On Grace Period")]):t._e(),t._v(" "),t.subscription.cancelled||t.subscription.cancel_at_period_end?s("span",{staticClass:"text-danger"},[t._v("Cancelled")]):t._e(),t._v(" "),!t.subscription.active||t.subscription.cancelled||t.subscription.cancel_at_period_end?t._e():s("span",[t._v("Active")]),t._v(" "),!t.subscription.active||t.subscription.cancelled||t.subscription.cancel_at_period_end?t._e():s("button",{staticClass:"btn btn-sm btn-outline",on:{click:function(e){t.cancelSubscription()}}},[t._v("\n Cancel\n ")]),t._v(" "),t.subscription.active&&t.subscription.cancel_at_period_end?s("button",{staticClass:"btn btn-sm btn-outline",on:{click:function(e){t.resumeSubscription()}}},[t._v("\n Resume\n ")]):t._e()])])]):t._e()]):t._e(),t._v(" "),!t.loading&&t.invoices&&t.invoices.length?s("div",{staticClass:"card mb-6 relative"},[t._m(6),t._v(" "),s("div",{staticClass:"overflow-hidden overflow-x-auto relative"},[s("table",{staticClass:"table w-full",attrs:{cellpadding:"0",cellspacing:"0","data-testid":"resource-table"}},[t._m(7),t._v(" "),s("tbody",t._l(t.invoices,function(e){return s("tr",[s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.total/100)+" "+t._s(e.currency))])]),t._v(" "),s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.period_start))])]),t._v(" "),s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.period_end))])]),t._v(" "),s("td",{staticClass:"text-right"},[e.total>0?s("button",{staticClass:"btn btn-sm btn-outline",on:{click:function(s){t.refundCharge(e.charge_id)}}},[t._v("\n Refund\n ")]):t._e()])])}))])])]):t._e(),t._v(" "),!t.loading&&t.charges&&t.charges.length?s("div",{staticClass:"card mb-6 relative"},[t._m(8),t._v(" "),s("div",{staticClass:"overflow-hidden overflow-x-auto relative"},[s("table",{staticClass:"table w-full",attrs:{cellpadding:"0",cellspacing:"0","data-testid":"resource-table"}},[t._m(9),t._v(" "),s("tbody",t._l(t.charges,function(e){return s("tr",[s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.amount/100)+" "+t._s(e.currency))])]),t._v(" "),s("td",[e.amount_refunded?s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.amount_refunded/100)+" "+t._s(e.currency)+" Refunded")]):t._e(),t._v(" "),e.captured?s("span",{staticClass:"whitespace-no-wrap text-left text-success"},[t._v("Successfull")]):t._e(),t._v(" "),e.failure_message?s("span",{staticClass:"whitespace-no-wrap text-left text-danger"},[t._v(t._s(e.failure_message))]):t._e()]),t._v(" "),s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.created))])]),t._v(" "),s("td",{staticClass:"text-right"},[s("button",{staticClass:"btn btn-sm btn-outline",on:{click:function(s){t.refundCharge(e.id)}}},[t._v("\n Refund\n ")])])])}))])])]):t._e(),t._v(" "),!t.loading&&t.cards&&t.cards.length?s("div",{staticClass:"card mb-6 relative"},[t._m(10),t._v(" "),s("div",{staticClass:"overflow-hidden overflow-x-auto relative"},[s("table",{staticClass:"table w-full",attrs:{cellpadding:"0",cellspacing:"0","data-testid":"resource-table"}},[t._m(11),t._v(" "),s("tbody",t._l(t.cards,function(e){return s("tr",[s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.brand))])]),t._v(" "),s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v("**********"+t._s(e.last4))])]),t._v(" "),s("td",[s("span",{staticClass:"whitespace-no-wrap text-left"},[t._v(t._s(e.exp_month)+"/"+t._s(e.exp_year))])])])}))])])]):t._e()],1)},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Customer")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Created")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Plan")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Amount")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Billing Period")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"w-1/4 py-4"},[e("h4",{staticClass:"font-normal text-80"},[this._v("Status")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"py-3 flex items-center border-b border-50"},[e("div",{staticClass:"px-3"},[this._v("\n Invoices\n ")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("thead",[e("tr",[e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Amount")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("From")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("To")])]),this._v(" "),e("th")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"py-3 flex items-center border-b border-50"},[e("div",{staticClass:"px-3"},[this._v("\n Charges\n ")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("thead",[e("tr",[e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Amount")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Status")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Created")])]),this._v(" "),e("th")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"py-3 flex items-center border-b border-50"},[e("div",{staticClass:"px-3"},[this._v("\n Cards\n ")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("thead",[e("tr",[e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Brand")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Number")])]),this._v(" "),e("th",{staticClass:"text-left"},[e("span",{staticClass:"cursor-pointer inline-flex items-center"},[this._v("Expiration")])])])])}]}},function(t,e){}]); \ No newline at end of file