@ozdao/martyrs 0.2.489 → 0.2.491
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.cjs +4 -4
- package/dist/_virtual/index.js +4 -4
- package/dist/_virtual/index2.cjs +4 -4
- package/dist/_virtual/index2.js +4 -4
- package/dist/auth.server.cjs +2 -51
- package/dist/auth.server.js +1 -50
- package/dist/builder.cjs +90 -4
- package/dist/builder.js +90 -4
- package/dist/main-BhCqlPMQ.cjs +11 -0
- package/dist/{main-IVRL6IjM.js → main-YBlKbx0g.js} +1308 -1285
- package/dist/martyrs/src/components/Block/Block.vue.cjs +1 -1
- package/dist/martyrs/src/components/Block/Block.vue.js +1 -1
- package/dist/martyrs/src/components/Button/Button.vue2.cjs +48 -21
- package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +1 -1
- package/dist/martyrs/src/components/Button/Button.vue2.js +49 -22
- package/dist/martyrs/src/components/Button/Button.vue2.js.map +1 -1
- package/dist/martyrs/src/components/Chips/{Chips.vue2.cjs → Chips.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Chips/{Chips.vue2.js → Chips.vue.js} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue.js.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs → Dropdown.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.js → Dropdown.vue2.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs.map → Dropdown.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.cjs +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +2 -2
- package/dist/martyrs/src/components/Feed/Feed.vue.js +2 -2
- package/dist/martyrs/src/components/FieldTags/FieldTags.vue.cjs +1 -1
- package/dist/martyrs/src/components/FieldTags/FieldTags.vue.js +1 -1
- package/dist/martyrs/src/components/Loader/{Loader.vue2.cjs → Loader.vue.cjs} +3 -3
- package/dist/martyrs/src/components/Loader/Loader.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Loader/{Loader.vue2.js → Loader.vue.js} +3 -3
- package/dist/martyrs/src/components/Loader/Loader.vue.js.map +1 -0
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.js +1 -1
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.cjs → Tooltip.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js.map → Tooltip.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js → Tooltip.vue.js} +2 -2
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue.js.map +1 -0
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +2 -2
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +3 -3
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +3 -3
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.cjs +1 -2
- package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.js +1 -2
- package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +3 -3
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +3 -3
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +10 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +10 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/layouts/MusicLayout.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/layouts/MusicLayout.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs +22 -8
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js +23 -9
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.cjs +13 -15
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js +14 -16
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.cjs +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.js +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.cjs +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.js +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.js +7 -7
- package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/router/notifications.router.js +4 -4
- package/dist/martyrs/src/modules/notifications/router/notifications.router.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs +7 -10
- package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/store/notifications.store.js +7 -10
- package/dist/martyrs/src/modules/notifications/store/notifications.store.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs +0 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js +0 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/ProductDiscounts.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/blocks/ProductDiscounts.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +3 -3
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +3 -3
- package/dist/martyrs.cjs.js +1 -1
- package/dist/martyrs.css +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/notifications.server.cjs +142 -44
- package/dist/notifications.server.js +142 -44
- package/dist/orders.server.cjs +155 -102
- package/dist/orders.server.js +155 -102
- package/dist/products.server.cjs +4 -0
- package/dist/products.server.js +4 -0
- package/dist/profile.schema-BGAe5VN5.js +92 -0
- package/dist/profile.schema-pidHrksV.cjs +91 -0
- package/dist/style.css +65 -247
- package/dist/{web-BXhlxo6M.cjs → web-BBmMBRv-.cjs} +1 -1
- package/dist/{web-Czi05iGG.js → web-Dqu-aCL5.js} +1 -1
- package/package.json +1 -1
- package/src/builder/rspack/rspack.config.spa.client.js +46 -1
- package/src/builder/rspack/rspack.config.ssr.client.js +43 -0
- package/src/builder/templates/page.js +1 -1
- package/src/components/Button/Button.vue +230 -196
- package/src/components/Loader/Loader.vue +1 -1
- package/src/modules/auth/controllers/middlewares/visitor.logger.js +22 -0
- package/src/modules/globals/globals.client.js +1 -1
- package/src/modules/globals/views/components/layouts/Client.vue +10 -9
- package/src/modules/notifications/FIXES.md +4 -0
- package/src/modules/notifications/components/layouts/NotificationsLayout.vue +33 -32
- package/src/modules/notifications/components/pages/Notifications.vue +10 -51
- package/src/modules/notifications/components/sections/NotificationPreferences.vue +1 -11
- package/src/modules/notifications/components/sections/NotificationsList.vue +1 -1
- package/src/modules/notifications/controllers/notifications.controller.js +50 -4
- package/src/modules/notifications/notifications.client.js +1 -1
- package/src/modules/notifications/notifications.server.js +18 -7
- package/src/modules/notifications/routes/notifications.routes.js +4 -2
- package/src/modules/notifications/services/notification.service.js +109 -38
- package/src/modules/notifications/services/telegram.service.js +1 -0
- package/src/modules/notifications/services/whatsapp.service.js +1 -0
- package/src/modules/notifications/store/notifications.store.js +25 -16
- package/src/modules/orders/components/partials/ShopCart.vue +0 -1
- package/src/modules/orders/controllers/orders.controller.js +195 -85
- package/src/modules/products/controllers/products.controller.js +4 -0
- package/dist/main-CmuUC0tl.cjs +0 -11
- package/dist/martyrs/src/components/Chips/Chips.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Chips/Chips.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.cjs +0 -200
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.js +0 -200
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.js.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.cjs +0 -21
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.js +0 -21
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.cjs +0 -9
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +0 -9
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/defaultOptions.cjs +0 -8
- package/dist/node_modules/date-fns/_lib/defaultOptions.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +0 -8
- package/dist/node_modules/date-fns/_lib/defaultOptions.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/formatters.cjs +0 -653
- package/dist/node_modules/date-fns/_lib/format/formatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/formatters.js +0 -653
- package/dist/node_modules/date-fns/_lib/format/formatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.cjs +0 -63
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +0 -63
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/longFormatters.cjs +0 -59
- package/dist/node_modules/date-fns/_lib/format/longFormatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +0 -59
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.cjs +0 -21
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +0 -21
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/normalizeDates.cjs +0 -12
- package/dist/node_modules/date-fns/_lib/normalizeDates.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +0 -12
- package/dist/node_modules/date-fns/_lib/normalizeDates.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/protectedTokens.cjs +0 -24
- package/dist/node_modules/date-fns/_lib/protectedTokens.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +0 -24
- package/dist/node_modules/date-fns/_lib/protectedTokens.js.map +0 -1
- package/dist/node_modules/date-fns/constants.cjs +0 -9
- package/dist/node_modules/date-fns/constants.cjs.map +0 -1
- package/dist/node_modules/date-fns/constants.js +0 -9
- package/dist/node_modules/date-fns/constants.js.map +0 -1
- package/dist/node_modules/date-fns/constructFrom.cjs +0 -13
- package/dist/node_modules/date-fns/constructFrom.cjs.map +0 -1
- package/dist/node_modules/date-fns/constructFrom.js +0 -13
- package/dist/node_modules/date-fns/constructFrom.js.map +0 -1
- package/dist/node_modules/date-fns/differenceInCalendarDays.cjs +0 -21
- package/dist/node_modules/date-fns/differenceInCalendarDays.cjs.map +0 -1
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +0 -21
- package/dist/node_modules/date-fns/differenceInCalendarDays.js.map +0 -1
- package/dist/node_modules/date-fns/format.cjs +0 -80
- package/dist/node_modules/date-fns/format.cjs.map +0 -1
- package/dist/node_modules/date-fns/format.js +0 -80
- package/dist/node_modules/date-fns/format.js.map +0 -1
- package/dist/node_modules/date-fns/getDayOfYear.cjs +0 -14
- package/dist/node_modules/date-fns/getDayOfYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getDayOfYear.js +0 -14
- package/dist/node_modules/date-fns/getDayOfYear.js.map +0 -1
- package/dist/node_modules/date-fns/getISOWeek.cjs +0 -14
- package/dist/node_modules/date-fns/getISOWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/getISOWeek.js +0 -14
- package/dist/node_modules/date-fns/getISOWeek.js.map +0 -1
- package/dist/node_modules/date-fns/getISOWeekYear.cjs +0 -27
- package/dist/node_modules/date-fns/getISOWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getISOWeekYear.js +0 -27
- package/dist/node_modules/date-fns/getISOWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/getWeek.cjs +0 -14
- package/dist/node_modules/date-fns/getWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/getWeek.js +0 -14
- package/dist/node_modules/date-fns/getWeek.js.map +0 -1
- package/dist/node_modules/date-fns/getWeekYear.cjs +0 -31
- package/dist/node_modules/date-fns/getWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getWeekYear.js +0 -31
- package/dist/node_modules/date-fns/getWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/isDate.cjs +0 -8
- package/dist/node_modules/date-fns/isDate.cjs.map +0 -1
- package/dist/node_modules/date-fns/isDate.js +0 -8
- package/dist/node_modules/date-fns/isDate.js.map +0 -1
- package/dist/node_modules/date-fns/isValid.cjs +0 -10
- package/dist/node_modules/date-fns/isValid.cjs.map +0 -1
- package/dist/node_modules/date-fns/isValid.js +0 -10
- package/dist/node_modules/date-fns/isValid.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.cjs +0 -11
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +0 -11
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.cjs +0 -21
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +0 -21
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.cjs +0 -44
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +0 -44
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.cjs +0 -17
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +0 -17
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.cjs +0 -86
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +0 -86
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.cjs +0 -37
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +0 -37
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.cjs +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.cjs +0 -165
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +0 -165
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.cjs +0 -123
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +0 -123
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US.cjs +0 -22
- package/dist/node_modules/date-fns/locale/en-US.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US.js +0 -22
- package/dist/node_modules/date-fns/locale/en-US.js.map +0 -1
- package/dist/node_modules/date-fns/startOfDay.cjs +0 -11
- package/dist/node_modules/date-fns/startOfDay.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfDay.js +0 -11
- package/dist/node_modules/date-fns/startOfDay.js.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeek.cjs +0 -9
- package/dist/node_modules/date-fns/startOfISOWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeek.js +0 -9
- package/dist/node_modules/date-fns/startOfISOWeek.js.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeekYear.cjs +0 -15
- package/dist/node_modules/date-fns/startOfISOWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +0 -15
- package/dist/node_modules/date-fns/startOfISOWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/startOfWeek.cjs +0 -18
- package/dist/node_modules/date-fns/startOfWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfWeek.js +0 -18
- package/dist/node_modules/date-fns/startOfWeek.js.map +0 -1
- package/dist/node_modules/date-fns/startOfWeekYear.cjs +0 -20
- package/dist/node_modules/date-fns/startOfWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfWeekYear.js +0 -20
- package/dist/node_modules/date-fns/startOfWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/startOfYear.cjs +0 -12
- package/dist/node_modules/date-fns/startOfYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfYear.js +0 -12
- package/dist/node_modules/date-fns/startOfYear.js.map +0 -1
- package/dist/node_modules/date-fns/toDate.cjs +0 -9
- package/dist/node_modules/date-fns/toDate.cjs.map +0 -1
- package/dist/node_modules/date-fns/toDate.js +0 -9
- package/dist/node_modules/date-fns/toDate.js.map +0 -1
- package/dist/profile.schema-DchVS-Jr.js +0 -21
- package/dist/profile.schema-yQuIzngl.cjs +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.register('/sw.js');\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n // Отправь подписку на сервер\n await store.notifications.actions.registerDevice({\n deviceToken: JSON.stringify(subscription),\n deviceType: 'web',\n });\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n\n console.log('Connecting to websockets via notifications');\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // 🎯 Опционально включаем push\n if (this.options.enablePush !== false) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n\n // ✅ Загружаем список уведомлений из API\n await this.store.notifications.actions.getNotifications(userId);\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize after auth is confirmed\n const isAuthenticated = store.auth.state.access.status;\n const userId = store.auth.state.user?._id;\n\n if (isAuthenticated && userId) {\n notificationManager.initialize();\n }\n\n // Watch for user login/logout using auth store\n watch(\n () => store.auth.state.access.status,\n isAuthenticated => {\n if (isAuthenticated) {\n notificationManager.initialize();\n } else {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["routerNotifications","storeNotifications","isAuthenticated"],"mappings":";;;;;;;;;;AAsBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK,QAAQ;AACb,SAAK,oBAAoB;AACzB,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKE,MAAM,aAAa;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,QAAI;AAEF,YAAM,EAAE,UAAS,IAAK,MAAM,OAAO,8FAAiB;AACpD,YAAM,EAAE,kBAAiB,IAAK,MAAM,OAAO,uJAA+B;AAC1E,YAAM,EAAE,OAAM,IAAK,MAAM,OAAO,+HAAmB;AAEnD,WAAK,YAAY;AACjB,WAAK,oBAAoB;AACzB,WAAK,SAAS;AAGd,UAAI,CAAC,KAAK,UAAU,oBAAoB;AACtC,eAAO;AAAA,MACf;AAEM,WAAK,gBAAgB;AACrB,aAAO;AAAA,IACR,SAAQ,OAAO;AACd,cAAQ,MAAM,sCAAsC,KAAK;AACzD,aAAO;AAAA,IACb;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKE,MAAM,qBAAqB;AAEzB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IAC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AMD;AAAAA,IACD;AAAA,IACD,YAAY;AAAA;AAAA,MAEV;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,IACD;AAAA,EACF;AACH;"}
|
|
1
|
+
{"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { toRefs, watch } from 'vue';\n// Router import\nimport routerNotifications from './router/notifications.router.js';\n// Store\nimport * as storeNotifications from './store/notifications.store.js';\n// Auth store import\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Layouts\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\n// Sections\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\n// Pages\nimport Notifications from './components/pages/Notifications.vue';\n// Components\nimport NotificationItem from './components/blocks/NotificationItem.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n\n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n\n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n // Set up event listeners\n this._setupListeners();\n\n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', this._handleRegistration.bind(this));\n\n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived', this._handleNotificationReceived.bind(this));\n\n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed', this._handleNotificationAction.bind(this));\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n\n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value,\n };\n\n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {},\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\n\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n async registerWebPush(store) {\n if (!('Notification' in window) || !('serviceWorker' in navigator) || !('PushManager' in window)) {\n console.warn('Web Push не поддерживается в браузере');\n return;\n }\n\n const permission = await Notification.requestPermission();\n if (permission !== 'granted') {\n console.warn('Разрешение на уведомления не получено');\n return;\n }\n\n const registration = await navigator.serviceWorker.ready;\n const subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: 'BJtNnRrx05VQS0abnkHC-8gHJWpnmoqC_iQveENCmZOZIs-adWzqAiqFCdGVVd7CbiaLW-Q5iuIBDRgM9G-VnKg',\n });\n\n console.log('New subscription:', JSON.stringify(subscription));\n\n // Отправь подписку на сервер\n await store.notifications.actions.registerDevice({\n deviceToken: JSON.stringify(subscription),\n deviceType: 'web',\n });\n }\n\n async initialize() {\n if (this.initialized || this.isServer) return;\n\n const userId = this.store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n\n console.log('Connecting to websockets via notifications');\n await globalWebSocket.connect(userId);\n\n globalWebSocket.removeModuleListeners('notification');\n\n await globalWebSocket.subscribeModule('notification');\n\n globalWebSocket.addEventListener(\n 'notification',\n data => {\n this.store.notifications.actions.addLocalNotification(data.data);\n },\n { module: 'notification' }\n );\n\n // 🎯 Опционально включаем push\n if (this.options.enablePush !== false) {\n await this.pushHandler.requestPermissions();\n await this.registerWebPush(this.store);\n }\n\n this.initialized = true;\n\n // ✅ Загружаем список уведомлений из API\n await this.store.notifications.actions.getNotifications(userId);\n }\n\n disconnect() {\n if (this.isServer) return;\n\n globalWebSocket.removeModuleListeners('notification');\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n },\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n\n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000,\n });\n\n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n\n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n if (autoInit) {\n // Initialize after auth is confirmed\n const isAuthenticated = store.auth.state.access.status;\n const userId = store.auth.state.user?._id;\n\n if (isAuthenticated && userId) {\n notificationManager.initialize();\n }\n\n // Watch for user login/logout using auth store\n watch(\n () => store.auth.state.access.status,\n isAuthenticated => {\n if (isAuthenticated) {\n notificationManager.initialize();\n } else {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n }\n }\n );\n }\n\n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer,\n };\n });\n\n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications,\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n },\n },\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // Sections\n NotificationsList,\n // SSR Utilities\n SSRUtils,\n};\n\nexport default ModuleNotifications;\n"],"names":["routerNotifications","storeNotifications","isAuthenticated","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;AAsBA,MAAM,qBAAqB;AAAA,EACzB,YAAY,OAAO;AACjB,SAAK,QAAQ;AACb,SAAK,oBAAoB;AACzB,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKE,MAAM,aAAa;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,QAAI;AAEF,YAAM,EAAE,UAAS,IAAK,MAAM,OAAO,8FAAiB;AACpD,YAAM,EAAE,kBAAiB,IAAK,MAAM,OAAO,uJAA+B;AAC1E,YAAM,EAAE,OAAM,IAAK,MAAM,OAAO,+HAAmB;AAEnD,WAAK,YAAY;AACjB,WAAK,oBAAoB;AACzB,WAAK,SAAS;AAGd,UAAI,CAAC,KAAK,UAAU,oBAAoB;AACtC,eAAO;AAAA,MACf;AAEM,WAAK,gBAAgB;AACrB,aAAO;AAAA,IACR,SAAQ,OAAO;AACd,cAAQ,MAAM,sCAAsC,KAAK;AACzD,aAAO;AAAA,IACb;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKE,MAAM,qBAAqB;AAEzB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,QAAI,CAAC,KAAK,eAAe;AACvB,YAAM,cAAc,MAAM,KAAK,WAAY;AAC3C,UAAI,CAAC,YAAa,QAAO;AAAA,IAC/B;AAEI,QAAI;AAEF,YA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AAMC;AAAAA,IACD;AAAA,EACF;AACH;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _sfc_main$1 from "../components/layouts/NotificationsLayout.vue.js";
|
|
2
|
+
import _sfc_main from "../components/pages/Notifications.vue.js";
|
|
3
3
|
import NotificationPreferences from "../components/sections/NotificationPreferences.vue.js";
|
|
4
4
|
const nofitications = {
|
|
5
5
|
path: "/notifications",
|
|
6
|
-
component:
|
|
6
|
+
component: _sfc_main$1,
|
|
7
7
|
children: [
|
|
8
8
|
{
|
|
9
9
|
path: "",
|
|
10
10
|
name: "Notifications",
|
|
11
|
-
component:
|
|
11
|
+
component: _sfc_main,
|
|
12
12
|
meta: {
|
|
13
13
|
// requiresAuth: true,
|
|
14
14
|
title: "Notifications"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.router.js","sources":["../../../../../../src/modules/notifications/router/notifications.router.js"],"sourcesContent":["import NotificationsLayout from '../components/layouts/NotificationsLayout.vue';\nimport Notifications from '../components/pages/Notifications.vue';\nimport NotificationPreferences from '../components/sections/NotificationPreferences.vue';\n\nconst nofitications = {\n path: '/notifications',\n component: NotificationsLayout,\n children: [\n {\n path: '',\n name: 'Notifications',\n component: Notifications,\n meta: {\n // requiresAuth: true,\n title: 'Notifications',\n },\n },\n {\n path: 'preferences',\n name: 'NotificationPreferences',\n component: NotificationPreferences,\n meta: {\n // requiresAuth: true,\n title: 'Notification Preferences',\n },\n },\n ],\n};\n\nexport default nofitications;\n"],"names":[],"mappings":";;;AAIK,MAAC,gBAAgB;AAAA,EACpB,MAAM;AAAA,EACN,
|
|
1
|
+
{"version":3,"file":"notifications.router.js","sources":["../../../../../../src/modules/notifications/router/notifications.router.js"],"sourcesContent":["import NotificationsLayout from '../components/layouts/NotificationsLayout.vue';\nimport Notifications from '../components/pages/Notifications.vue';\nimport NotificationPreferences from '../components/sections/NotificationPreferences.vue';\n\nconst nofitications = {\n path: '/notifications',\n component: NotificationsLayout,\n children: [\n {\n path: '',\n name: 'Notifications',\n component: Notifications,\n meta: {\n // requiresAuth: true,\n title: 'Notifications',\n },\n },\n {\n path: 'preferences',\n name: 'NotificationPreferences',\n component: NotificationPreferences,\n meta: {\n // requiresAuth: true,\n title: 'Notification Preferences',\n },\n },\n ],\n};\n\nexport default nofitications;\n"],"names":["NotificationsLayout","Notifications"],"mappings":";;;AAIK,MAAC,gBAAgB;AAAA,EACpB,MAAM;AAAA,EACN,WAAWA;AAAAA,EACX,UAAU;AAAA,IACR;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAWC;AAAAA,MACX,MAAM;AAAA;AAAA,QAEJ,OAAO;AAAA,MACR;AAAA,IACF;AAAA,IACD;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,MAAM;AAAA;AAAA,QAEJ,OAAO;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACH;"}
|
|
@@ -196,17 +196,9 @@ const actions = {
|
|
|
196
196
|
*/
|
|
197
197
|
handleNotificationAction(data) {
|
|
198
198
|
if (data.notificationId) {
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
if (data.route) {
|
|
202
|
-
alert("1");
|
|
203
|
-
} else if (data.type === "order") {
|
|
204
|
-
alert("2");
|
|
205
|
-
} else if (data.type === "message") {
|
|
206
|
-
alert("3");
|
|
207
|
-
} else {
|
|
208
|
-
alert("4");
|
|
199
|
+
actions.markAsRead(data.notificationId);
|
|
209
200
|
}
|
|
201
|
+
return true;
|
|
210
202
|
},
|
|
211
203
|
/**
|
|
212
204
|
* Mark all notifications as read
|
|
@@ -218,12 +210,17 @@ const actions = {
|
|
|
218
210
|
console.warn("Cannot mark all as read: No user ID found");
|
|
219
211
|
return;
|
|
220
212
|
}
|
|
213
|
+
console.log("=== markAllAsRead API call ===");
|
|
214
|
+
console.log("URL:", `/api/notifications/user/${userId}/read-all`);
|
|
221
215
|
const response = await axiosInstance.default.put(`/api/notifications/user/${userId}/read-all`);
|
|
216
|
+
console.log("markAllAsRead response status:", response.status);
|
|
217
|
+
console.log("markAllAsRead response data:", response.data);
|
|
222
218
|
state.notifications.forEach((notification) => {
|
|
223
219
|
notification.status = "read";
|
|
224
220
|
notification.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
225
221
|
});
|
|
226
222
|
updateUnreadCount();
|
|
223
|
+
console.log("Local state updated, unread count:", state.unreadCount);
|
|
227
224
|
return response.data;
|
|
228
225
|
} catch (error) {
|
|
229
226
|
globals.setError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.store.cjs","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n // Add the current user ID to the device data\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot register device: No user ID found');\n return;\n }\n\n deviceData.userId = userId;\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n this.markAsRead(data.notificationId);\n }\n\n // Navigate based on notification type and metadata\n if (data.route) {\n // router.push(data.route);\n alert('1');\n } else if (data.type === 'order') {\n // router.push(`/orders/${data.orderId}`);\n alert('2');\n } else if (data.type === 'message') {\n // router.push('/messages');\n alert('3');\n } else {\n // Default to notifications page\n // router.push('/notifications');\n alert('4');\n }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["reactive","auth.state","$axios","setError","watch","computed"],"mappings":";;;;;;AAUA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAE;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,eAAe,CAAE;AAAA,EACjB,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAuB;AAAA,EACrC,aAAa,EAA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AAAA,EAC9D,CAAG;AAAA,EAED,mBAAmBA,IAAQ,SAAC,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,qBAAqBA,IAAQ,SAAC,MAAM;AAClC,UAAM,SAAS,CAAE;AACjB,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAE;AAAA,MACtC;AACM,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IACjD,CAAK;AACD,WAAO;AAAA,EACX,CAAG;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"notifications.store.cjs","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n // Add the current user ID to the device data\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot register device: No user ID found');\n return;\n }\n\n deviceData.userId = userId;\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["reactive","auth.state","$axios","setError","watch","computed"],"mappings":";;;;;;AAUA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAE;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;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AS,oBAAoB;AAC3B,QAAM,cAAc,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM,EAAE;AAC3E;AAMAC,IAAAA,MAAM,OAAO,cAAY;AAEzB,CAAC;AAGI,MAAC,UAAU;AAAA,EACd,qBAAqBC,IAAQ,SAAC,MAAM;AAClC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,mBAAmBA,IAAQ,SAAC,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,qBAAqBA,IAAQ,SAAC,MAAM;AAClC,UAAM,SAAS,CAAE;AACjB,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAE;AAAA,MACtC;AACM,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IACjD,CAAK;AACD,WAAO;AAAA,EACX,CAAG;AACH;;;;;"}
|
|
@@ -194,17 +194,9 @@ const actions = {
|
|
|
194
194
|
*/
|
|
195
195
|
handleNotificationAction(data) {
|
|
196
196
|
if (data.notificationId) {
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
if (data.route) {
|
|
200
|
-
alert("1");
|
|
201
|
-
} else if (data.type === "order") {
|
|
202
|
-
alert("2");
|
|
203
|
-
} else if (data.type === "message") {
|
|
204
|
-
alert("3");
|
|
205
|
-
} else {
|
|
206
|
-
alert("4");
|
|
197
|
+
actions.markAsRead(data.notificationId);
|
|
207
198
|
}
|
|
199
|
+
return true;
|
|
208
200
|
},
|
|
209
201
|
/**
|
|
210
202
|
* Mark all notifications as read
|
|
@@ -216,12 +208,17 @@ const actions = {
|
|
|
216
208
|
console.warn("Cannot mark all as read: No user ID found");
|
|
217
209
|
return;
|
|
218
210
|
}
|
|
211
|
+
console.log("=== markAllAsRead API call ===");
|
|
212
|
+
console.log("URL:", `/api/notifications/user/${userId}/read-all`);
|
|
219
213
|
const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);
|
|
214
|
+
console.log("markAllAsRead response status:", response.status);
|
|
215
|
+
console.log("markAllAsRead response data:", response.data);
|
|
220
216
|
state.notifications.forEach((notification) => {
|
|
221
217
|
notification.status = "read";
|
|
222
218
|
notification.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
223
219
|
});
|
|
224
220
|
updateUnreadCount();
|
|
221
|
+
console.log("Local state updated, unread count:", state.unreadCount);
|
|
225
222
|
return response.data;
|
|
226
223
|
} catch (error) {
|
|
227
224
|
setError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.store.js","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n // Add the current user ID to the device data\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot register device: No user ID found');\n return;\n }\n\n deviceData.userId = userId;\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n this.markAsRead(data.notificationId);\n }\n\n // Navigate based on notification type and metadata\n if (data.route) {\n // router.push(data.route);\n alert('1');\n } else if (data.type === 'order') {\n // router.push(`/orders/${data.orderId}`);\n alert('2');\n } else if (data.type === 'message') {\n // router.push('/messages');\n alert('3');\n } else {\n // Default to notifications page\n // router.push('/notifications');\n alert('4');\n }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["auth.state"],"mappings":";;;;AAUA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAE;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQ,SAAS;AAAA,EACrB,eAAe,CAAE;AAAA,EACjB,aAAa;AAAA,EACb,SAAS,EAAE,GAAG,sBAAuB;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c,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,qBAAqB,SAAS,MAAM;AAClC,UAAM,SAAS,CAAE;AACjB,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAE;AAAA,MACtC;AACM,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IACjD,CAAK;AACD,WAAO;AAAA,EACX,CAAG;AACH;"}
|
|
1
|
+
{"version":3,"file":"notifications.store.js","sources":["../../../../../../src/modules/notifications/store/notifications.store.js"],"sourcesContent":["// Dependencies\nimport { computed, reactive, watch } from 'vue';\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals.js';\n// Auth\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n\n// Initial state for a notification\nconst notificationInitState = {\n _id: null,\n title: '',\n body: '',\n type: 'info',\n metadata: {},\n userId: null,\n status: 'pending',\n createdAt: null,\n updatedAt: null,\n};\n\n// Initial state for notification preferences\nconst preferencesInitState = {\n web: true,\n push: true,\n email: true,\n sms: true,\n telegram: false,\n whatsapp: false,\n};\n\n// State declaration\nconst state = reactive({\n notifications: [],\n unreadCount: 0,\n current: { ...notificationInitState },\n preferences: { ...preferencesInitState },\n deviceRegistered: false,\n loading: false,\n lastSync: null,\n});\n\nconst actions = {\n /**\n * Get user notifications from server\n */\n async getNotifications(userId = null) {\n try {\n // Use provided userId or get from auth store\n const userIdToUse = userId || auth.state.user._id;\n\n if (!userIdToUse) {\n console.warn('Cannot get notifications: No user ID found');\n return [];\n }\n\n state.loading = true;\n const response = await $axios.get(`/api/notifications/user/${userIdToUse}`);\n state.notifications = response.data;\n state.lastSync = new Date().toISOString();\n updateUnreadCount();\n state.loading = false;\n return response.data;\n } catch (error) {\n state.loading = false;\n setError(error);\n throw error;\n }\n },\n\n /**\n * Mark a notification as read\n */\n async markAsRead(notificationId) {\n try {\n const response = await $axios.put(`/api/notifications/${notificationId}/read`);\n\n // Update the notification in the local state\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index] = response.data;\n updateUnreadCount();\n }\n\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Synchronize notification status without API call\n * (For use with WebSocket updates)\n */\n syncNotificationStatus(notificationId, status) {\n const index = state.notifications.findIndex(n => n._id === notificationId);\n if (index !== -1) {\n state.notifications[index].status = status;\n state.notifications[index].updatedAt = new Date().toISOString();\n updateUnreadCount();\n }\n },\n\n /**\n * Register a device for push notifications\n */\n async registerDevice(deviceData) {\n try {\n // Add the current user ID to the device data\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot register device: No user ID found');\n return;\n }\n\n deviceData.userId = userId;\n\n const response = await $axios.post('/api/notifications/devices/register', deviceData);\n state.deviceRegistered = true;\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Update notification preferences\n */\n async updatePreferences(preferences) {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot update preferences: No user ID found');\n return;\n }\n\n // Transform preferences object to array format expected by the API\n const preferencesArray = Object.entries(preferences).map(([channelType, isEnabled]) => {\n return {\n channelType,\n notificationType: 'all', // Default type, can be made more specific\n isEnabled,\n };\n });\n\n const response = await $axios.put('/api/notifications/preferences', {\n userId,\n preferences: preferencesArray,\n });\n\n // Update state with new preferences\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n\n /**\n * Get notification preferences\n */\n async getPreferences() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot get preferences: No user ID found');\n return;\n }\n\n // Assuming an endpoint exists to fetch preferences\n const response = await $axios.get(`/api/notifications/preferences/${userId}`);\n\n // Transform API response to our state format\n const newPreferences = {};\n response.data.forEach(pref => {\n newPreferences[pref.channelType] = pref.isEnabled;\n });\n\n state.preferences = { ...preferencesInitState, ...newPreferences };\n return response.data;\n } catch (error) {\n setError(error);\n // If API fails, use default preferences\n state.preferences = { ...preferencesInitState };\n throw error;\n }\n },\n\n /**\n * Add a local notification (for handling push notifications or WebSocket notifications)\n */\n addLocalNotification(notification) {\n // Check if notification already exists by ID to prevent duplicates\n if (notification._id) {\n const existingIndex = state.notifications.findIndex(n => n._id === notification._id);\n if (existingIndex !== -1) {\n // Update existing notification\n state.notifications[existingIndex] = {\n ...state.notifications[existingIndex],\n ...notification,\n updatedAt: new Date().toISOString(),\n };\n updateUnreadCount();\n return;\n }\n }\n\n // Create a notification object that matches our expected format\n const newNotification = {\n _id: notification._id || Date.now().toString(), // Use provided ID or generate temporary one\n title: notification.title,\n body: notification.body,\n type: notification.type || notification.data?.type || 'info',\n metadata: notification.data || notification.metadata || {},\n status: notification.status || 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString(),\n };\n\n // Add to local state\n state.notifications.unshift(newNotification);\n updateUnreadCount();\n },\n\n /**\n * Handle notification action (e.g., when user taps on push notification)\n */\n handleNotificationAction(data) {\n // Mark notification as read if ID is provided\n if (data.notificationId) {\n actions.markAsRead(data.notificationId);\n }\n\n return true\n\n // // Navigate based on notification type and metadata\n // if (data.route) {\n // // router.push(data.route);\n // alert('1');\n // } else if (data.type === 'order') {\n // // router.push(`/orders/${data.orderId}`);\n // alert('2');\n // } else if (data.type === 'message') {\n // // router.push('/messages');\n // alert('3');\n // } else {\n // // Default to notifications page\n // // router.push('/notifications');\n // alert('4');\n // }\n },\n\n /**\n * Mark all notifications as read\n */\n async markAllAsRead() {\n try {\n const userId = auth.state.user._id;\n if (!userId) {\n console.warn('Cannot mark all as read: No user ID found');\n return;\n }\n\n console.log('=== markAllAsRead API call ===');\n console.log('URL:', `/api/notifications/user/${userId}/read-all`);\n \n const response = await $axios.put(`/api/notifications/user/${userId}/read-all`);\n \n console.log('markAllAsRead response status:', response.status);\n console.log('markAllAsRead response data:', response.data);\n\n // Update all notifications in local state\n state.notifications.forEach(notification => {\n notification.status = 'read';\n notification.updatedAt = new Date().toISOString();\n });\n\n updateUnreadCount();\n console.log('Local state updated, unread count:', state.unreadCount);\n return response.data;\n } catch (error) {\n setError(error);\n throw error;\n }\n },\n};\n\nconst mutations = {\n resetNotifications() {\n state.notifications = [];\n state.unreadCount = 0;\n state.lastSync = null;\n },\n\n resetCurrent() {\n state.current = { ...notificationInitState };\n },\n\n resetPreferences() {\n state.preferences = { ...preferencesInitState };\n },\n};\n\n// Helper functions\nfunction updateUnreadCount() {\n state.unreadCount = state.notifications.filter(n => n.status !== 'read').length;\n}\n\n// Track state changes\nconst history = [];\nhistory.push(state);\n\nwatch(state, newState => {\n history.push(newState);\n});\n\n// Computed properties\nconst getters = {\n unreadNotifications: computed(() => {\n return state.notifications.filter(n => n.status !== 'read');\n }),\n\n readNotifications: computed(() => {\n return state.notifications.filter(n => n.status === 'read');\n }),\n\n notificationsByType: computed(() => {\n const result = {};\n state.notifications.forEach(notification => {\n if (!result[notification.type]) {\n result[notification.type] = [];\n }\n result[notification.type].push(notification);\n });\n return result;\n }),\n};\n\nexport { actions, getters, mutations, state };\n"],"names":["auth.state"],"mappings":";;;;AAUA,MAAM,wBAAwB;AAAA,EAC5B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,CAAE;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAGA,MAAM,uBAAuB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAGK,MAAC,QAAQ,SAAS;AAA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OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,mBAAmB,SAAS,MAAM;AAChC,WAAO,MAAM,cAAc,OAAO,OAAK,EAAE,WAAW,MAAM;AAAA,EAC9D,CAAG;AAAA,EAED,qBAAqB,SAAS,MAAM;AAClC,UAAM,SAAS,CAAE;AACjB,UAAM,cAAc,QAAQ,kBAAgB;AAC1C,UAAI,CAAC,OAAO,aAAa,IAAI,GAAG;AAC9B,eAAO,aAAa,IAAI,IAAI,CAAE;AAAA,MACtC;AACM,aAAO,aAAa,IAAI,EAAE,KAAK,YAAY;AAAA,IACjD,CAAK;AACD,WAAO;AAAA,EACX,CAAG;AACH;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const vue = require("vue");
|
|
4
|
-
const Tooltip = require("../../../../components/Tooltip/Tooltip.
|
|
4
|
+
const Tooltip = require("../../../../components/Tooltip/Tooltip.vue.cjs");
|
|
5
5
|
const IconStatusCreated = require("../icons/IconStatusCreated.vue.cjs");
|
|
6
6
|
const IconStatusConfirmed = require("../icons/IconStatusConfirmed.vue.cjs");
|
|
7
7
|
const IconStatusInUse = require("../icons/IconStatusInUse.vue.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, Fragment, renderList, toDisplayString, createVNode, withCtx, createBlock, resolveDynamicComponent } from "vue";
|
|
2
|
-
import _sfc_main$7 from "../../../../components/Tooltip/Tooltip.
|
|
2
|
+
import _sfc_main$7 from "../../../../components/Tooltip/Tooltip.vue.js";
|
|
3
3
|
import _sfc_main$6 from "../icons/IconStatusCreated.vue.js";
|
|
4
4
|
import _sfc_main$5 from "../icons/IconStatusConfirmed.vue.js";
|
|
5
5
|
import _sfc_main$2 from "../icons/IconStatusInUse.vue.js";
|
|
@@ -10,7 +10,7 @@ const CardOrderItem = require("../blocks/CardOrderItem.vue.cjs");
|
|
|
10
10
|
const CardOrganization = require("../../../organizations/components/blocks/CardOrganization.vue.cjs");
|
|
11
11
|
const ChatPage = require("../../../chats/components/pages/ChatPage.vue.cjs");
|
|
12
12
|
const PriceTotal = require("../elements/PriceTotal.vue.cjs");
|
|
13
|
-
;/* empty css
|
|
13
|
+
;/* empty css */
|
|
14
14
|
const globals = require("../../../globals/views/store/globals.cjs");
|
|
15
15
|
const auth = require("../../../auth/views/store/auth.cjs");
|
|
16
16
|
const orders = require("../../store/orders.cjs");
|
|
@@ -8,7 +8,7 @@ import _sfc_main$3 from "../blocks/CardOrderItem.vue.js";
|
|
|
8
8
|
import _sfc_main$5 from "../../../organizations/components/blocks/CardOrganization.vue.js";
|
|
9
9
|
import _sfc_main$6 from "../../../chats/components/pages/ChatPage.vue.js";
|
|
10
10
|
import _sfc_main$4 from "../elements/PriceTotal.vue.js";
|
|
11
|
-
/* empty css
|
|
11
|
+
/* empty css */
|
|
12
12
|
import { state } from "../../../globals/views/store/globals.js";
|
|
13
13
|
import { state as state$1 } from "../../../auth/views/store/auth.js";
|
|
14
14
|
import { actions, state as state$2, getters, mutations } from "../../store/orders.js";
|
|
@@ -75,7 +75,6 @@ const _sfc_main = {
|
|
|
75
75
|
!(shopcart.state.positions.length > 0) ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_6, [
|
|
76
76
|
vue.createElementVNode("i", null, vue.toDisplayString(vue.unref(t)("emptystate")), 1)
|
|
77
77
|
])) : vue.createCommentVNode("", true),
|
|
78
|
-
vue.createElementVNode("pre", null, vue.toDisplayString(shopcart.state.positions), 1),
|
|
79
78
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(shopcart.state.positions, (product, index) => {
|
|
80
79
|
return vue.openBlock(), vue.createBlock(CardOrderItem.default, {
|
|
81
80
|
key: `${product._id}_${product.variant || "no-variant"}_${index}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopCart.vue.cjs","sources":["../../../../../../../src/modules/orders/components/partials/ShopCart.vue"],"sourcesContent":["<template>\n\t<section class=\"z-index-5 flex flex-column transition-ease-in-out bg-white shop-cart\" :class=\"{'shop-cart-active':shopcart.state.currentState === true}\">\n <!-- ---------------------------------------------------------------- -->\n <!-- 01. Popup Header -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big mobile:pd-medium pd-b-zero mobile:pd-b-zero flex-nowrap flex\">\n <div class=\"mn-b-medium w-100\">\n <h4 class=\"mn-b-thin p-semi\">{{t('title')}}</h4>\n <p class=\"t-transp p-small\">{{t('subtitle')}} {{ t('positions', { count: StoreCartAmount }) }}</p>\n </div>\n <IconCross @click=\"shopcart.actions.toggleShopcart\" class=\"cursor-pointer i-medium button-icon\"/>\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 02. Popup Content -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big pd-t-zero mobile:pd-t-zero mobile:pd-medium h-70 flex flex-column w-100 pos-relative o-x-hidden o-y-scroll gap-small shopcart-content\">\n <!-- Empty State -->\n <p v-if=\"!(shopcart.state.positions.length > 0)\" class=\"mn-t-medium\"><i>{{t('emptystate')}}</i></p>\n <!-- Shopcart positions -->\n <
|
|
1
|
+
{"version":3,"file":"ShopCart.vue.cjs","sources":["../../../../../../../src/modules/orders/components/partials/ShopCart.vue"],"sourcesContent":["<template>\n\t<section class=\"z-index-5 flex flex-column transition-ease-in-out bg-white shop-cart\" :class=\"{'shop-cart-active':shopcart.state.currentState === true}\">\n <!-- ---------------------------------------------------------------- -->\n <!-- 01. Popup Header -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big mobile:pd-medium pd-b-zero mobile:pd-b-zero flex-nowrap flex\">\n <div class=\"mn-b-medium w-100\">\n <h4 class=\"mn-b-thin p-semi\">{{t('title')}}</h4>\n <p class=\"t-transp p-small\">{{t('subtitle')}} {{ t('positions', { count: StoreCartAmount }) }}</p>\n </div>\n <IconCross @click=\"shopcart.actions.toggleShopcart\" class=\"cursor-pointer i-medium button-icon\"/>\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 02. Popup Content -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big pd-t-zero mobile:pd-t-zero mobile:pd-medium h-70 flex flex-column w-100 pos-relative o-x-hidden o-y-scroll gap-small shopcart-content\">\n <!-- Empty State -->\n <p v-if=\"!(shopcart.state.positions.length > 0)\" class=\"mn-t-medium\"><i>{{t('emptystate')}}</i></p>\n <!-- Shopcart positions -->\n <CardOrderItem \n v-for=\"(product, index) in shopcart.state.positions\" \n :key=\"`${product._id}_${product.variant || 'no-variant'}_${index}`\" \n :editable=\"true\" \n :productId=\"product._id\"\n :variantId=\"product.variant\"\n :images=\"product.images\"\n :name=\"product.name\"\n :quantity=\"product.quantity\"\n :unit=\"product.unit\"\n :dates=\"product.date\"\n :listing=\"product.listing\"\n :price=\"product.price\"\n :increase=\"() => shopcart.actions.incrementItemQuantity(product._id, product.variant)\"\n :decrease=\"() => shopcart.actions.decrementItemQuantity(product._id, product.variant)\"\n :remove=\"() => shopcart.actions.removeProduct(product._id, product.variant)\"\n @updateRentDates=\"(productId, variantId, dates) => shopcart.actions.updateRentDates({ productId, variantId, dates })\"\n />\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 03. Footer -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"h-30 transition-ease-in-out pd-b-medium pd-t-medium pd-big transition-cubic bg-light t-black\">\n <div v-if=\"shopcart.state.positions.length > 0\" class=\"mn-b-small total-price\">\n <PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate\"\n />\n </div>\n <button v-if=\"shopcart.state.positions.length > 0\" @click=\"openOrder()\" class=\"bg-main t-black w-100 button\">{{ t('fastorder') }}</button>\n </div> \n\n <!-- ---------------------------------------------------------------- -->\n <!-- 04. Color Overlay -->\n <!-- ---------------------------------------------------------------- -->\n <transition name=\"fade\">\n <teleport to=\"#app-wrapper\" v-if=\"shopcart.state.currentState\">\n\n <div \n v-if=\"shopcart.state.currentState\"\n @click=\"() => shopcart.state.currentState = false\"\n class=\"color-overlay z-index-3\"\n :class=\"{'active':shopcart.state.currentState === true}\"\n >\n </div>\n </teleport>\n </transition>\n </section>\n</template>\n\n\n<script setup>\n /////////////////////////////\n // COMPONENT DEPENDENCIES\n /////////////////////////////\n\timport { computed,onMounted } from 'vue'\n // Route\n import { useRouter,useRoute } from 'vue-router'\n // i18n\n import { useI18n } from 'vue-i18n'\n // Components\n import CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue';\n import PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\n import IconCross from '@martyrs/src/modules/icons/navigation/IconCross.vue';\n\n import * as globals from '@martyrs/src/modules/globals/views/store/globals.js';\n import * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n import * as shopcart from '@martyrs/src/modules/orders/store/shopcart.js';\n /////////////////////////////\n // CREATED\n /////////////////////////////\n const route = useRoute()\n const router = useRouter()\n // Accessing state\n const cartTotalPrice = shopcart.getters.cartTotalPrice\n const StoreCartAmount = shopcart.getters.cartTotalAmount\n // \n // router.beforeEach((to, from, next) => {\n // if (shopcart.state.currentState === true) {\n // shopcart.actions.toggleShopcart();\n // }\n // next(); // Убедитесь, что вызываете next() для продолжения перехода по роуту\n // });\n\n /////////////////////////////\n // LOCALIZATION\n /////////////////////////////\n const text = {\n messages: {\n en: {\n title: 'Your order',\n subtitle: 'You have',\n positions: 'no products in shop cart | 1 product in shop cart | {count} products in shop card',\n emptystate: \"You don't have any positions in your shop cart yet. Maybe something needs to be added?\",\n intotal: 'In total',\n fastorder: 'Checkout'\n },\n ru: {\n title: 'Ваш заказ',\n subtitle: 'У вас',\n positions: 'нет товаров в корзине | 1 товар в корзине | {count} товаров в корзине',\n emptystate: \"У вас еще нет товаров в корзине. Может стоит что-нибудь добавить?\",\n intotal: 'Итого',\n fastorder: 'Подтвердить заказ'\n }\n }\n }\n\n const { t } = useI18n(text)\n /////////////////////////////\n // MOUNTED\n /////////////////////////////\n function openOrder() {\n // store.dispatch(\"shopcart/toggleShopCart\");\n // store.dispatch(\"shopcart/setSearch\");\n !globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id ? router.push({name: 'Sign In', query: { returnUrl: '/orders/form'}}) : router.push({name: 'CreateOrder'}) \n shopcart.actions.toggleShopcart();\n }\n</script>\n\n<style lang=\"scss\">\n.shop-cart {\n display: block;\n position: fixed;\n\n right: -33%;\n top: 0;\n\n height: 100%;\n width: 33%;\n\n overflow-y: scroll; \n}\n\n.shop-cart-active {\n right: 0;\n\n}\n\n@media screen and (max-width: 1025px) {\n .shop-cart {\n width: 100%;\n right: -100%;\n\n .shopcart-footer {\n width: 100%;\n right: -100%;\n }\n\n &-active {\n right: 0;\n\n .shopcart-footer {\n right: 0;\n }\n }\n }\n}\n</style>\n\n\n"],"names":["useRoute","useRouter","shopcart.getters","useI18n","globals.state","auth.state","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FgBA,cAAQ,SAAA;AACtB,UAAM,SAASC,UAAS,UAAA;AAExB,UAAM,iBAAiBC,SAAAA,QAAiB;AACxC,UAAM,kBAAkBA,SAAAA,QAAiB;AAYzC,UAAM,OAAO;AAAA,MACX,UAAU;AAAA,QACR,IAAI;AAAA,UACF,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW;AAAA,UACX,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,WAAW;AAAA,QACZ;AAAA,QACD,IAAI;AAAA,UACF,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW;AAAA,UACX,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,WAAW;AAAA,QACnB;AAAA,MACA;AAAA,IACA;AAEE,UAAM,EAAE,MAAMC,QAAAA,QAAQ,IAAI;AAI1B,aAAS,YAAY;AAGnB,OAACC,cAAc,QAAQ,OAAO,8BAA8B,CAACC,WAAW,KAAK,MAAO,OAAO,KAAK,EAAC,MAAM,WAAW,OAAO,EAAE,WAAW,eAAc,EAAC,CAAC,IAAM,OAAO,KAAK,EAAC,MAAM,cAAa,CAAC;AAC7LC,eAAAA,QAAiB,eAAgB;AAAA,IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -73,7 +73,6 @@ const _sfc_main = {
|
|
|
73
73
|
!(state.positions.length > 0) ? (openBlock(), createElementBlock("p", _hoisted_6, [
|
|
74
74
|
createElementVNode("i", null, toDisplayString(unref(t)("emptystate")), 1)
|
|
75
75
|
])) : createCommentVNode("", true),
|
|
76
|
-
createElementVNode("pre", null, toDisplayString(state.positions), 1),
|
|
77
76
|
(openBlock(true), createElementBlock(Fragment, null, renderList(state.positions, (product, index) => {
|
|
78
77
|
return openBlock(), createBlock(_sfc_main$2, {
|
|
79
78
|
key: `${product._id}_${product.variant || "no-variant"}_${index}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopCart.vue.js","sources":["../../../../../../../src/modules/orders/components/partials/ShopCart.vue"],"sourcesContent":["<template>\n\t<section class=\"z-index-5 flex flex-column transition-ease-in-out bg-white shop-cart\" :class=\"{'shop-cart-active':shopcart.state.currentState === true}\">\n <!-- ---------------------------------------------------------------- -->\n <!-- 01. Popup Header -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big mobile:pd-medium pd-b-zero mobile:pd-b-zero flex-nowrap flex\">\n <div class=\"mn-b-medium w-100\">\n <h4 class=\"mn-b-thin p-semi\">{{t('title')}}</h4>\n <p class=\"t-transp p-small\">{{t('subtitle')}} {{ t('positions', { count: StoreCartAmount }) }}</p>\n </div>\n <IconCross @click=\"shopcart.actions.toggleShopcart\" class=\"cursor-pointer i-medium button-icon\"/>\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 02. Popup Content -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big pd-t-zero mobile:pd-t-zero mobile:pd-medium h-70 flex flex-column w-100 pos-relative o-x-hidden o-y-scroll gap-small shopcart-content\">\n <!-- Empty State -->\n <p v-if=\"!(shopcart.state.positions.length > 0)\" class=\"mn-t-medium\"><i>{{t('emptystate')}}</i></p>\n <!-- Shopcart positions -->\n <
|
|
1
|
+
{"version":3,"file":"ShopCart.vue.js","sources":["../../../../../../../src/modules/orders/components/partials/ShopCart.vue"],"sourcesContent":["<template>\n\t<section class=\"z-index-5 flex flex-column transition-ease-in-out bg-white shop-cart\" :class=\"{'shop-cart-active':shopcart.state.currentState === true}\">\n <!-- ---------------------------------------------------------------- -->\n <!-- 01. Popup Header -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big mobile:pd-medium pd-b-zero mobile:pd-b-zero flex-nowrap flex\">\n <div class=\"mn-b-medium w-100\">\n <h4 class=\"mn-b-thin p-semi\">{{t('title')}}</h4>\n <p class=\"t-transp p-small\">{{t('subtitle')}} {{ t('positions', { count: StoreCartAmount }) }}</p>\n </div>\n <IconCross @click=\"shopcart.actions.toggleShopcart\" class=\"cursor-pointer i-medium button-icon\"/>\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 02. Popup Content -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"pd-big pd-t-zero mobile:pd-t-zero mobile:pd-medium h-70 flex flex-column w-100 pos-relative o-x-hidden o-y-scroll gap-small shopcart-content\">\n <!-- Empty State -->\n <p v-if=\"!(shopcart.state.positions.length > 0)\" class=\"mn-t-medium\"><i>{{t('emptystate')}}</i></p>\n <!-- Shopcart positions -->\n <CardOrderItem \n v-for=\"(product, index) in shopcart.state.positions\" \n :key=\"`${product._id}_${product.variant || 'no-variant'}_${index}`\" \n :editable=\"true\" \n :productId=\"product._id\"\n :variantId=\"product.variant\"\n :images=\"product.images\"\n :name=\"product.name\"\n :quantity=\"product.quantity\"\n :unit=\"product.unit\"\n :dates=\"product.date\"\n :listing=\"product.listing\"\n :price=\"product.price\"\n :increase=\"() => shopcart.actions.incrementItemQuantity(product._id, product.variant)\"\n :decrease=\"() => shopcart.actions.decrementItemQuantity(product._id, product.variant)\"\n :remove=\"() => shopcart.actions.removeProduct(product._id, product.variant)\"\n @updateRentDates=\"(productId, variantId, dates) => shopcart.actions.updateRentDates({ productId, variantId, dates })\"\n />\n </div>\n <!-- ---------------------------------------------------------------- -->\n <!-- 03. Footer -->\n <!-- ---------------------------------------------------------------- -->\n <div class=\"h-30 transition-ease-in-out pd-b-medium pd-t-medium pd-big transition-cubic bg-light t-black\">\n <div v-if=\"shopcart.state.positions.length > 0\" class=\"mn-b-small total-price\">\n <PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate\"\n />\n </div>\n <button v-if=\"shopcart.state.positions.length > 0\" @click=\"openOrder()\" class=\"bg-main t-black w-100 button\">{{ t('fastorder') }}</button>\n </div> \n\n <!-- ---------------------------------------------------------------- -->\n <!-- 04. Color Overlay -->\n <!-- ---------------------------------------------------------------- -->\n <transition name=\"fade\">\n <teleport to=\"#app-wrapper\" v-if=\"shopcart.state.currentState\">\n\n <div \n v-if=\"shopcart.state.currentState\"\n @click=\"() => shopcart.state.currentState = false\"\n class=\"color-overlay z-index-3\"\n :class=\"{'active':shopcart.state.currentState === true}\"\n >\n </div>\n </teleport>\n </transition>\n </section>\n</template>\n\n\n<script setup>\n /////////////////////////////\n // COMPONENT DEPENDENCIES\n /////////////////////////////\n\timport { computed,onMounted } from 'vue'\n // Route\n import { useRouter,useRoute } from 'vue-router'\n // i18n\n import { useI18n } from 'vue-i18n'\n // Components\n import CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue';\n import PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\n import IconCross from '@martyrs/src/modules/icons/navigation/IconCross.vue';\n\n import * as globals from '@martyrs/src/modules/globals/views/store/globals.js';\n import * as auth from '@martyrs/src/modules/auth/views/store/auth.js';\n import * as shopcart from '@martyrs/src/modules/orders/store/shopcart.js';\n /////////////////////////////\n // CREATED\n /////////////////////////////\n const route = useRoute()\n const router = useRouter()\n // Accessing state\n const cartTotalPrice = shopcart.getters.cartTotalPrice\n const StoreCartAmount = shopcart.getters.cartTotalAmount\n // \n // router.beforeEach((to, from, next) => {\n // if (shopcart.state.currentState === true) {\n // shopcart.actions.toggleShopcart();\n // }\n // next(); // Убедитесь, что вызываете next() для продолжения перехода по роуту\n // });\n\n /////////////////////////////\n // LOCALIZATION\n /////////////////////////////\n const text = {\n messages: {\n en: {\n title: 'Your order',\n subtitle: 'You have',\n positions: 'no products in shop cart | 1 product in shop cart | {count} products in shop card',\n emptystate: \"You don't have any positions in your shop cart yet. Maybe something needs to be added?\",\n intotal: 'In total',\n fastorder: 'Checkout'\n },\n ru: {\n title: 'Ваш заказ',\n subtitle: 'У вас',\n positions: 'нет товаров в корзине | 1 товар в корзине | {count} товаров в корзине',\n emptystate: \"У вас еще нет товаров в корзине. Может стоит что-нибудь добавить?\",\n intotal: 'Итого',\n fastorder: 'Подтвердить заказ'\n }\n }\n }\n\n const { t } = useI18n(text)\n /////////////////////////////\n // MOUNTED\n /////////////////////////////\n function openOrder() {\n // store.dispatch(\"shopcart/toggleShopCart\");\n // store.dispatch(\"shopcart/setSearch\");\n !globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id ? router.push({name: 'Sign In', query: { returnUrl: '/orders/form'}}) : router.push({name: 'CreateOrder'}) \n shopcart.actions.toggleShopcart();\n }\n</script>\n\n<style lang=\"scss\">\n.shop-cart {\n display: block;\n position: fixed;\n\n right: -33%;\n top: 0;\n\n height: 100%;\n width: 33%;\n\n overflow-y: scroll; \n}\n\n.shop-cart-active {\n right: 0;\n\n}\n\n@media screen and (max-width: 1025px) {\n .shop-cart {\n width: 100%;\n right: -100%;\n\n .shopcart-footer {\n width: 100%;\n right: -100%;\n }\n\n &-active {\n right: 0;\n\n .shopcart-footer {\n right: 0;\n }\n }\n }\n}\n</style>\n\n\n"],"names":["shopcart.getters","globals.state","auth.state","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FgB,aAAQ;AACtB,UAAM,SAAS,UAAS;AAExB,UAAM,iBAAiBA,QAAiB;AACxC,UAAM,kBAAkBA,QAAiB;AAYzC,UAAM,OAAO;AAAA,MACX,UAAU;AAAA,QACR,IAAI;AAAA,UACF,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW;AAAA,UACX,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,WAAW;AAAA,QACZ;AAAA,QACD,IAAI;AAAA,UACF,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW;AAAA,UACX,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,WAAW;AAAA,QACnB;AAAA,MACA;AAAA,IACA;AAEE,UAAM,EAAE,MAAM,QAAQ,IAAI;AAI1B,aAAS,YAAY;AAGnB,OAACC,QAAc,QAAQ,OAAO,8BAA8B,CAACC,QAAW,KAAK,MAAO,OAAO,KAAK,EAAC,MAAM,WAAW,OAAO,EAAE,WAAW,eAAc,EAAC,CAAC,IAAM,OAAO,KAAK,EAAC,MAAM,cAAa,CAAC;AAC7LC,cAAiB,eAAgB;AAAA,IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
|
-
;/* empty css
|
|
6
|
-
;/* empty css
|
|
5
|
+
;/* empty css */
|
|
6
|
+
;/* empty css */
|
|
7
7
|
const Field = require("../../../../components/Field/Field.vue.cjs");
|
|
8
8
|
const Radio = require("../../../../components/Radio/Radio.vue.cjs");
|
|
9
9
|
;/* empty css */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { watch, onMounted, computed, createBlock, openBlock, withCtx, createElementVNode, createElementBlock, createCommentVNode, createVNode, Fragment, renderList } from "vue";
|
|
2
2
|
import { useRoute } from "vue-router";
|
|
3
|
-
/* empty css
|
|
4
|
-
/* empty css
|
|
3
|
+
/* empty css */
|
|
4
|
+
/* empty css */
|
|
5
5
|
import Field from "../../../../components/Field/Field.vue.js";
|
|
6
6
|
import _sfc_main$2 from "../../../../components/Radio/Radio.vue.js";
|
|
7
7
|
/* empty css */
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
5
|
const CardOrderItem = require("../../../orders/components/blocks/CardOrderItem.vue.cjs");
|
|
6
|
-
const Chips = require("../../../../components/Chips/Chips.
|
|
6
|
+
const Chips = require("../../../../components/Chips/Chips.vue.cjs");
|
|
7
7
|
const PlaceholderOrganizationPic = require("../../../icons/placeholders/PlaceholderOrganizationPic.vue.cjs");
|
|
8
8
|
const IconShopcart = require("../../../icons/entities/IconShopcart.vue.cjs");
|
|
9
9
|
const IconTime = require("../../../icons/entities/IconTime.vue.cjs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElementBlock, openBlock, createElementVNode, createCommentVNode, createBlock, toDisplayString, withCtx, createVNode, Fragment, renderList, withModifiers } from "vue";
|
|
2
2
|
import { useRouter } from "vue-router";
|
|
3
3
|
import _sfc_main$4 from "../../../orders/components/blocks/CardOrderItem.vue.js";
|
|
4
|
-
import _sfc_main$1 from "../../../../components/Chips/Chips.
|
|
4
|
+
import _sfc_main$1 from "../../../../components/Chips/Chips.vue.js";
|
|
5
5
|
import PlaceholderOrganizationPic from "../../../icons/placeholders/PlaceholderOrganizationPic.vue.js";
|
|
6
6
|
import _sfc_main$3 from "../../../icons/entities/IconShopcart.vue.js";
|
|
7
7
|
import IconTime from "../../../icons/entities/IconTime.vue.js";
|
|
@@ -11,7 +11,7 @@ const Field = require("../../../../components/Field/Field.vue.cjs");
|
|
|
11
11
|
const Checkbox = require("../../../../components/Checkbox/Checkbox.vue.cjs");
|
|
12
12
|
require("../../../../../../node_modules/.pnpm/@googlemaps_js-api-loader@1.16.8/node_modules/@googlemaps/js-api-loader/dist/index.cjs");
|
|
13
13
|
;/* empty css */
|
|
14
|
-
;/* empty css
|
|
14
|
+
;/* empty css */
|
|
15
15
|
;/* empty css */
|
|
16
16
|
const Button = require("../../../../components/Button/Button.vue2.cjs");
|
|
17
17
|
const Popup = require("../../../../components/Popup/Popup.vue.cjs");
|
|
@@ -9,7 +9,7 @@ import Field from "../../../../components/Field/Field.vue.js";
|
|
|
9
9
|
import _sfc_main$8 from "../../../../components/Checkbox/Checkbox.vue.js";
|
|
10
10
|
import "../../../../../../node_modules/.pnpm/@googlemaps_js-api-loader@1.16.8/node_modules/@googlemaps/js-api-loader/dist/index.js";
|
|
11
11
|
/* empty css */
|
|
12
|
-
/* empty css
|
|
12
|
+
/* empty css */
|
|
13
13
|
/* empty css */
|
|
14
14
|
import _sfc_main$1 from "../../../../components/Button/Button.vue2.js";
|
|
15
15
|
import _sfc_main$6 from "../../../../components/Popup/Popup.vue.js";
|
|
@@ -4,7 +4,7 @@ const vue = require("vue");
|
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
5
|
const Feed = require("../../../../components/Feed/Feed.vue.cjs");
|
|
6
6
|
;/* empty css */
|
|
7
|
-
;/* empty css
|
|
7
|
+
;/* empty css */
|
|
8
8
|
const Popup = require("../../../../components/Popup/Popup.vue.cjs");
|
|
9
9
|
const SectionPageTitle = require("../../../globals/views/components/sections/SectionPageTitle.vue.cjs");
|
|
10
10
|
const MembersAdd = require("../sections/MembersAdd.vue.cjs");
|