Skip to content

Commit 6a56ce6

Browse files
committed
Add assertion for type (success / failure) toast in consent preferences component
1 parent dcea89a commit 6a56ce6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • src/components/Consent/Preferences/client

src/components/Consent/Preferences/client/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,21 @@ export class ConsentPreferencesElement extends LitElement {
261261
// Example: Clear marketing cookies
262262
}
263263

264-
private showNotification(message: string): void {
264+
private showNotification(message: string, type: 'success' | 'error' = 'success'): void {
265265
document
266266
.querySelectorAll<HTMLDivElement>('[data-testid="consent-toast"]')
267267
.forEach((existingToast) => existingToast.remove())
268268

269+
const typeClasses: Record<'success' | 'error', string> = {
270+
success: 'bg-green-600',
271+
error: 'bg-red-600'
272+
}
273+
269274
// Create a simple notification
270275
const notification = document.createElement('div')
271-
notification.className =
272-
'fixed top-4 right-4 bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg z-50 transition-all duration-300'
276+
notification.className = `fixed top-4 right-4 ${typeClasses[type]} text-white px-6 py-3 rounded-lg shadow-lg z-50 transition-all duration-300`
273277
notification.dataset['testid'] = 'consent-toast'
278+
notification.dataset['toastType'] = type
274279
notification.textContent = message
275280

276281
document.body.appendChild(notification)

0 commit comments

Comments
 (0)