{"version":3,"file":"content-access.js","sources":["../../../../modules/content-access/js/app.js"],"sourcesContent":["export default class ContentAccess {\r\n\tconstructor ({ customer }) {\r\n\t\tthis.customer = customer ? JSON.parse(JSON.stringify(customer)) : null;\r\n\t\tthis.pageAccessMode = window.pageAccessMode || '';\r\n\t\tthis.init();\r\n\t}\r\n\r\n\tinit() {\r\n\t\tswitch (true) {\r\n\t\t\tcase this.pageAccessMode.includes('view_customer_only'):\r\n\t\t\t\tthis.customerContent();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase this.pageAccessMode.includes('view_approved_customer_only'):\r\n\t\t\t\tthis.approvedCustomerContent();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase this.pageAccessMode.includes('price_customer_only'):\r\n\t\t\t\tthis.customerPrices();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase this.pageAccessMode.includes('price_approved_customer_only'):\r\n\t\t\t\tthis.approvedCustomerPrices();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase this.pageAccessMode.includes('public'):\r\n\t\t\t\t/*this.handlePublicContent();*/\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tcustomerContent () {\r\n\t\tif (!this.customer || this.customer.guest) {\r\n\t\t\tconst { pathname } = window.location;\r\n\t\t\tconst link = `/my/signin?next=${pathname}`;\r\n\r\n\t\t\twindow.location.href = link;\r\n\t\t}\r\n\t}\r\n\r\n\tapprovedCustomerContent () {\r\n\t\tif (!this.customer || this.customer.guest || !this.customer.is_approved) {\r\n\t\t\tconst msg = document.createElement('div');\r\n\t\t\tmsg.setAttribute('style', 'position: fixed; top: 0; left: 0; z-index: 9999; width: 100%; height: 100%; background: #fff; display: flex; justify-content: center; text-align: center; align-items: center; font-size: 16px;');\r\n\t\t\tmsg.innerHTML = 'Sorry...
To view this page, your customer account needs to be approved.
';\r\n\t\t\tdocument.body.append(msg);\r\n\t\t}\r\n\t}\r\n\r\n\tcustomerPrices () {\r\n\t\tif (!this.customer || this.customer.guest) {\r\n\t\t\tthis.hidePrices();\r\n\t\t}\r\n\t}\r\n\r\n\tapprovedCustomerPrices () {\r\n\t\tif (!this.customer || this.customer.guest || !this.customer.is_approved) {\r\n\t\t\tthis.hidePrices();\r\n\t\t}\r\n\t}\r\n\r\n\thidePrices () {\r\n\t\tconst priceRefs = document.querySelectorAll('.product-price');\r\n\r\n\t\tpriceRefs.forEach(ref => {\r\n\t\t\tref.remove();\r\n\t\t});\r\n\t}\r\n\r\n\t/*handlePublicContent() {}*/\r\n}\r\n\r\nfunction initContentAccess () {\r\n\twindow.Session.get( 'Customer' ).then( customer => {\r\n\t\tnew ContentAccess({ customer });\r\n\t});\r\n}\r\n\r\ndocument.addEventListener('[Session]:fetched', initContentAccess);\r\ndocument.addEventListener('SESSION_FETCHED', initContentAccess);\r\n"],"names":["ContentAccess","constructor","_ref","customer","this","JSON","parse","stringify","pageAccessMode","window","init","includes","customerContent","approvedCustomerContent","customerPrices","approvedCustomerPrices","guest","pathname","location","link","concat","href","is_approved","msg","document","createElement","setAttribute","innerHTML","body","append","hidePrices","querySelectorAll","forEach","ref","remove","initContentAccess","Session","get","then","addEventListener"],"mappings":"AAAe,MAAMA,EACpBC,WAAAA,CAAWC,GAAgB,IAAdC,SAAEA,GAAUD,EACxBE,KAAKD,SAAWA,EAAWE,KAAKC,MAAMD,KAAKE,UAAUJ,IAAa,KAClEC,KAAKI,eAAiBC,OAAOD,gBAAkB,GAC/CJ,KAAKM,MACN,CAEAA,IAAAA,GACC,QAAQ,GACP,KAAKN,KAAKI,eAAeG,SAAS,sBACjCP,KAAKQ,kBACL,MAED,KAAKR,KAAKI,eAAeG,SAAS,+BACjCP,KAAKS,0BACL,MAED,KAAKT,KAAKI,eAAeG,SAAS,uBACjCP,KAAKU,iBACL,MAED,KAAKV,KAAKI,eAAeG,SAAS,gCACjCP,KAAKW,yBAGN,KAAKX,KAAKI,eAAeG,SAAS,WAOp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