@kompasid/lit-web-components 0.9.38 → 0.9.40

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.
@@ -36,7 +36,6 @@ export class KompasMeteredPaywall extends LitElement {
36
36
  ]
37
37
 
38
38
  @state() private isLoading: Boolean = true
39
- @state() private maxQuota: number = 3
40
39
  @state() private packageData: PackageData = {
41
40
  subscriptionText: 'Langganan untuk akses tanpa batas',
42
41
  buttonText: 'Langganan',
@@ -48,7 +47,6 @@ export class KompasMeteredPaywall extends LitElement {
48
47
  * Props
49
48
  */
50
49
  /**
51
- * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.
52
50
  * prop paywall_location = The location where user encounter the paywall
53
51
  * prop paywall_subscription_package = The name of the subscription package viewed by user
54
52
  * prop paywall_subscription_id = The ID of the subscription package viewed by user
@@ -63,10 +61,8 @@ export class KompasMeteredPaywall extends LitElement {
63
61
  * prop tracker_subscription_status = Status of their subscription
64
62
  * prop tracker_page_domain = Page Domain
65
63
  * prop tracker_metered_wall_type = The type of Metered Wall
66
- * prop tracker_epaper_edition = The edition of epaper viewed by user
67
64
  * prop tracker_metered_wall_balance = The balance of their metered wall
68
65
  */
69
- @property({ type: Number }) countdownArticle = 0
70
66
  @property({ type: String }) paywall_location = ''
71
67
  @property({ type: String }) paywall_subscription_package = ''
72
68
  @property({ type: String }) paywall_subscription_id = ''
@@ -83,27 +79,7 @@ export class KompasMeteredPaywall extends LitElement {
83
79
  @property({ type: String }) tracker_metered_wall_type = ''
84
80
  @property({ type: Number }) tracker_metered_wall_balance = 0
85
81
 
86
- private getCountdownArticle() {
87
- // const getCountdown = this.countdownArticle
88
- // const { maxQuota } = this
89
-
90
- // if (getCountdown > 0 && getCountdown < maxQuota) {
91
- // return html`
92
- // <p>
93
- // Anda memiliki sisa
94
- // <b>${maxQuota - getCountdown} dari ${maxQuota}</b> artikel premium
95
- // gratis bulan ini. ${this.packageData.subscriptionText}
96
- // </p>
97
- // `
98
- // }
99
- // return html`
100
- // <p>
101
- // Anda sedang membaca <b>artikel gratis terakhir bulan ini.</b> ${this
102
- // .packageData.subscriptionText}
103
- // </p>
104
- // `
105
-
106
- // Handle tanpa kuota
82
+ private textSubscription() {
107
83
  return html` <p>${this.packageData.subscriptionText}</p> `
108
84
  }
109
85
 
@@ -155,7 +131,7 @@ export class KompasMeteredPaywall extends LitElement {
155
131
  subscription_status: this.tracker_subscription_status,
156
132
  page_domain: this.tracker_page_domain || 'Kompas.id',
157
133
  metered_wall_type: this.tracker_metered_wall_type || 'MP',
158
- metered_wall_balance: this.maxQuota - this.countdownArticle + 1,
134
+ metered_wall_balance: this.tracker_metered_wall_balance || 0,
159
135
  })
160
136
  }
161
137
 
@@ -176,7 +152,7 @@ export class KompasMeteredPaywall extends LitElement {
176
152
  subscription_status: this.tracker_subscription_status,
177
153
  page_domain: this.tracker_page_domain || 'Kompas.id',
178
154
  metered_wall_type: this.tracker_metered_wall_type || 'MP',
179
- metered_wall_balance: this.maxQuota - this.countdownArticle + 1,
155
+ metered_wall_balance: this.tracker_metered_wall_balance || 0,
180
156
  })
181
157
  }
182
158
 
@@ -190,7 +166,7 @@ export class KompasMeteredPaywall extends LitElement {
190
166
  <div
191
167
  class="text-grey-600 text-sm md:text-lg self-center text-left"
192
168
  >
193
- ${this.getCountdownArticle()}
169
+ ${this.textSubscription()}
194
170
  </div>
195
171
  <div class="self-center">
196
172
  <button
@@ -206,3 +182,26 @@ export class KompasMeteredPaywall extends LitElement {
206
182
  : nothing
207
183
  }
208
184
  }
