feat: Enhance ChatAssistant and ProductFilters components with dynamic privacy prompts and category push notification support; update localization strings for new article notifications across multiple languages
This commit is contained in:
57
src/utils/categoryPush.js
Normal file
57
src/utils/categoryPush.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Web Push for category “new articles” notifications — same VAPID/SW as article/pickup push.
|
||||
*/
|
||||
|
||||
export {
|
||||
fetchPushConfiguration,
|
||||
registerPushServiceWorker,
|
||||
ensurePushSubscription,
|
||||
isPushApiSupported,
|
||||
parseSubscribedStatus,
|
||||
parseSuccess,
|
||||
} from "./articlePush.js";
|
||||
|
||||
/**
|
||||
* @param {number} kKategorie
|
||||
* @param {string} endpoint
|
||||
*/
|
||||
export async function categoryPushStatus(kKategorie, endpoint) {
|
||||
const res = await fetch("/api/category/push/status", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ kKategorie, endpoint }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return { ...data, httpOk: res.ok };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} kKategorie
|
||||
* @param {PushSubscription} subscription
|
||||
*/
|
||||
export async function categoryPushSubscribe(kKategorie, subscription) {
|
||||
const subJson = subscription.toJSON();
|
||||
const res = await fetch("/api/category/push/subscribe", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
kKategorie,
|
||||
subscription: subJson,
|
||||
}),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return { ...data, httpOk: res.ok };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} endpoint
|
||||
*/
|
||||
export async function categoryPushUnsubscribe(endpoint) {
|
||||
const res = await fetch("/api/category/push/unsubscribe", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ endpoint }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return { ...data, httpOk: res.ok };
|
||||
}
|
||||
Reference in New Issue
Block a user