import { CocoComponent } from "@assets/js/base/coco"; import Cookies from "js-cookie"; export default CocoComponent("systemBanner", (opts = {}) => { return { cookieName: null, cookieValue: null, cookieExpiry: null, init() { this.cookieName = opts.cookieName; this.cookieValue = opts.cookieValue; this.cookieExpiry = opts.cookieExpiry; }, onDismiss() { this.$dispatch("banner:dismiss", { banner: this }); if (this.shouldSetCookie) { Cookies.set(this.cookieName, this.cookieValue, { expires: this.cookieExpiry, }); } }, remove() { this.$root.remove(); }, get shouldSetCookie() { return Number.isInteger(this.cookieExpiry); }, root: { "@alert:dismiss": "onDismiss", "@alert:removed": "remove", }, }; });