185
+
186
+ // Leftover code sebelum nya
187
+ // @state() private maxQuota: number = 3
188
+ // const getCountdown = this.countdownArticle
189
+ // const { maxQuota } = this
190
+
191
+ // if (getCountdown > 0 && getCountdown < maxQuota) {
192
+ // return html`
193
+ // <p>
194
+ // Anda memiliki sisa
195
+ // <b>${maxQuota - getCountdown} dari ${maxQuota}</b> artikel premium
196
+ // gratis bulan ini. ${this.packageData.subscriptionText}
197
+ // </p>
198
+ // `
199
+ // }
200
+ // return html`
201
+ // <p>
202
+ // Anda sedang membaca <b>artikel gratis terakhir bulan ini.</b> ${this
203
+ // .packageData.subscriptionText}
204
+ // </p>
205
+ // `
206
+
207
+ // Handle tanpa kuota
@@ -4,7 +4,6 @@
4
4
 
5
5
  | Property | Attribute | Description | Type | Default |
6
6
  | ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------- | -------- | ------- |
7
- | `countdownArticle` | `countdown-article` | prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca (User tidak bisa melihat kuota countdown dari update terbaru lit, namun data tetap di gunakan untuk GTM) | `number` | `0` |
8
7
  | `paywall_location` | `paywall_location` | prop paywall_location = The location where user encounter the paywall | `string` | `''` |
9
8
  | `paywall_position` | `paywall_position` | prop paywall_position = The position of ther subscription package viewed by user | `number` | `0` |
10
9
  | `paywall_subscription_id` | `paywall_subscription_id` | prop paywall_subscription_id = The ID of the subscription package viewed by user | `string` | `''` |
@@ -15,11 +14,11 @@
15
14
  | `tracker_content_title` | `tracker_content_title` | prop tracker_content_title = The title of article | `string` | `''` |
16
15
  | `tracker_content_type` | `tracker_content_type` | prop tracker_content_type = Whether it's free article or paid article | `string` | `''` |
17
16
  | `tracker_metered_wall_balance` | `tracker_metered_wall_balance` | prop tracker_metered_wall_balance = The balance of their metered wall | `number` | `0` |
18
- | `tracker_metered_wall_type` | `tracker_metered_wall_type` | prop tracker_metered_wall_type = The type of Metered Wall | `string` | `''` |
19
- | `tracker_page_domain` | `tracker_page_domain` | prop tracker_page_domain = Page Domain | `string` | `''` |
17
+ | `tracker_metered_wall_type` | `tracker_metered_wall_type` | prop tracker_metered_wall_type = The type of Metered Wall | `string` | `'MP'` |
18
+ | `tracker_page_domain` | `tracker_page_domain` | prop tracker_page_domain = Page Domain | `string` | `'Kompas.id'` |
20
19
  | `tracker_page_type` | `tracker_page_type` | prop tracker_page_type = Type of the page | `string` | `''` |
21
20
  | `tracker_subscription_status` | `tracker_subscription_status` | prop tracker_subscription_status = Status of their subscription | `string` | `''` |
22
- | `tracker_user_type` | `tracker_user_type` | prop tracker_user_type = Type of user based on their subscription | `string` | `''` |
21
+ | `tracker_user_type` | `tracker_user_type` | prop tracker_user_type = Type of user based on their subscription | `string` | `'R'` |
23
22
 
24
23
  ----------------------------------------------
25
24
 
@@ -343,7 +343,9 @@ export class KompasPaywall extends LitElement {
343
343
  const variantTarget = target.variant
344
344
  const checkVariant =
345
345
  variantTarget.toLowerCase() === stringVariant.toLowerCase()
346
+
346
347
  const checkTags = () => {
348
+ if (!tagsTarget.length) return false
347
349
  for (const item of tagsTarget) {
348
350
  if (!stringTag.toLowerCase().includes(item.toLowerCase())) {
349
351
  return false
@@ -351,7 +353,6 @@ export class KompasPaywall extends LitElement {
351
353
  }
352
354
  return true
353
355
  }
354
-
355
356
  return checkVariant && checkTags()
356
357
  }
357
358
 
@@ -381,7 +382,10 @@ export class KompasPaywall extends LitElement {
381
382
  const isoDateString = publishedDate.replace(' ', 'T')
382
383
  const publishedDateObj = new Date(isoDateString)
383
384
 
384
- const isWithin90Days = differenceInDays(publishedDateObj, nowDate) <= -90 // differenceInDays jika tanggal telah melewati 90 hari
385
+ const isWithin90Days = jsonContextual.articleAgeTreshold
386
+ ? differenceInDays(publishedDateObj, nowDate) <
387
+ -jsonContextual.articleAgeTreshold
388
+ : false // differenceInDays jika tanggal telah melewati 90 hari
385
389
  const hasMatchingTagsAndVariants = this.checkAllInString(
386
390
  jsonContextual,
387
391
  trackerTags,
@@ -93,4 +93,5 @@ export type PaywallType =
93
93
  export interface Contextual {
94
94
  variant: string
95
95
  tags: string[]
96
+ articleAgeTreshold: number
96
97
  }