@kompasid/lit-web-components 0.9.31 → 0.9.32
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 +129 -0
- package/demo/paywall.html +1 -1
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +3 -3
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +113 -66
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -1
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js +1 -1
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-grace-period/KompasGracePeriod.ts +3 -3
- package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +121 -72
- package/src/components/kompasid-paywall-body/KompasPaywallBody.ts +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit'
|
|
2
|
-
import { format,
|
|
2
|
+
import { format, addDays, differenceInDays } from 'date-fns'
|
|
3
3
|
import { id } from 'date-fns/locale/id'
|
|
4
4
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
5
5
|
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
6
|
-
import { truncate } from '../../utils/text.js'
|
|
7
6
|
import { User } from '../kompasid-header-account/types.js'
|
|
8
7
|
import '../kompasid-grace-period/KompasGracePeriod.js'
|
|
9
8
|
|
|
@@ -81,7 +80,7 @@ export class KompasHeaderAccountProfile extends LitElement {
|
|
|
81
80
|
* Subs Button Element
|
|
82
81
|
*/
|
|
83
82
|
const subscribeButton = () => {
|
|
84
|
-
if (!(this.userData as any)?.
|
|
83
|
+
if (!(this.userData as any)?.isMembership) {
|
|
85
84
|
return html``
|
|
86
85
|
}
|
|
87
86
|
const handleSubscribe = () => {
|
|
@@ -93,9 +92,9 @@ export class KompasHeaderAccountProfile extends LitElement {
|
|
|
93
92
|
<div class="w-full">
|
|
94
93
|
<button
|
|
95
94
|
@click=${handleSubscribe}
|
|
96
|
-
class="w-full rounded-lg px-4 py-3 mt-4 h-10 flex justify-center items-center bg-
|
|
95
|
+
class="w-full rounded-lg px-4 py-3 mt-4 h-10 flex justify-center items-center bg-brand-1 text-grey-100 font-bold text-base focus:outline-none"
|
|
97
96
|
>
|
|
98
|
-
|
|
97
|
+
Berlangganan Sekarang
|
|
99
98
|
</button>
|
|
100
99
|
</div>
|
|
101
100
|
`
|
|
@@ -124,84 +123,133 @@ export class KompasHeaderAccountProfile extends LitElement {
|
|
|
124
123
|
*/
|
|
125
124
|
|
|
126
125
|
const activeInfoTemplate = () => {
|
|
127
|
-
const {
|
|
128
|
-
|
|
126
|
+
const {
|
|
127
|
+
isGracePeriod,
|
|
128
|
+
totalGracePeriod,
|
|
129
|
+
isMembership,
|
|
130
|
+
activeInfo,
|
|
131
|
+
expired,
|
|
132
|
+
} = this.userData
|
|
133
|
+
let result = html``
|
|
134
|
+
let endGracePeriodDate = ''
|
|
129
135
|
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
const nowDate = new Date()
|
|
137
|
+
const isoDateString = expired.replace(' ', 'T')
|
|
138
|
+
const expiredDate = new Date(isoDateString)
|
|
139
|
+
const subsDaysLeft: number = differenceInDays(expiredDate, nowDate)
|
|
132
140
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
const gracePeriodCard = () => {
|
|
142
|
+
if (isGracePeriod) {
|
|
143
|
+
const totalGraceSubs = Math.max(totalGracePeriod - 1, 0)
|
|
144
|
+
endGracePeriodDate = this.formatDate(
|
|
145
|
+
addDays(new Date(), this.maxGracePeriod - totalGraceSubs)
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
const label = activeInfo ?? 'Periode Masa Tenggang'
|
|
149
|
+
return html`
|
|
150
|
+
<div class="text-orange-500 gracePeriodCard">
|
|
151
|
+
<span>${label}</span>
|
|
152
|
+
<p class="font-bold">hingga ${endGracePeriodDate}</p>
|
|
153
|
+
</div>
|
|
154
|
+
`
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const lessThan3daysCard = () => {
|
|
158
|
+
const label = activeInfo ?? 'Aktif Berlangganan'
|
|
159
|
+
return html`
|
|
160
|
+
<div class="lessThan3daysCard">
|
|
161
|
+
<span> ${label} </span>
|
|
162
|
+
<p class="font-bold">Berakhir ${subsDaysLeft} hari lagi</p>
|
|
163
|
+
</div>
|
|
164
|
+
`
|
|
141
165
|
}
|
|
142
166
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
167
|
+
const moreThan3daysCard = () => {
|
|
168
|
+
const formattedExpired = this.formatDate(expired)
|
|
169
|
+
const label = activeInfo ?? 'Aktif Berlangganan'
|
|
170
|
+
return html`
|
|
171
|
+
<div class="moreThan3daysCard">
|
|
172
|
+
<span>${label}</span>
|
|
173
|
+
<p class="font-bold">hingga ${formattedExpired}</p>
|
|
174
|
+
</div>
|
|
175
|
+
`
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const noSubsCard = () => {
|
|
179
|
+
const label = activeInfo ?? 'Tidak Berlangganan'
|
|
180
|
+
return html`
|
|
181
|
+
<div class="noSubsCard">
|
|
182
|
+
<span>${label}</span>
|
|
183
|
+
</div>
|
|
184
|
+
`
|
|
185
|
+
}
|
|
146
186
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
if (isGracePeriod) {
|
|
188
|
+
result = gracePeriodCard()
|
|
189
|
+
} else if (subsDaysLeft > 0 && subsDaysLeft < 3) {
|
|
190
|
+
result = lessThan3daysCard()
|
|
191
|
+
} else if (subsDaysLeft >= 3) {
|
|
192
|
+
result = moreThan3daysCard()
|
|
193
|
+
} else if (!isMembership || subsDaysLeft < 1) {
|
|
194
|
+
result = noSubsCard()
|
|
195
|
+
}
|
|
154
196
|
|
|
155
|
-
return html`<p class="text-sm ${
|
|
197
|
+
return html`<p class="text-sm text-grey-600 ${subsDaysLeft}-days-left">
|
|
198
|
+
${result}
|
|
199
|
+
</p>`
|
|
156
200
|
}
|
|
157
201
|
|
|
158
|
-
return html
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<div
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<span class="capitalize text-2xl text-grey-100 font-bold"
|
|
166
|
-
>${this.userInitialName}</span
|
|
202
|
+
return html`
|
|
203
|
+
<div
|
|
204
|
+
class="active-info flex flex-col items-start leading-none text-left font-sans"
|
|
205
|
+
>
|
|
206
|
+
<div class="flex flex-row items-center gap-4">
|
|
207
|
+
<div
|
|
208
|
+
class="flex bg-brand-1 flex-shrink-0 p-5 rounded-full h-16 w-16 items-center justify-center relative"
|
|
167
209
|
>
|
|
168
|
-
|
|
169
|
-
|
|
210
|
+
<span class="capitalize text-2xl text-grey-100 font-bold">
|
|
211
|
+
${this.userInitialName}
|
|
212
|
+
</span>
|
|
213
|
+
${membershipIcon()}
|
|
214
|
+
</div>
|
|
170
215
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
216
|
+
<div class="flex flex-col text-left">
|
|
217
|
+
<p class="capitalize font-bold text-base text-blue-600">
|
|
218
|
+
${this.userData.userName}
|
|
219
|
+
</p>
|
|
220
|
+
${activeInfoTemplate()}
|
|
221
|
+
</div>
|
|
176
222
|
</div>
|
|
177
|
-
</div>
|
|
178
223
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
224
|
+
${this.userData?.isGracePeriod
|
|
225
|
+
? html` <div class="mt-4 kompasid-grace-period">
|
|
226
|
+
<kompasid-grace-period
|
|
227
|
+
totalGracePeriod=${this.userData.totalGracePeriod}
|
|
228
|
+
isColumn="true"
|
|
229
|
+
isShowButton="true"
|
|
230
|
+
isBackgroundOnContentOnly="true"
|
|
231
|
+
paywall_location=${this.paywall_location}
|
|
232
|
+
paywall_subscription_package=${this
|
|
233
|
+
.paywall_subscription_package}
|
|
234
|
+
paywall_subscription_id=${this.paywall_subscription_id}
|
|
235
|
+
paywall_subscription_price=${this.paywall_subscription_price}
|
|
236
|
+
paywall_position=${this.paywall_position}
|
|
237
|
+
tracker_page_type=${this.tracker_page_type}
|
|
238
|
+
tracker_content_id=${this.tracker_content_id}
|
|
239
|
+
tracker_content_title=${this.tracker_content_title}
|
|
240
|
+
tracker_content_categories=${this.tracker_content_categories}
|
|
241
|
+
tracker_content_type=${this.tracker_content_type}
|
|
242
|
+
tracker_user_type=${this.tracker_user_type}
|
|
243
|
+
tracker_subscription_status=${this.tracker_subscription_status}
|
|
244
|
+
tracker_page_domain=${this.tracker_page_domain}
|
|
245
|
+
tracker_metered_wall_type=${this.tracker_metered_wall_type}
|
|
246
|
+
tracker_metered_wall_balance=${this
|
|
247
|
+
.tracker_metered_wall_balance}
|
|
248
|
+
></kompasid-grace-period>
|
|
249
|
+
</div>`
|
|
250
|
+
: subscribeButton()}
|
|
251
|
+
</div>
|
|
252
|
+
`
|
|
205
253
|
}
|
|
206
254
|
|
|
207
255
|
override async connectedCallback() {
|
|
@@ -210,11 +258,12 @@ export class KompasHeaderAccountProfile extends LitElement {
|
|
|
210
258
|
|
|
211
259
|
render() {
|
|
212
260
|
return html`
|
|
213
|
-
<div class="flex flex-shrink-0 flex-col
|
|
261
|
+
<div class="flex flex-shrink-0 flex-col p-4">
|
|
214
262
|
${!this.userData
|
|
215
263
|
? this.renderSkeletonLoading()
|
|
216
264
|
: this.renderProfileContent()}
|
|
217
265
|
</div>
|
|
266
|
+
<hr class="border-grey-300 mx-4" />
|
|
218
267
|
`
|
|
219
268
|
}
|
|
220
269
|
}
|
|
@@ -637,7 +637,7 @@ export class KompasIdPaywallBody extends LitElement {
|
|
|
637
637
|
>
|
|
638
638
|
${unsafeSVG(getFontAwesomeIcon('fas', 'arrow-left'))}
|
|
639
639
|
</button>`
|
|
640
|
-
} else if (type === '
|
|
640
|
+
} else if (type === 'proMiningOutlook' && isPrevHistoryExist) {
|
|
641
641
|
buttonContent = html` <button
|
|
642
642
|
@click=${this.redirectToPrevUrl}
|
|
643
643
|
class="hidden md:block w-8 h-8 pl-4 ${textColorClass}"
|