PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.7.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.7.2
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / dist / components / esm / sc-customer-edit.entry.js
sc-customer-edit.entry.js
109 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { r as registerInstance, h } from './index-25e5af33.js';
2 import './fetch-cdff67be.js';
3 import { a as addQueryArgs } from './add-query-args-0e2a8393.js';
4 import { a as apiFetch } from './index-824c562b.js';
5 import './remove-query-args-938c53ea.js';
6
7 const scCustomerEditCss = ":host{display:block;position:relative}.customer-edit{display:grid;gap:0.75em}";
8 const ScCustomerEditStyle0 = scCustomerEditCss;
9
10 const ScCustomerEdit = class {
11 constructor(hostRef) {
12 registerInstance(this, hostRef);
13 this.heading = undefined;
14 this.customer = undefined;
15 this.successUrl = undefined;
16 this.loading = undefined;
17 this.error = undefined;
18 }
19 async handleSubmit(e) {
20 var _a, _b;
21 this.loading = true;
22 try {
23 const { email, first_name, last_name, phone, billing_matches_shipping, shipping_name, shipping_city, 'tax_identifier.number_type': tax_identifier_number_type, 'tax_identifier.number': tax_identifier_number, shipping_country, shipping_line_1, shipping_line_2, shipping_postal_code, shipping_state, billing_name, billing_city, billing_country, billing_line_1, billing_line_2, billing_postal_code, billing_state, } = await e.target.getFormJson();
24 this.customer.billing_address = {
25 name: billing_name,
26 city: billing_city,
27 country: billing_country,
28 line_1: billing_line_1,
29 line_2: billing_line_2,
30 postal_code: billing_postal_code,
31 state: billing_state,
32 };
33 this.customer.shipping_address = {
34 name: shipping_name,
35 city: shipping_city,
36 country: shipping_country,
37 line_1: shipping_line_1,
38 line_2: shipping_line_2,
39 postal_code: shipping_postal_code,
40 state: shipping_state,
41 };
42 await apiFetch({
43 path: addQueryArgs(`surecart/v1/customers/${(_a = this.customer) === null || _a === void 0 ? void 0 : _a.id}`, { expand: ['tax_identifier'] }),
44 method: 'PATCH',
45 data: {
46 email,
47 first_name,
48 last_name,
49 phone,
50 billing_matches_shipping: billing_matches_shipping === true || billing_matches_shipping === 'on',
51 shipping_address: this.customer.shipping_address,
52 billing_address: this.customer.billing_address,
53 ...(tax_identifier_number && tax_identifier_number_type
54 ? {
55 tax_identifier: {
56 number: tax_identifier_number,
57 number_type: tax_identifier_number_type,
58 },
59 }
60 : {}),
61 },
62 });
63 if (this.successUrl) {
64 window.location.assign(this.successUrl);
65 }
66 else {
67 this.loading = false;
68 }
69 }
70 catch (e) {
71 this.error = ((_b = e === null || e === void 0 ? void 0 : e.additional_errors) === null || _b === void 0 ? void 0 : _b.length) ? e.additional_errors.map(err => err.message).join(', ') : (e === null || e === void 0 ? void 0 : e.message) || wp.i18n.__('Something went wrong', 'surecart');
72 this.loading = false;
73 }
74 }
75 render() {
76 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
77 return (h("sc-dashboard-module", { key: 'b0868e6cc2d8789718662e8584c6eb79652e4b48', class: "customer-edit", error: this.error }, h("span", { key: '60f3719bd34ec30b09abdb5d879329135736cefc', slot: "heading" }, this.heading || wp.i18n.__('Update Billing Details', 'surecart'), ' ', !((_a = this === null || this === void 0 ? void 0 : this.customer) === null || _a === void 0 ? void 0 : _a.live_mode) && (h("sc-tag", { key: '8b943872648c8a9562ce000e9d183f4cfeada128', type: "warning", size: "small" }, wp.i18n.__('Test', 'surecart')))), h("sc-card", { key: '23a3cad6c0e61c5812ac39f105c6ab639fbe5350' }, h("sc-form", { key: '8adfa8259521ae911fd6ce44c944bb5bb8e4b4dc', onScFormSubmit: e => this.handleSubmit(e) }, h("sc-columns", { key: 'fcc7c56a09ca25e4cc16bf57c5b102cb3a32fdfa', style: { '--sc-column-spacing': 'var(--sc-spacing-medium)' } }, h("sc-column", { key: '7a244a14f9c7aea993b7a65f1fa1bb8fea9c1012' }, h("sc-input", { key: '5a53ad092fc6ceeff375d240e47f0c116a20eb96', label: wp.i18n.__('First Name', 'surecart'), name: "first_name", value: (_b = this.customer) === null || _b === void 0 ? void 0 : _b.first_name })), h("sc-column", { key: 'f665e83ec6d8311daf55ae82964da70500a4228a' }, h("sc-input", { key: '19f629227cf366327e4643c61baa7b8639eac6b1', label: wp.i18n.__('Last Name', 'surecart'), name: "last_name", value: (_c = this.customer) === null || _c === void 0 ? void 0 : _c.last_name }))), h("sc-column", { key: '87edeffc8a0f27b7bec289861ea4705da6724a3c' }, h("sc-phone-input", { key: '18e631f763688ed4adf9b482f9b66fd50046be51', label: wp.i18n.__('Phone', 'surecart'), name: "phone", value: (_d = this.customer) === null || _d === void 0 ? void 0 : _d.phone })), h("sc-flex", { key: 'bcaf7e6992abec31db6292361994f1ab1c4ff838', style: { '--sc-flex-column-gap': 'var(--sc-spacing-medium)' }, flexDirection: "column" }, h("div", { key: '3c2502e2d21d58ec0652e01c70a34d3577f726ca' }, h("sc-address", { key: '10b303c243f112a53f88d6a6a7185785341322db', label: wp.i18n.__('Shipping Address', 'surecart'), showName: true, address: {
78 ...(_e = this.customer) === null || _e === void 0 ? void 0 : _e.shipping_address,
79 }, showLine2: true, required: false, names: {
80 name: 'shipping_name',
81 country: 'shipping_country',
82 line_1: 'shipping_line_1',
83 line_2: 'shipping_line_2',
84 city: 'shipping_city',
85 postal_code: 'shipping_postal_code',
86 state: 'shipping_state',
87 } })), h("div", { key: '1dfb9374290bc21b563fbd6e64c693bf98ca1330' }, h("sc-checkbox", { key: '828e70ca7edd0b161d759dbb270f3dbe7a62bbc0', name: "billing_matches_shipping", checked: (_f = this.customer) === null || _f === void 0 ? void 0 : _f.billing_matches_shipping, onScChange: e => {
88 this.customer = {
89 ...this.customer,
90 billing_matches_shipping: e.target.checked,
91 };
92 }, value: "on" }, wp.i18n.__('Billing address is same as shipping', 'surecart'))), h("div", { key: '93ce6721cde0603365d6a19b5e0c145f5416a965', style: { display: ((_g = this.customer) === null || _g === void 0 ? void 0 : _g.billing_matches_shipping) ? 'none' : 'block' } }, h("sc-address", { key: '5ff07ff28093a253328ef5bacf3cc89468cf25ec', label: wp.i18n.__('Billing Address', 'surecart'), showName: true, address: {
93 ...(_h = this.customer) === null || _h === void 0 ? void 0 : _h.billing_address,
94 }, showLine2: true, names: {
95 name: 'billing_name',
96 country: 'billing_country',
97 line_1: 'billing_line_1',
98 line_2: 'billing_line_2',
99 city: 'billing_city',
100 postal_code: 'billing_postal_code',
101 state: 'billing_state',
102 }, required: true })), h("sc-tax-id-input", { key: '5a87ac8d4b4e00c680e2409929ebe8ac8895c972', show: true, number: (_k = (_j = this.customer) === null || _j === void 0 ? void 0 : _j.tax_identifier) === null || _k === void 0 ? void 0 : _k.number, type: (_m = (_l = this.customer) === null || _l === void 0 ? void 0 : _l.tax_identifier) === null || _m === void 0 ? void 0 : _m.number_type })), h("div", { key: 'b26f474e86f33940ebea025ad3aa81676bc34bcd' }, h("sc-button", { key: '43e8b4a4d92d48094faa1dbd7e8f5c5bc9245abb', type: "primary", full: true, submit: true }, wp.i18n.__('Save', 'surecart'))))), this.loading && h("sc-block-ui", { key: 'c672b8e94fe3dcd205f0ab1065d5effba7717ac1', spinner: true })));
103 }
104 };
105 ScCustomerEdit.style = ScCustomerEditStyle0;
106
107 export { ScCustomerEdit as sc_customer_edit };
108
109 //# sourceMappingURL=sc-customer-edit.entry.js.map