+ ${renderNumericInput('^d+(?:.d{1,2})?$', 'amount', 'Amount', 'required', false)}
+ ${renderInput('text', 'description', 'Description', 'required')}
+ ${renderInput('checkbox', 'hasEnd', 'Existing End Date', '', false, 'change:subscription-edit#onCheck')}
+ ${renderInput(
+ 'date',
+ 'endDate',
+ 'End date',
+ 'required',
+ !(this.hasEndCheck?.inp as HTMLInputElement)?.checked
+ )}
+ ${renderDropdown(
+ 'subscription-edit#getWallets',
+ 'wallet',
+ 'Wallet',
+ 'required',
+ this.walletData && this.walletData.walletId
+ )}
+ ${this.errorMessage ? html`
${this.errorMessage}
` : html``}`;
+ };
+
+ render = (): TemplateResult => {
+ return html`
+
+
+ `;
+ };
+}
+
+export type { SubscriptionEditElement };
diff --git a/src/pages/subscription-list/SubscriptionListElement.ts b/src/pages/subscription-list/SubscriptionListElement.ts
index ae30d66..61f8d63 100644
--- a/src/pages/subscription-list/SubscriptionListElement.ts
+++ b/src/pages/subscription-list/SubscriptionListElement.ts
@@ -33,6 +33,23 @@ class SubscriptionListElement extends BasePageElement {
this.pagination?.executeFetch();
};
+ subscriptionEdit = (id) => {
+ const _modal = this.appMain.appModal;
+ if (_modal) {
+ this.appMain.closeModal();
+ } else {
+ this.appMain.createModal('subscription-edit', {
+ id: id
+ });
+ }
+ }
+
+ subscriptionEnd = (id) => {
+ if (confirm('Are you sure you want to end this subscription?')) {
+ this.subscriptionService.endSubscription(id);
+ }
+ }
+
renderSubscription = (item) => html`
| ${dayjs(item.lastTransactionDate).format("MMM DD 'YY")} |
every ${item.customRange} ${item.rangeName} |
@@ -50,6 +67,10 @@ class SubscriptionListElement extends BasePageElement {
(${item.currency ? item.currency : 'USD'})
+
+
+
+ |
`;
getSubscriptions = async (options): Promise
=> {
diff --git a/src/services/SubscriptionService.ts b/src/services/SubscriptionService.ts
index a5c89fa..f1b45a6 100644
--- a/src/services/SubscriptionService.ts
+++ b/src/services/SubscriptionService.ts
@@ -1,9 +1,13 @@
import { AppService, BaseService } from 'core/services';
class SubscriptionService extends BaseService {
- constructor(appService: AppService) {
+ constructor(public appService: AppService) {
super('/subscription', appService);
}
+
+ endSubscription = (id) => {
+ return this.appService.put(this.endpoint + `/end/${id || ''}`, null, null);
+ };
}
export default SubscriptionService;
diff --git a/src/styles/app-pagination/app-pagination.scss b/src/styles/app-pagination/app-pagination.scss
index d1da237..27a822b 100644
--- a/src/styles/app-pagination/app-pagination.scss
+++ b/src/styles/app-pagination/app-pagination.scss
@@ -138,13 +138,14 @@ app-pagination {
grid-template-columns: repeat(6, 1fr);
}
&.col-subscription {
- grid-template-columns: 1fr 2fr 10fr 1fr 2fr;
+ grid-template-columns: 1fr 2fr 10fr 1fr 2fr 1fr;
}
td,
th {
margin: 0 12px;
overflow: hidden; // Or flex might break
list-style: none;
+ align-self: center;
&.--left {
text-align: left;
}
diff --git a/yarn.lock b/yarn.lock
index 9d60438..e3f0e70 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1207,22 +1207,22 @@
"@webassemblyjs/ast" "1.11.0"
"@xtuc/long" "4.2.2"
-"@webpack-cli/configtest@^1.0.3":
- version "1.0.3"
- resolved "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.0.3.tgz"
- integrity sha512-WQs0ep98FXX2XBAfQpRbY0Ma6ADw8JR6xoIkaIiJIzClGOMqVRvPCWqndTxf28DgFopWan0EKtHtg/5W1h0Zkw==
+"@webpack-cli/configtest@^1.0.4":
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.0.4.tgz#f03ce6311c0883a83d04569e2c03c6238316d2aa"
+ integrity sha512-cs3XLy+UcxiP6bj0A6u7MLLuwdXJ1c3Dtc0RkKg+wiI1g/Ti1om8+/2hc2A2B60NbBNAbMgyBMHvyymWm/j4wQ==
-"@webpack-cli/info@^1.2.4":
- version "1.2.4"
- resolved "https://registry.npmjs.org/@webpack-cli/info/-/info-1.2.4.tgz"
- integrity sha512-ogE2T4+pLhTTPS/8MM3IjHn0IYplKM4HbVNMCWA9N4NrdPzunwenpCsqKEXyejMfRu6K8mhauIPYf8ZxWG5O6g==
+"@webpack-cli/info@^1.3.0":
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.3.0.tgz#9d78a31101a960997a4acd41ffd9b9300627fe2b"
+ integrity sha512-ASiVB3t9LOKHs5DyVUcxpraBXDOKubYu/ihHhU+t1UPpxsivg6Od2E2qU4gJCekfEddzRBzHhzA/Acyw/mlK/w==
dependencies:
envinfo "^7.7.3"
-"@webpack-cli/serve@^1.4.0":
- version "1.4.0"
- resolved "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.4.0.tgz"
- integrity sha512-xgT/HqJ+uLWGX+Mzufusl3cgjAcnqYYskaB7o0vRcwOEfuu6hMzSILQpnIzFMGsTaeaX4Nnekl+6fadLbl1/Vg==
+"@webpack-cli/serve@^1.5.1":
+ version "1.5.1"
+ resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.5.1.tgz#b5fde2f0f79c1e120307c415a4c1d5eb15a6f278"
+ integrity sha512-4vSVUiOPJLmr45S8rMGy7WDvpWxfFxfP/Qx/cxZFCfvoypTYpPPL1X8VIZMe0WTA+Jr7blUxwUSEZNkjoMTgSw==
"@xtuc/ieee754@^1.2.0":
version "1.2.0"
@@ -6595,15 +6595,15 @@ wbuf@^1.1.0, wbuf@^1.7.3:
dependencies:
minimalistic-assert "^1.0.0"
-webpack-cli@^4.7.0:
- version "4.7.0"
- resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.7.0.tgz"
- integrity sha512-7bKr9182/sGfjFm+xdZSwgQuFjgEcy0iCTIBxRUeteJ2Kr8/Wz0qNJX+jw60LU36jApt4nmMkep6+W5AKhok6g==
+webpack-cli@^4.7.2:
+ version "4.7.2"
+ resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.7.2.tgz#a718db600de6d3906a4357e059ae584a89f4c1a5"
+ integrity sha512-mEoLmnmOIZQNiRl0ebnjzQ74Hk0iKS5SiEEnpq3dRezoyR3yPaeQZCMCe+db4524pj1Pd5ghZXjT41KLzIhSLw==
dependencies:
"@discoveryjs/json-ext" "^0.5.0"
- "@webpack-cli/configtest" "^1.0.3"
- "@webpack-cli/info" "^1.2.4"
- "@webpack-cli/serve" "^1.4.0"
+ "@webpack-cli/configtest" "^1.0.4"
+ "@webpack-cli/info" "^1.3.0"
+ "@webpack-cli/serve" "^1.5.1"
colorette "^1.2.1"
commander "^7.0.0"
execa "^5.0.0"