ok
This commit is contained in:
@@ -8,10 +8,8 @@ const ChatBot = ({ existingConversation, readOnly, hh }) => {
|
|||||||
text: 'Hai Dermalovers! 👋 Saya siap membantu anda tampil lebih percaya diri. Ada pertanyaan seputar perawatan kulit atau kecantikan hari ini?',
|
text: 'Hai Dermalovers! 👋 Saya siap membantu anda tampil lebih percaya diri. Ada pertanyaan seputar perawatan kulit atau kecantikan hari ini?',
|
||||||
time: getTime(),
|
time: getTime(),
|
||||||
quickReplies: [
|
quickReplies: [
|
||||||
'Info layanan Dermalounge',
|
'Konsultasi estetik',
|
||||||
'Apa perawatan wajah recommended',
|
'Konsultasi kulit dan kelamin'
|
||||||
'Saya ingin konsultasi masalah kulit',
|
|
||||||
'Info lokasi & cara booking',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -20,7 +18,7 @@ const ChatBot = ({ existingConversation, readOnly, hh }) => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
const [isPoppedUp, setIsPoppedUp] = useState(false);
|
const [isPoppedUp, setIsPoppedUp] = useState('');
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
const [phoneNumber, setPhoneNumber] = useState('');
|
const [phoneNumber, setPhoneNumber] = useState('');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -50,6 +48,14 @@ const ChatBot = ({ existingConversation, readOnly, hh }) => {
|
|||||||
const message = textOverride || input.trim();
|
const message = textOverride || input.trim();
|
||||||
if (message === '') return;
|
if (message === '') return;
|
||||||
|
|
||||||
|
const session = JSON.parse(localStorage.getItem('session'));
|
||||||
|
|
||||||
|
if ((!session || !session.name || !session.phoneNumber) && messages.length > 2) {
|
||||||
|
setIsPoppedUp(message); // munculkan form input
|
||||||
|
setInput('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Show user's message immediately
|
// Show user's message immediately
|
||||||
const newMessages = [
|
const newMessages = [
|
||||||
...messages,
|
...messages,
|
||||||
@@ -80,12 +86,6 @@ const ChatBot = ({ existingConversation, readOnly, hh }) => {
|
|||||||
{ sender: 'bot', text: botAnswer, time: getTime() },
|
{ sender: 'bot', text: botAnswer, time: getTime() },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const session = JSON.parse(localStorage.getItem('session'));
|
|
||||||
|
|
||||||
if ((!session || !session.name || !session.phoneNumber) && messages.length > 2) {
|
|
||||||
setIsPoppedUp(true); // munculkan form input
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(tryCount)
|
console.log(tryCount)
|
||||||
@@ -194,7 +194,7 @@ function formatBoldText(text) {
|
|||||||
Kirim
|
Kirim
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{isPoppedUp &&
|
{isPoppedUp != '' &&
|
||||||
<div className={styles.PopUp}>
|
<div className={styles.PopUp}>
|
||||||
<div className={`${styles.message} ${styles['bot']}`}>
|
<div className={`${styles.message} ${styles['bot']}`}>
|
||||||
Untuk bisa membantu Anda lebih jauh, boleh saya tahu nama dan nomor telepon Anda?
|
Untuk bisa membantu Anda lebih jauh, boleh saya tahu nama dan nomor telepon Anda?
|
||||||
@@ -241,7 +241,8 @@ function formatBoldText(text) {
|
|||||||
sessionData.phoneNumber = phoneNumber;
|
sessionData.phoneNumber = phoneNumber;
|
||||||
|
|
||||||
localStorage.setItem('session', JSON.stringify(sessionData));
|
localStorage.setItem('session', JSON.stringify(sessionData));
|
||||||
setIsPoppedUp(false)
|
setIsPoppedUp('')
|
||||||
|
sendMessage(isPoppedUp)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -46,18 +46,9 @@ const Dashboard = () => {
|
|||||||
|
|
||||||
navigator.serviceWorker.ready.then(function (registration) {
|
navigator.serviceWorker.ready.then(function (registration) {
|
||||||
registration.pushManager.getSubscription().then(function (subscription) {
|
registration.pushManager.getSubscription().then(function (subscription) {
|
||||||
|
console.log(subscription)
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
subscription.unsubscribe().then(function (successful) {
|
subscription.unsubscribe();
|
||||||
console.log('Push subscription unsubscribed on logout:', successful);
|
|
||||||
// Optional: also notify backend to clear the token
|
|
||||||
fetch('/api/clear-subscription', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ endpoint: subscription.endpoint }),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -134,6 +125,15 @@ const Dashboard = () => {
|
|||||||
setLoading(false); // ⬅️ Setelah berhasil, hilangkan loading
|
setLoading(false); // ⬅️ Setelah berhasil, hilangkan loading
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|
||||||
|
navigator.serviceWorker.ready.then(function (registration) {
|
||||||
|
registration.pushManager.getSubscription().then(function (subscription) {
|
||||||
|
console.log(subscription)
|
||||||
|
if (subscription) {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const Login = () => {
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
© 2025 Kloowear AI - Admin Panel
|
© 2025 Kediri Technopark
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,17 +28,11 @@ const ProfileTab = () => {
|
|||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
localStorage.removeItem('user');
|
localStorage.removeItem('user');
|
||||||
|
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then(function (registration) {
|
||||||
registration.pushManager.getSubscription().then((subscription) => {
|
registration.pushManager.getSubscription().then(function (subscription) {
|
||||||
|
console.log(subscription)
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
subscription.unsubscribe().then((successful) => {
|
subscription.unsubscribe();
|
||||||
console.log('Unsubscribed from push notifications:', successful);
|
|
||||||
fetch('/api/clear-subscription', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ endpoint: subscription.endpoint }),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -73,6 +67,15 @@ const ProfileTab = () => {
|
|||||||
setProfileTemp(data.profile_data);
|
setProfileTemp(data.profile_data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Fetch error:', error);
|
console.error('Fetch error:', error);
|
||||||
|
|
||||||
|
navigator.serviceWorker.ready.then(function (registration) {
|
||||||
|
registration.pushManager.getSubscription().then(function (subscription) {
|
||||||
|
console.log(subscription)
|
||||||
|
if (subscription) {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user