Skyd3d commited on
Commit
ca76193
·
verified ·
1 Parent(s): 36002a8

how does this directly shows in my notification bar?

Browse files
Files changed (2) hide show
  1. components/order-column.js +10 -3
  2. script.js +14 -2
components/order-column.js CHANGED
@@ -103,10 +103,17 @@ class OrderColumn extends HTMLElement {
103
  const addOrderBtn = this.shadowRoot.getElementById('add-order');
104
  addOrderBtn.addEventListener('click', () => {
105
  const customerName = prompt("Enter customer name:");
106
- if (customerName) {
107
- this.addOrderCard(customerName);
 
 
 
 
 
 
108
  }
109
- });
 
110
  }
111
 
112
  addOrderCard(customerName) {
 
103
  const addOrderBtn = this.shadowRoot.getElementById('add-order');
104
  addOrderBtn.addEventListener('click', () => {
105
  const customerName = prompt("Enter customer name:");
106
+ if (customerName) {
107
+ this.addOrderCard(customerName);
108
+ // Show notification
109
+ if ('Notification' in window && Notification.permission === 'granted') {
110
+ new Notification('New Order Added', {
111
+ body: `New order for ${customerName} in ${this.getAttribute('title')}`,
112
+ icon: 'https://cdn-icons-png.flaticon.com/512/3144/3144456.png'
113
+ });
114
  }
115
+ }
116
+ });
117
  }
118
 
119
  addOrderCard(customerName) {
script.js CHANGED
@@ -1,6 +1,18 @@
1
- document.addEventListener('DOMContentLoaded', () => {
 
 
 
 
 
 
 
 
 
 
 
 
2
  // Theme toggle
3
- const themeToggle = document.getElementById('theme-toggle');
4
  themeToggle.addEventListener('click', () => {
5
  document.documentElement.classList.toggle('dark');
6
  const icon = themeToggle.querySelector('i');
 
1
+
2
+ // Request notification permission on page load
3
+ document.addEventListener('DOMContentLoaded', async () => {
4
+ // Request notification permission
5
+ if ('Notification' in window) {
6
+ try {
7
+ const permission = await Notification.requestPermission();
8
+ console.log('Notification permission:', permission);
9
+ } catch (err) {
10
+ console.error('Notification permission error:', err);
11
+ }
12
+ }
13
+
14
  // Theme toggle
15
+ const themeToggle = document.getElementById('theme-toggle');
16
  themeToggle.addEventListener('click', () => {
17
  document.documentElement.classList.toggle('dark');
18
  const icon = themeToggle.querySelector('i');