feat(orders): tg notifications, ya metrika, meta tags

This commit is contained in:
Nikita Kiselev
2025-08-03 09:39:51 +03:00
parent 454bd39f1f
commit 86d0fa9594
32 changed files with 1205 additions and 76 deletions

View File

@@ -0,0 +1,46 @@
class AppMetaInitializer {
private readonly settings: object;
constructor(settings: object) {
this.settings = settings;
}
public init() {
document.title = this.settings.app_name;
this.setMeta('application-name', this.settings.app_name);
this.setMeta('apple-mobile-web-app-title', this.settings.app_name);
this.setMeta('mobile-web-app-capable', 'yes');
this.setMeta('apple-mobile-web-app-capable', 'yes');
this.setMeta('apple-mobile-web-app-status-bar-style', 'default');
this.setMeta('theme-color', '#000000');
this.setMeta('msapplication-navbutton-color', '#000000');
this.setMeta('apple-mobile-web-app-status-bar-style', 'black-translucent');
this.addLink('manifest', this.settings.manifest_url);
this.addLink('icon', this.settings.app_icon192, '192x192');
this.addLink('apple-touch-icon', this.settings.app_icon192);
this.addLink('apple-touch-icon', this.settings.app_icon180, '180x180');
this.addLink('apple-touch-icon', this.settings.app_icon152, '152x152');
this.addLink('apple-touch-icon', this.settings.app_icon120, '120x120');
}
private setMeta(name: string, content: string) {
let meta = document.querySelector(`meta[name="${name}"]`);
if (!meta) {
meta = document.createElement('meta');
meta.setAttribute('name', name);
document.head.appendChild(meta);
}
meta.setAttribute('content', content);
}
private addLink(rel: string, href: string, sizes?: string) {
const link = document.createElement('link');
link.rel = rel;
link.href = href;
if (sizes) link.sizes = sizes;
document.head.appendChild(link);
}
}
export default AppMetaInitializer;

View File

@@ -59,4 +59,8 @@ export async function cartEditItem(data) {
});
}
export async function fetchSettings() {
return await ftch('settings');
}
export default ftch;

View File

@@ -0,0 +1,7 @@
export function injectYaMetrika() {
const script = document.createElement('script');
script.src = '/index.php?route=extension/tgshop/handle/ya_metrika';
script.async = true;
document.head.appendChild(script);
console.log('Yandex Metrika injected to the page.');
}