JezK
Edit File: sc-dashboard-customer-details.cjs.entry.js.map
{"file":"sc-dashboard-customer-details.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,6BAA6B,GAAG,kFAAkF,CAAC;AACzH,yCAAe,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BCwCvB,UAAE;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/controllers/dashboard/customer-details/sc-dashboard-customer-details.css?tag=sc-dashboard-customer-details&encapsulation=shadow","src/components/controllers/dashboard/customer-details/sc-dashboard-customer-details.tsx"],"sourcesContent":[":host {\n display: block;\n position: relative;\n}\n\n.customer-details {\n display: grid;\n gap: 0.75em;\n}\n","import { Component, Element, h, Prop, State } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '../../../../functions/fetch';\nimport { onFirstVisible } from '../../../../functions/lazy';\nimport { Customer } from '../../../../types';\n\n@Component({\n tag: 'sc-dashboard-customer-details',\n styleUrl: 'sc-dashboard-customer-details.css',\n shadow: true,\n})\nexport class ScDashboardCustomerDetails {\n @Element() el: HTMLScCustomerDetailsElement;\n @Prop() customerId: string;\n @Prop() heading: string;\n @State() customer: Customer;\n @State() loading: boolean;\n @State() error: string;\n\n componentWillLoad() {\n onFirstVisible(this.el, () => {\n this.fetch();\n });\n }\n\n async fetch() {\n if ('' === this.customerId) {\n return;\n }\n try {\n this.loading = true;\n this.customer = (await await apiFetch({\n path: addQueryArgs(`surecart/v1/customers/${this.customerId}`, {\n expand: ['shipping_address', 'billing_address', 'tax_identifier'],\n }),\n })) as Customer;\n } catch (e) {\n if (e?.message) {\n this.error = e.message;\n } else {\n this.error = __('Something went wrong', 'surecart');\n }\n console.error(this.error);\n } finally {\n this.loading = false;\n }\n }\n\n render() {\n return (\n <sc-customer-details\n exportparts=\"base, heading, heading-text, heading-title, heading-description, error__base, error__icon, error__text, error__title, error__message, test-tag__base, test-tag__content, button__base, button__label, button__prefix\"\n customer={this.customer}\n loading={this.loading}\n error={this.error}\n heading={this.heading}\n edit-link={addQueryArgs(window.location.href, {\n action: 'edit',\n model: 'customer',\n id: this.customerId,\n })}\n ></sc-customer-details>\n );\n }\n}\n"],"version":3}