@kompasid/lit-web-components 0.9.53 → 0.9.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/header.html CHANGED
@@ -46,6 +46,7 @@
46
46
  import { format, addDays } from 'date-fns'
47
47
  import { id } from 'date-fns/locale/id'
48
48
  import '../dist/src/components/kompasid-header-account/KompasHeaderAccount.js'
49
+ import '../dist/src/components/kompasid-grace-period/KompasGracePeriod.js'
49
50
  import "../dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js"
50
51
  import '../dist/src/components/kompasid-header-notification/KompasHeaderNotification.js'
51
52
 
@@ -58,8 +59,13 @@
58
59
  "userName": "Clara Wijaya",
59
60
  "expired": formated(new Date()),
60
61
  "isMembership": true,
61
- "totalGracePeriod": 10,
62
- "isGracePeriod": true
62
+ "totalGracePeriod": 4,
63
+ "isGracePeriod": true,
64
+ "detailPackageUser": {
65
+ "memberhsip_channel_id": 8,
66
+ "payment_method": 'xendit_gopek',
67
+ "offering": 'Q2'
68
+ }
63
69
  },
64
70
  moreThan3Days: {
65
71
  "userName": "Clara Wijaya",
@@ -114,7 +120,7 @@
114
120
  const readLaterUrl = ''
115
121
  const totalGracePeriod = '5'
116
122
  const paywallLocation = 'paywall'
117
- const paywallSubscriptionPackage = 'kompasid'
123
+ const paywallSubscriptionPackage = 'kdp'
118
124
  const productId = 9802032
119
125
  const paywallSubscriptionPrice = 0
120
126
  const paywallPosition = 'header'
@@ -228,8 +234,35 @@
228
234
  .theme=${headerTheme}
229
235
  .company_name=${companyName}
230
236
  .manage_account_url=${manageAccountUrl}
237
+ .paywall_subscription_id=${productId}
238
+ .paywall_subscription_package=${paywallSubscriptionPackage}
231
239
  ></kompasid-header-account-profile>
232
240
  </div>
241
+ <div>
242
+ <kompasid-grace-period
243
+ totalGracePeriod=${userData.totalGracePeriod}
244
+ offering=${userData.detailPackageUser?.offering}
245
+ memberhsip_channel_id=${userData.detailPackageUser?.memberhsip_channel_id}
246
+ payment_method="${userData.detailPackageUser?.payment_method}"
247
+ isShowButton="true"
248
+ source="epaper"
249
+ .paywall_location=${paywallLocation}
250
+ .paywall_subscription_package=${paywallSubscriptionPackage}
251
+ .paywall_subscription_id=${productId}
252
+ .paywall_subscription_price=${paywallSubscriptionPrice}
253
+ .paywall_position=${paywallPosition}
254
+ .tracker_page_type=${trackerPageType}
255
+ .tracker_content_id=${trackerContentId}
256
+ .tracker_content_type=${trackerContentType}
257
+ .tracker_content_title=${trackerContentTitle}
258
+ .tracker_content_categories=${trackerContentCategories}
259
+ .tracker_user_type=${trackerUserType}
260
+ .tracker_page_domain=${trackerPageDomain}
261
+ .tracker_metered_wall_type=${meteredWallType}
262
+ .tracker_subscription_status=${trackerSubscriptionStatus}
263
+ .tracker_metered_wall_balance=${trackerMeteredWallBalance}
264
+ ></kompasid-grace-period>
265
+ </div>
233
266
  `,
234
267
  document.getElementById('controller-container')
235
268
  )
@@ -9,6 +9,9 @@ export declare class KompasGracePeriod extends LitElement {
9
9
  * property isColumn = changes how the component looks on different screen sizes
10
10
  * property isShowButton = shows or hides a subscription button
11
11
  * property isEpaper = is paywall opened in epaper page
12
+ * property memberhsip_channel_id = the ID of the subscription package by platform
13
+ * property payment_method = the payment method used by user
14
+ * property offering = the offering product
12
15
  * property paywall_location = the location where user encounter the paywall
13
16
  * property paywall_subscription_package = the name of the subscription package viewed by user
14
17
  * property paywall_subscription_id = the ID of the subscription package viewed by user
@@ -27,6 +30,9 @@ export declare class KompasGracePeriod extends LitElement {
27
30
  * property tracker_epaper_edition = the edition of epaper viewed by user
28
31
  */
29
32
  totalGracePeriod: number;
33
+ memberhsip_channel_id: number;
34
+ payment_method: string;
35
+ offering: string;
30
36
  isColumn: boolean;
31
37
  isShowButton: boolean;
32
38
  isEpaper: boolean;
@@ -55,11 +61,16 @@ export declare class KompasGracePeriod extends LitElement {
55
61
  private subscriptionPage;
56
62
  private checkoutPage;
57
63
  private tempTextEachDay;
64
+ private basketSize;
65
+ private messages;
66
+ private templateCheckout;
58
67
  private tempButtonA;
59
68
  private tempButtonB;
69
+ private isAutoRenewal;
70
+ private isWallet;
60
71
  private getCountdownGracePeriod;
61
72
  private redirectToKnowledgeBase;
62
- private redirectToBerlangganan;
73
+ private redirectCekSaldo;
63
74
  private redirectToCheckout;
64
75
  private getGtmParams;
65
76
  private sendGtmEvent;
@@ -14,6 +14,9 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
14
14
  * property isColumn = changes how the component looks on different screen sizes
15
15
  * property isShowButton = shows or hides a subscription button
16
16
  * property isEpaper = is paywall opened in epaper page
17
+ * property memberhsip_channel_id = the ID of the subscription package by platform
18
+ * property payment_method = the payment method used by user
19
+ * property offering = the offering product
17
20
  * property paywall_location = the location where user encounter the paywall
18
21
  * property paywall_subscription_package = the name of the subscription package viewed by user
19
22
  * property paywall_subscription_id = the ID of the subscription package viewed by user
@@ -32,13 +35,16 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
32
35
  * property tracker_epaper_edition = the edition of epaper viewed by user
33
36
  */
34
37
  this.totalGracePeriod = 0;
38
+ this.memberhsip_channel_id = 0; // [2 5 8] itu autorenewal
39
+ this.payment_method = ''; // xendit_shopeepay, midtrans_gopay, xendit_ovo , midtrans_cc
40
+ this.offering = ''; // Q1 ... Q5, [Q5 default]
35
41
  this.isColumn = false;
36
42
  this.isShowButton = true;
37
43
  this.isEpaper = false;
38
44
  this.isBackgroundOnContentOnly = false;
39
45
  this.source = 'article';
40
46
  this.paywall_location = '';
41
- this.paywall_subscription_package = '';
47
+ this.paywall_subscription_package = ''; // kdp, kompas-one, kdp-koran
42
48
  this.paywall_subscription_id = 0;
43
49
  this.paywall_subscription_price = 0;
44
50
  this.paywall_position = 0;
@@ -60,6 +66,9 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
60
66
  this.subscriptionPage = 'https://www.kompas.id/berlangganan';
61
67
  this.checkoutPage = 'https://checkoutv2.kompas.id';
62
68
  this.tempTextEachDay = [];
69
+ this.basketSize = {};
70
+ this.messages = {};
71
+ this.templateCheckout = '';
63
72
  this.tempButtonA = {
64
73
  url: '',
65
74
  text: '',
@@ -69,18 +78,60 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
69
78
  text: '',
70
79
  };
71
80
  }
81
+ isAutoRenewal() {
82
+ const { memberhsip_channel_id: checkAutoRenewal } = this;
83
+ if (checkAutoRenewal === 2 ||
84
+ checkAutoRenewal === 5 ||
85
+ checkAutoRenewal === 8) {
86
+ return true;
87
+ }
88
+ return false;
89
+ }
90
+ isWallet() {
91
+ const { payment_method: paymentMethod, memberhsip_channel_id: checkAutoRenewal, } = this;
92
+ const isMobile = checkAutoRenewal === 5 || checkAutoRenewal === 2;
93
+ if (paymentMethod.includes('cc')) {
94
+ return false;
95
+ }
96
+ if (isMobile) {
97
+ return false;
98
+ }
99
+ return true;
100
+ }
72
101
  getCountdownGracePeriod() {
73
- const { totalGracePeriod } = this;
74
- const { maxGracePeriod } = this;
75
- return html `
76
- <p
77
- class="message-gp"
78
- .innerHTML=${this.tempTextEachDay[totalGracePeriod > maxGracePeriod
79
- ? maxGracePeriod - 1
80
- : totalGracePeriod - 1 // template maksimal 7 hari
81
- ]}
82
- ></p>
83
- `;
102
+ const { messages, memberhsip_channel_id: checkAutoRenewal } = this;
103
+ if (!this.isAutoRenewal()) {
104
+ return messages.default;
105
+ }
106
+ // 8=Autorenewal
107
+ // 5=Apple
108
+ // 2=Google
109
+ const isRenewal = checkAutoRenewal === 8 || checkAutoRenewal === 5 || checkAutoRenewal === 2;
110
+ const isMobile = checkAutoRenewal === 5 || checkAutoRenewal === 2;
111
+ if (!isRenewal) {
112
+ return messages.default;
113
+ }
114
+ if (isMobile) {
115
+ return messages.default;
116
+ }
117
+ // if string contains cc
118
+ if (this.payment_method.includes('cc')) {
119
+ return messages.credit_card;
120
+ }
121
+ return messages.ewallet;
122
+ // Comment old
123
+ // const { totalGracePeriod } = this
124
+ // const { maxGracePeriod } = this
125
+ // return html`
126
+ // <p
127
+ // class="message-gp"
128
+ // .innerHTML=${this.tempTextEachDay[
129
+ // totalGracePeriod > maxGracePeriod
130
+ // ? maxGracePeriod - 1
131
+ // : totalGracePeriod - 1 // template maksimal 7 hari
132
+ // ]}
133
+ // ></p>
134
+ // `
84
135
  // comment old html
85
136
  // if (totalGracePeriod === 7) {
86
137
  // return html`
@@ -115,21 +166,37 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
115
166
  redirectToKnowledgeBase() {
116
167
  window.open('https://kb.kompas.id/baca/berlangganan-kompas-id/masa-tenggang-atau-grace-period-langganan/', '_blank');
117
168
  }
118
- redirectToBerlangganan() {
119
- const { url = '' } = this.tempButtonB;
120
- this.dataLayeronPerbaruiLanggananButton();
121
- this.sendGtmEvent('subscribe_button_clicked', true);
122
- const urlComputed = url || `${this.subscriptionPage}?open_from=Grace_Period`;
169
+ redirectCekSaldo() {
170
+ // this.dataLayeronPerbaruiLanggananButton()
171
+ // this.sendGtmEvent('subscribe_button_clicked', true)
172
+ const urlComputed = 'https://kb.kompas.id/baca/berlangganan-kompas-id/langganan-kompas-id/mengapa-perpanjangan-pembaruan-langganan-otomatis-melalui-e-wallet-belum-berhasil/';
123
173
  window.open(urlComputed);
124
174
  }
125
175
  redirectToCheckout() {
126
- const { url = '' } = this.tempButtonA;
176
+ const { paywall_subscription_package: paywallSubscriptionPackage, paywall_subscription_id: paywallSubscriptionId, basketSize, templateCheckout, offering, } = this;
177
+ const tempOffering = offering || 'Q5';
178
+ const tempPackageSlug = paywallSubscriptionPackage.toLowerCase();
127
179
  this.dataLayeronPerbaruiLanggananButton();
128
- const originHost = encodeURIComponent(window.location.href);
129
180
  this.sendGtmEvent('subscribe_button_clicked');
130
- const defaultPath = url ||
131
- `${this.checkoutPage}/v2/kdp?productId=${this.paywall_subscription_id}&autorenewal=1`;
132
- window.open(`${defaultPath}&referrer=${originHost}&source=${this.source}`);
181
+ if (!paywallSubscriptionId) {
182
+ window.open(basketSize[tempOffering]);
183
+ return;
184
+ }
185
+ if (tempPackageSlug.includes('kdp') && !tempPackageSlug.includes('koran')) {
186
+ window.open(basketSize[tempOffering]);
187
+ }
188
+ else {
189
+ window.open(templateCheckout.replace('_productid_', paywallSubscriptionId.toString()));
190
+ }
191
+ // comment old
192
+ // const { url = '' } = this.tempButtonA
193
+ // this.dataLayeronPerbaruiLanggananButton()
194
+ // const originHost: string = encodeURIComponent(window.location.href)
195
+ // this.sendGtmEvent('subscribe_button_clicked')
196
+ // const defaultPath =
197
+ // url ||
198
+ // `${this.checkoutPage}/v2/kdp?productId=${this.paywall_subscription_id}&autorenewal=1`
199
+ // window.open(`${defaultPath}&referrer=${originHost}&source=${this.source}`)
133
200
  }
134
201
  getGtmParams(excludeSubscriptionParams = false) {
135
202
  const gtmParams = {};
@@ -193,54 +260,50 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
193
260
  gracePeriodTemplate() {
194
261
  const { isColumn, isBackgroundOnContentOnly } = this;
195
262
  const { text: textA = '' } = this.tempButtonA;
196
- const { text: textB = '' } = this.tempButtonB;
263
+ // const { text: textB = '' } = this.tempButtonB
197
264
  const wrapperColumnClass = isColumn
198
265
  ? 'rounded-lg'
199
- : 'md:flex-row lg:px-8 md:space-x-4 px-4 py-4';
200
- const buttonColumnClass = isColumn
201
- ? ''
202
- : 'md:w-1/2 justify-end md:flex-row pt-4 md:pt-0';
266
+ : 'md:flex-row lg:px-8 px-4 py-4';
267
+ const buttonColumnClass = isColumn ? '' : 'justify-end md:flex-row';
203
268
  const otherBtnColumnClass = isColumn ? '' : 'md:w-auto';
204
269
  const wrapperBgClass = !isBackgroundOnContentOnly ? 'p-4' : '';
205
270
  const contentBgClass = isBackgroundOnContentOnly
206
- ? 'bg-orange-100 p-4 rounded-lg mb-4'
271
+ ? 'bg-orange-100 p-4 rounded-lg'
207
272
  : '';
208
273
  return html `
209
274
  <div
210
- class="bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}"
275
+ class="bottom-0 mx-auto flex gap-4 w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}"
211
276
  >
212
277
  <div
213
- class="self-center text-left text-sm text-grey-600 md:text-base ${contentBgClass}"
278
+ class="self-center w-full text-left text-sm text-grey-600 md:text-base ${contentBgClass}"
214
279
  >
215
280
  ${this.getCountdownGracePeriod()}
216
281
  </div>
217
282
  ${this.isShowButton
218
283
  ? html `
219
284
  <div
220
- class="flex w-full flex-col gap-4 self-center ${buttonColumnClass}"
285
+ class="flex grow items-center flex-wrap shrink-0 gap-2 ${buttonColumnClass}"
221
286
  >
222
- <button
223
- @click=${this.redirectToCheckout}
224
- class="w-full rounded-md bg-brand-1 p-2 px-5 text-sm font-bold text-grey-100 md:w-auto md:text-base"
225
- >
226
- ${textA || 'Perbarui Langganan'}
227
- </button>
228
- <div class="md:block hidden">
229
- <button
230
- @click=${this.redirectToBerlangganan}
231
- class="bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}"
232
- >
233
- ${textB || 'Paket Lainnya'}
234
- </button>
235
- </div>
236
- <div class="md:hidden block">
287
+ <div class="max-h-10 flex flex-grow md:w-auto">
237
288
  <button
238
- @click=${this.redirectToBerlangganan}
239
- class="bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}"
289
+ @click=${this.redirectToCheckout}
290
+ class="w-full rounded-md bg-brand-1 p-2 px-5 text-sm justify-center items-center font-bold text-grey-100 md:text-base"
240
291
  >
241
- ${textB || 'Lihat Paket Lainnya'}
292
+ ${textA || 'Perbarui Langganan'}
242
293
  </button>
243
294
  </div>
295
+ ${this.isWallet()
296
+ ? html `
297
+ <div class="w-full md:w-auto flex flex-grow max-h-10">
298
+ <button
299
+ @click=${this.redirectCekSaldo}
300
+ class="bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}"
301
+ >
302
+ Cara Isi Saldo
303
+ </button>
304
+ </div>
305
+ `
306
+ : nothing}
244
307
  </div>
245
308
  `
246
309
  : nothing}
@@ -248,13 +311,21 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
248
311
  `;
249
312
  }
250
313
  async connectedCallback() {
314
+ // New API
315
+ const endpointNew = 'https://cdn-www.kompas.id/web-component/grace-period-offering.json';
316
+ const responseNew = await fetch(endpointNew);
317
+ const resultNew = await responseNew.json();
318
+ this.basketSize = resultNew.basket_size_kdp;
319
+ this.messages = resultNew.payment_method_messages;
320
+ this.templateCheckout = resultNew.template_checkout_url;
321
+ // comment old
251
322
  // Constructing the URL with parameters
252
- const endpoint = `https://cdn-www.kompas.id/web-component/grace-period-paywall.json`;
253
- const response = await fetch(endpoint);
254
- const result = await response.json();
255
- this.tempTextEachDay = result.message;
256
- this.tempButtonA = result.buttonA;
257
- this.tempButtonB = result.buttonB;
323
+ // const endpoint = `https://cdn-www.kompas.id/web-component/grace-period-paywall.json`
324
+ // const response = await fetch(endpoint)
325
+ // const result = await response.json()
326
+ // this.tempTextEachDay = result.message
327
+ // this.tempButtonA = result.buttonA
328
+ // this.tempButtonB = result.buttonB
258
329
  super.connectedCallback();
259
330
  this.sendGtmEvent('paywall_viewed');
260
331
  this.dataLayeronGracePeriod();
@@ -295,6 +366,15 @@ KompasGracePeriod.styles = [
295
366
  __decorate([
296
367
  property({ type: Number })
297
368
  ], KompasGracePeriod.prototype, "totalGracePeriod", void 0);
369
+ __decorate([
370
+ property({ type: Number })
371
+ ], KompasGracePeriod.prototype, "memberhsip_channel_id", void 0);
372
+ __decorate([
373
+ property({ type: String })
374
+ ], KompasGracePeriod.prototype, "payment_method", void 0);
375
+ __decorate([
376
+ property({ type: String })
377
+ ], KompasGracePeriod.prototype, "offering", void 0);
298
378
  __decorate([
299
379
  property({ type: Boolean })
300
380
  ], KompasGracePeriod.prototype, "isColumn", void 0);
@@ -370,6 +450,15 @@ __decorate([
370
450
  __decorate([
371
451
  state()
372
452
  ], KompasGracePeriod.prototype, "tempTextEachDay", void 0);
453
+ __decorate([
454
+ state()
455
+ ], KompasGracePeriod.prototype, "basketSize", void 0);
456
+ __decorate([
457
+ state()
458
+ ], KompasGracePeriod.prototype, "messages", void 0);
459
+ __decorate([
460
+ state()
461
+ ], KompasGracePeriod.prototype, "templateCheckout", void 0);
373
462
  __decorate([
374
463
  state()
375
464
  ], KompasGracePeriod.prototype, "tempButtonA", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAwBL;;WAEG;QACH;;;;;;;;;;;;;;;;;;;;;WAqBG;QAEyB,qBAAgB,GAAG,CAAC,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,iBAAY,GAAG,IAAI,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,8BAAyB,GAAG,KAAK,CAAA;QAClC,WAAM,GAAG,SAAS,CAAA;QAClB,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC3B,+BAA0B,GAAG,CAAC,CAAA;QAC9B,qBAAgB,GAAG,CAAC,CAAA;QACpB,sBAAiB,GAAG,EAAE,CAAA;QACtB,uBAAkB,GAAG,EAAE,CAAA;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AE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAA4B;AAK9C;IAAR,KAAK,EAAE;yDAA2B;AAC1B;IAAR,KAAK,EAAE;2DAAgE;AAC/D;IAAR,KAAK,EAAE;uDAAsD;AACrD;IAAR,KAAK,EAAE;0DAA6B;AAC5B;IAAR,KAAK,EAAE;sDAMP;AACQ;IAAR,KAAK,EAAE;sDAMP;AA7FU,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CA0U7B;SA1UY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n\n .message-gp > a {\n color: #db5d00;\n text-decoration-line: underline;\n font-weight: 700;\n cursor: pointer;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property isEpaper = is paywall opened in epaper page\n * property paywall_location = the location where user encounter the paywall\n * property paywall_subscription_package = the name of the subscription package viewed by user\n * property paywall_subscription_id = the ID of the subscription package viewed by user\n * property paywall_subscription_price = the price of the subscriprtion package viewed by user\n * property paywall_position = the position of the subscription package viewed by user\n * property tracker_page_type = type of the page\n * property tracker_content_id = ID of article (slug)\n * property tracker_content_type = whether it's free article or paid article\n * property tracker_content_title = the title of article\n * property tracker_content_categories = the category of the content\n * property tracker_user_type = type of user based on their subscription\n * property tracker_subscription_status = status of their subscription\n * property tracker_page_domain = page Domain\n * property tracker_metered_wall_type = the type of Metered Wall\n * property tracker_metered_wall_balance = the balance of their metered wall\n * property tracker_epaper_edition = the edition of epaper viewed by user\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = true\n @property({ type: Boolean }) isEpaper = false\n @property({ type: Boolean }) isBackgroundOnContentOnly = false\n @property({ type: String }) source = 'article'\n @property({ type: String }) paywall_location = ''\n @property({ type: String }) paywall_subscription_package = ''\n @property({ type: Number }) paywall_subscription_id = 0\n @property({ type: Number }) paywall_subscription_price = 0\n @property({ type: Number }) paywall_position = 0\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n @property({ type: String }) tracker_epaper_edition = ''\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private subscriptionPage = 'https://www.kompas.id/berlangganan'\n @state() private checkoutPage = 'https://checkoutv2.kompas.id'\n @state() private tempTextEachDay = []\n @state() private tempButtonA: {\n url: string\n text: string\n } = {\n url: '',\n text: '',\n }\n @state() private tempButtonB: {\n url: string\n text: string\n } = {\n url: '',\n text: '',\n }\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n return html`\n <p\n class=\"message-gp\"\n .innerHTML=${this.tempTextEachDay[\n totalGracePeriod > maxGracePeriod\n ? maxGracePeriod - 1\n : totalGracePeriod - 1 // template maksimal 7 hari\n ]}\n ></p>\n `\n // comment old html\n // if (totalGracePeriod === 7) {\n // return html`\n // <p>\n // Anda dalam\n // <a\n // href=\"#\"\n // class=\"text-orange-500 underline font-bold cursor-pointer\"\n // @click=${this.redirectToKnowledgeBase}\n // >\n // hari terakhir\n // </a>\n // masa tenggang langganan. Segera perbarui paket langganan untuk tetap\n // mengakses konten premium tanpa batas.\n // </p>\n // `\n // }\n // return html`\n // <p>\n // Masa tenggang langganan Anda tersisa\n // <a\n // href=\"#\"\n // class=\"text-orange-500 underline font-bold cursor-pointer\"\n // @click=${this.redirectToKnowledgeBase}\n // >\n // ${maxGracePeriod - totalGracePeriod + 1} hari lagi </a\n // >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n // tanpa batas.\n // </p>\n // `\n }\n\n private redirectToKnowledgeBase(): void {\n window.open(\n 'https://kb.kompas.id/baca/berlangganan-kompas-id/masa-tenggang-atau-grace-period-langganan/',\n '_blank'\n )\n }\n\n private redirectToBerlangganan(): void {\n const { url = '' } = this.tempButtonB\n this.dataLayeronPerbaruiLanggananButton()\n this.sendGtmEvent('subscribe_button_clicked', true)\n\n const urlComputed = url || `${this.subscriptionPage}?open_from=Grace_Period`\n window.open(urlComputed)\n }\n\n private redirectToCheckout(): void {\n const { url = '' } = this.tempButtonA\n this.dataLayeronPerbaruiLanggananButton()\n const originHost: string = encodeURIComponent(window.location.href)\n\n this.sendGtmEvent('subscribe_button_clicked')\n\n const defaultPath =\n url ||\n `${this.checkoutPage}/v2/kdp?productId=${this.paywall_subscription_id}&autorenewal=1`\n\n window.open(`${defaultPath}&referrer=${originHost}&source=${this.source}`)\n }\n\n private getGtmParams(\n excludeSubscriptionParams: boolean = false\n ): Record<string, any> {\n const gtmParams: Record<string, any> = {}\n\n if (!this.isEpaper) {\n gtmParams.content_title = this.tracker_content_title\n gtmParams.content_id = this.tracker_content_id\n gtmParams.content_categories = this.tracker_content_categories\n gtmParams.content_type = this.tracker_content_type\n gtmParams.page_type = this.tracker_page_type\n } else {\n gtmParams.epaper_edition = this.tracker_epaper_edition\n }\n\n if (!excludeSubscriptionParams) {\n gtmParams.paywall_subscription_package = this.paywall_subscription_package\n gtmParams.paywall_subscription_id = this.paywall_subscription_id\n gtmParams.paywall_subscription_price = this.paywall_subscription_price\n }\n\n gtmParams.paywall_location = this.paywall_location\n gtmParams.paywall_position = this.paywall_position\n gtmParams.user_type = this.tracker_user_type\n gtmParams.subscription_status = this.tracker_subscription_status\n gtmParams.page_domain = this.tracker_page_domain || 'Kompas.id'\n gtmParams.metered_wall_type = this.tracker_metered_wall_type || 'GP'\n gtmParams.metered_wall_balance = this.tracker_metered_wall_balance\n\n return gtmParams\n }\n\n private sendGtmEvent(\n event: string,\n excludeSubscriptionParams: boolean = false\n ) {\n let gtmParams: Record<string, any> = { event }\n\n if (event === 'paywall_viewed') {\n gtmParams.impressions = [\n {\n ...this.getGtmParams(excludeSubscriptionParams),\n },\n ]\n } else {\n gtmParams = {\n ...gtmParams,\n ...this.getGtmParams(excludeSubscriptionParams),\n }\n }\n\n window.dataLayer.push(gtmParams)\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n const { isColumn, isBackgroundOnContentOnly } = this\n\n const { text: textA = '' } = this.tempButtonA\n\n const { text: textB = '' } = this.tempButtonB\n\n const wrapperColumnClass = isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8 md:space-x-4 px-4 py-4'\n const buttonColumnClass = isColumn\n ? ''\n : 'md:w-1/2 justify-end md:flex-row pt-4 md:pt-0'\n const otherBtnColumnClass = isColumn ? '' : 'md:w-auto'\n const wrapperBgClass = !isBackgroundOnContentOnly ? 'p-4' : ''\n const contentBgClass = isBackgroundOnContentOnly\n ? 'bg-orange-100 p-4 rounded-lg mb-4'\n : ''\n\n return html`\n <div\n class=\"bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}\"\n >\n <div\n class=\"self-center text-left text-sm text-grey-600 md:text-base ${contentBgClass}\"\n >\n ${this.getCountdownGracePeriod()}\n </div>\n ${this.isShowButton\n ? html`\n <div\n class=\"flex w-full flex-col gap-4 self-center ${buttonColumnClass}\"\n >\n <button\n @click=${this.redirectToCheckout}\n class=\"w-full rounded-md bg-brand-1 p-2 px-5 text-sm font-bold text-grey-100 md:w-auto md:text-base\"\n >\n ${textA || 'Perbarui Langganan'}\n </button>\n <div class=\"md:block hidden\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}\"\n >\n ${textB || 'Paket Lainnya'}\n </button>\n </div>\n <div class=\"md:hidden block\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}\"\n >\n ${textB || 'Lihat Paket Lainnya'}\n </button>\n </div>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n // Constructing the URL with parameters\n const endpoint = `https://cdn-www.kompas.id/web-component/grace-period-paywall.json`\n const response = await fetch(endpoint)\n const result = await response.json()\n this.tempTextEachDay = result.message\n this.tempButtonA = result.buttonA\n this.tempButtonB = result.buttonB\n\n super.connectedCallback()\n\n this.sendGtmEvent('paywall_viewed')\n\n this.dataLayeronGracePeriod()\n }\n\n render() {\n const bgClass = !this.isBackgroundOnContentOnly\n ? 'bg-orange-100 sticky bottom-0 z-20'\n : ''\n return html`\n <div class=\"h-full w-full ${bgClass}\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
1
+ {"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAwBL;;WAEG;QACH;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QAEyB,qBAAgB,GAAG,CAAC,CAAA;QACpB,0BAAqB,GAAG,CAAC,CAAA,CAAC,0BAA0B;QACpD,mBAAc,GAAG,EAAE,CAAA,CAAC,6DAA6D;QACjF,aAAQ,GAAG,EAAE,CAAA,CAAC,0BAA0B;QACvC,aAAQ,GAAG,KAAK,CAAA;QAChB,iBAAY,GAAG,IAAI,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,8BAAyB,GAAG,KAAK,CAAA;QAClC,WAAM,GAAG,SAAS,CAAA;QAClB,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA,CAAC,6BAA6B;QAC/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E;yDAA2B;AAC1B;IAAR,KAAK,EAAE;2DAAgE;AAC/D;IAAR,KAAK,EAAE;uDAAsD;AACrD;IAAR,KAAK,EAAE;0DAA6B;AAC5B;IAAR,KAAK,EAAE;qDAAmD;AAClD;IAAR,KAAK,EAAE;mDAAiD;AAChD;IAAR,KAAK,EAAE;2DAAsC;AACrC;IAAR,KAAK,EAAE;sDAMP;AACQ;IAAR,KAAK,EAAE;sDAMP;AAtGU,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CA8a7B;SA9aY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n\n .message-gp > a {\n color: #db5d00;\n text-decoration-line: underline;\n font-weight: 700;\n cursor: pointer;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property isEpaper = is paywall opened in epaper page\n * property memberhsip_channel_id = the ID of the subscription package by platform\n * property payment_method = the payment method used by user\n * property offering = the offering product\n * property paywall_location = the location where user encounter the paywall\n * property paywall_subscription_package = the name of the subscription package viewed by user\n * property paywall_subscription_id = the ID of the subscription package viewed by user\n * property paywall_subscription_price = the price of the subscriprtion package viewed by user\n * property paywall_position = the position of the subscription package viewed by user\n * property tracker_page_type = type of the page\n * property tracker_content_id = ID of article (slug)\n * property tracker_content_type = whether it's free article or paid article\n * property tracker_content_title = the title of article\n * property tracker_content_categories = the category of the content\n * property tracker_user_type = type of user based on their subscription\n * property tracker_subscription_status = status of their subscription\n * property tracker_page_domain = page Domain\n * property tracker_metered_wall_type = the type of Metered Wall\n * property tracker_metered_wall_balance = the balance of their metered wall\n * property tracker_epaper_edition = the edition of epaper viewed by user\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Number }) memberhsip_channel_id = 0 // [2 5 8] itu autorenewal\n @property({ type: String }) payment_method = '' // xendit_shopeepay, midtrans_gopay, xendit_ovo , midtrans_cc\n @property({ type: String }) offering = '' // Q1 ... Q5, [Q5 default]\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = true\n @property({ type: Boolean }) isEpaper = false\n @property({ type: Boolean }) isBackgroundOnContentOnly = false\n @property({ type: String }) source = 'article'\n @property({ type: String }) paywall_location = ''\n @property({ type: String }) paywall_subscription_package = '' // kdp, kompas-one, kdp-koran\n @property({ type: Number }) paywall_subscription_id = 0\n @property({ type: Number }) paywall_subscription_price = 0\n @property({ type: Number }) paywall_position = 0\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n @property({ type: String }) tracker_epaper_edition = ''\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private subscriptionPage = 'https://www.kompas.id/berlangganan'\n @state() private checkoutPage = 'https://checkoutv2.kompas.id'\n @state() private tempTextEachDay = []\n @state() private basketSize: { [key: string]: string } = {}\n @state() private messages: { [key: string]: string } = {}\n @state() private templateCheckout: string = ''\n @state() private tempButtonA: {\n url: string\n text: string\n } = {\n url: '',\n text: '',\n }\n @state() private tempButtonB: {\n url: string\n text: string\n } = {\n url: '',\n text: '',\n }\n\n private isAutoRenewal() {\n const { memberhsip_channel_id: checkAutoRenewal } = this\n if (\n checkAutoRenewal === 2 ||\n checkAutoRenewal === 5 ||\n checkAutoRenewal === 8\n ) {\n return true\n }\n return false\n }\n\n private isWallet() {\n const {\n payment_method: paymentMethod,\n memberhsip_channel_id: checkAutoRenewal,\n } = this\n const isMobile = checkAutoRenewal === 5 || checkAutoRenewal === 2\n if (paymentMethod.includes('cc')) {\n return false\n }\n\n if (isMobile) {\n return false\n }\n\n return true\n }\n\n private getCountdownGracePeriod() {\n const { messages, memberhsip_channel_id: checkAutoRenewal } = this\n\n if (!this.isAutoRenewal()) {\n return messages.default\n }\n\n // 8=Autorenewal\n // 5=Apple\n // 2=Google\n const isRenewal =\n checkAutoRenewal === 8 || checkAutoRenewal === 5 || checkAutoRenewal === 2\n const isMobile = checkAutoRenewal === 5 || checkAutoRenewal === 2\n if (!isRenewal) {\n return messages.default\n }\n\n if (isMobile) {\n return messages.default\n }\n\n // if string contains cc\n if (this.payment_method.includes('cc')) {\n return messages.credit_card\n }\n return messages.ewallet\n\n // Comment old\n // const { totalGracePeriod } = this\n // const { maxGracePeriod } = this\n // return html`\n // <p\n // class=\"message-gp\"\n // .innerHTML=${this.tempTextEachDay[\n // totalGracePeriod > maxGracePeriod\n // ? maxGracePeriod - 1\n // : totalGracePeriod - 1 // template maksimal 7 hari\n // ]}\n // ></p>\n // `\n // comment old html\n // if (totalGracePeriod === 7) {\n // return html`\n // <p>\n // Anda dalam\n // <a\n // href=\"#\"\n // class=\"text-orange-500 underline font-bold cursor-pointer\"\n // @click=${this.redirectToKnowledgeBase}\n // >\n // hari terakhir\n // </a>\n // masa tenggang langganan. Segera perbarui paket langganan untuk tetap\n // mengakses konten premium tanpa batas.\n // </p>\n // `\n // }\n // return html`\n // <p>\n // Masa tenggang langganan Anda tersisa\n // <a\n // href=\"#\"\n // class=\"text-orange-500 underline font-bold cursor-pointer\"\n // @click=${this.redirectToKnowledgeBase}\n // >\n // ${maxGracePeriod - totalGracePeriod + 1} hari lagi </a\n // >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n // tanpa batas.\n // </p>\n // `\n }\n\n private redirectToKnowledgeBase(): void {\n window.open(\n 'https://kb.kompas.id/baca/berlangganan-kompas-id/masa-tenggang-atau-grace-period-langganan/',\n '_blank'\n )\n }\n\n private redirectCekSaldo(): void {\n // this.dataLayeronPerbaruiLanggananButton()\n // this.sendGtmEvent('subscribe_button_clicked', true)\n const urlComputed =\n 'https://kb.kompas.id/baca/berlangganan-kompas-id/langganan-kompas-id/mengapa-perpanjangan-pembaruan-langganan-otomatis-melalui-e-wallet-belum-berhasil/'\n window.open(urlComputed)\n }\n\n private redirectToCheckout(): void {\n const {\n paywall_subscription_package: paywallSubscriptionPackage,\n paywall_subscription_id: paywallSubscriptionId,\n basketSize,\n templateCheckout,\n offering,\n } = this\n const tempOffering = offering || 'Q5'\n const tempPackageSlug = paywallSubscriptionPackage.toLowerCase()\n\n this.dataLayeronPerbaruiLanggananButton()\n this.sendGtmEvent('subscribe_button_clicked')\n\n if (!paywallSubscriptionId) {\n window.open(basketSize[tempOffering])\n return\n }\n\n if (tempPackageSlug.includes('kdp') && !tempPackageSlug.includes('koran')) {\n window.open(basketSize[tempOffering])\n } else {\n window.open(\n templateCheckout.replace(\n '_productid_',\n paywallSubscriptionId.toString()\n )\n )\n }\n\n // comment old\n // const { url = '' } = this.tempButtonA\n // this.dataLayeronPerbaruiLanggananButton()\n // const originHost: string = encodeURIComponent(window.location.href)\n\n // this.sendGtmEvent('subscribe_button_clicked')\n\n // const defaultPath =\n // url ||\n // `${this.checkoutPage}/v2/kdp?productId=${this.paywall_subscription_id}&autorenewal=1`\n\n // window.open(`${defaultPath}&referrer=${originHost}&source=${this.source}`)\n }\n\n private getGtmParams(\n excludeSubscriptionParams: boolean = false\n ): Record<string, any> {\n const gtmParams: Record<string, any> = {}\n\n if (!this.isEpaper) {\n gtmParams.content_title = this.tracker_content_title\n gtmParams.content_id = this.tracker_content_id\n gtmParams.content_categories = this.tracker_content_categories\n gtmParams.content_type = this.tracker_content_type\n gtmParams.page_type = this.tracker_page_type\n } else {\n gtmParams.epaper_edition = this.tracker_epaper_edition\n }\n\n if (!excludeSubscriptionParams) {\n gtmParams.paywall_subscription_package = this.paywall_subscription_package\n gtmParams.paywall_subscription_id = this.paywall_subscription_id\n gtmParams.paywall_subscription_price = this.paywall_subscription_price\n }\n\n gtmParams.paywall_location = this.paywall_location\n gtmParams.paywall_position = this.paywall_position\n gtmParams.user_type = this.tracker_user_type\n gtmParams.subscription_status = this.tracker_subscription_status\n gtmParams.page_domain = this.tracker_page_domain || 'Kompas.id'\n gtmParams.metered_wall_type = this.tracker_metered_wall_type || 'GP'\n gtmParams.metered_wall_balance = this.tracker_metered_wall_balance\n\n return gtmParams\n }\n\n private sendGtmEvent(\n event: string,\n excludeSubscriptionParams: boolean = false\n ) {\n let gtmParams: Record<string, any> = { event }\n\n if (event === 'paywall_viewed') {\n gtmParams.impressions = [\n {\n ...this.getGtmParams(excludeSubscriptionParams),\n },\n ]\n } else {\n gtmParams = {\n ...gtmParams,\n ...this.getGtmParams(excludeSubscriptionParams),\n }\n }\n\n window.dataLayer.push(gtmParams)\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n const { isColumn, isBackgroundOnContentOnly } = this\n\n const { text: textA = '' } = this.tempButtonA\n\n // const { text: textB = '' } = this.tempButtonB\n\n const wrapperColumnClass = isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8 px-4 py-4'\n const buttonColumnClass = isColumn ? '' : 'justify-end md:flex-row'\n const otherBtnColumnClass = isColumn ? '' : 'md:w-auto'\n const wrapperBgClass = !isBackgroundOnContentOnly ? 'p-4' : ''\n const contentBgClass = isBackgroundOnContentOnly\n ? 'bg-orange-100 p-4 rounded-lg'\n : ''\n\n return html`\n <div\n class=\"bottom-0 mx-auto flex gap-4 w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}\"\n >\n <div\n class=\"self-center w-full text-left text-sm text-grey-600 md:text-base ${contentBgClass}\"\n >\n ${this.getCountdownGracePeriod()}\n </div>\n ${this.isShowButton\n ? html`\n <div\n class=\"flex grow items-center flex-wrap shrink-0 gap-2 ${buttonColumnClass}\"\n >\n <div class=\"max-h-10 flex flex-grow md:w-auto\">\n <button\n @click=${this.redirectToCheckout}\n class=\"w-full rounded-md bg-brand-1 p-2 px-5 text-sm justify-center items-center font-bold text-grey-100 md:text-base\"\n >\n ${textA || 'Perbarui Langganan'}\n </button>\n </div>\n ${this.isWallet()\n ? html`\n <div class=\"w-full md:w-auto flex flex-grow max-h-10\">\n <button\n @click=${this.redirectCekSaldo}\n class=\"bg-transparent w-full rounded-md border border-brand-1 p-1.5 px-5 text-sm font-bold text-brand-1 md:text-base ${otherBtnColumnClass}\"\n >\n Cara Isi Saldo\n </button>\n </div>\n `\n : nothing}\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n // New API\n const endpointNew =\n 'https://cdn-www.kompas.id/web-component/grace-period-offering.json'\n const responseNew = await fetch(endpointNew)\n const resultNew = await responseNew.json()\n this.basketSize = resultNew.basket_size_kdp\n this.messages = resultNew.payment_method_messages\n this.templateCheckout = resultNew.template_checkout_url\n\n // comment old\n // Constructing the URL with parameters\n // const endpoint = `https://cdn-www.kompas.id/web-component/grace-period-paywall.json`\n // const response = await fetch(endpoint)\n // const result = await response.json()\n // this.tempTextEachDay = result.message\n // this.tempButtonA = result.buttonA\n // this.tempButtonB = result.buttonB\n\n super.connectedCallback()\n\n this.sendGtmEvent('paywall_viewed')\n\n this.dataLayeronGracePeriod()\n }\n\n render() {\n const bgClass = !this.isBackgroundOnContentOnly\n ? 'bg-orange-100 sticky bottom-0 z-20'\n : ''\n return html`\n <div class=\"h-full w-full ${bgClass}\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
@@ -1,7 +1,13 @@
1
+ export interface detailPackage {
2
+ offering: string;
3
+ payment_method: string;
4
+ memberhsip_channel_id: number;
5
+ }
1
6
  export interface User {
2
7
  userName: string;
3
8
  expired: string;
4
9
  totalGracePeriod: number;
5
10
  isGracePeriod: boolean;
6
11
  isMembership: boolean;
12
+ detailPackageUser: detailPackage;
7
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface User {\n userName: string\n expired: string\n totalGracePeriod: number\n isGracePeriod: boolean\n isMembership: boolean\n // updateMembership: string\n // activeInfo: string // ga kepake dua data ini\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface detailPackage {\n offering: string\n payment_method: string\n memberhsip_channel_id: number\n}\n\nexport interface User {\n userName: string\n expired: string\n totalGracePeriod: number\n isGracePeriod: boolean\n isMembership: boolean\n detailPackageUser: detailPackage\n}\n"]}
@@ -35,6 +35,7 @@ export declare class KompasHeaderAccountProfile extends LitElement {
35
35
  */
36
36
  private maxGracePeriod;
37
37
  formatDate(date: Date | string): string;
38
+ private handleDetailGracePeriod;
38
39
  private renderSkeletonLoading;
39
40
  private renderProfileContent;
40
41
  clickToManageAccount(): void;
@@ -45,6 +45,21 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
45
45
  formatDate(date) {
46
46
  return format(new Date(date), 'dd MMM yyyy', { locale: id });
47
47
  }
48
+ handleDetailGracePeriod() {
49
+ const { userData } = this;
50
+ if (userData.detailPackageUser) {
51
+ return {
52
+ memberhsip_channel_id: userData.detailPackageUser.memberhsip_channel_id || 0,
53
+ payment_method: userData.detailPackageUser.payment_method || '',
54
+ offering: userData.detailPackageUser.offering || '',
55
+ };
56
+ }
57
+ return {
58
+ memberhsip_channel_id: 0,
59
+ payment_method: '',
60
+ offering: '',
61
+ };
62
+ }
48
63
  renderSkeletonLoading() {
49
64
  return html `
50
65
  <div>
@@ -238,6 +253,11 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
238
253
  ? html ` <div class="mt-4 kompasid-grace-period">
239
254
  <kompasid-grace-period
240
255
  totalGracePeriod=${this.userData.totalGracePeriod}
256
+ offering="${this.handleDetailGracePeriod().offering}"
257
+ memberhsip_channel_id="${this.handleDetailGracePeriod()
258
+ .memberhsip_channel_id}"
259
+ payment_method="${this.handleDetailGracePeriod()
260
+ .payment_method}"
241
261
  isColumn="true"
242
262
  isShowButton="true"
243
263
  isBackgroundOnContentOnly="true"