@ozdao/martyrs 0.2.463 → 0.2.464

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.
Files changed (33) hide show
  1. package/dist/martyrs/src/components/Block/Block.vue.cjs +1 -1
  2. package/dist/martyrs/src/components/Block/Block.vue.js +1 -1
  3. package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.cjs → Tooltip.vue.cjs} +2 -2
  4. package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js.map → Tooltip.vue.cjs.map} +1 -1
  5. package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js → Tooltip.vue.js} +2 -2
  6. package/dist/martyrs/src/components/Tooltip/Tooltip.vue.js.map +1 -0
  7. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +1 -1
  8. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +1 -1
  9. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs +1 -1
  10. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js +1 -1
  11. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  12. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  13. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +0 -1
  14. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
  15. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +1 -2
  16. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
  17. package/dist/martyrs/src/modules/orders/store/shopcart.cjs +1 -0
  18. package/dist/martyrs/src/modules/orders/store/shopcart.cjs.map +1 -1
  19. package/dist/martyrs/src/modules/orders/store/shopcart.js +1 -0
  20. package/dist/martyrs/src/modules/orders/store/shopcart.js.map +1 -1
  21. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  22. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
  23. package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
  24. package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
  25. package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +5 -4
  26. package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs.map +1 -1
  27. package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +5 -4
  28. package/dist/martyrs/src/modules/products/components/pages/Product.vue.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/modules/orders/components/pages/OrderCreate.vue +0 -1
  31. package/src/modules/orders/store/shopcart.js +1 -0
  32. package/src/modules/products/components/pages/Product.vue +6 -5
  33. package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.cjs.map +0 -1
@@ -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("../Tooltip/Tooltip.vue2.cjs");
4
+ const Tooltip = require("../Tooltip/Tooltip.vue.cjs");
5
5
  const _hoisted_1 = { class: "bg-light pd-medium radius-medium" };
6
6
  const _hoisted_2 = {
7
7
  key: 0,
@@ -1,5 +1,5 @@
1
1
  import { useSlots, createElementBlock, openBlock, createCommentVNode, renderSlot, createBlock, toDisplayString, Fragment, renderList, normalizeClass, withCtx, createElementVNode, Comment } from "vue";
2
- import _sfc_main$1 from "../Tooltip/Tooltip.vue2.js";
2
+ import _sfc_main$1 from "../Tooltip/Tooltip.vue.js";
3
3
  const _hoisted_1 = { class: "bg-light pd-medium radius-medium" };
4
4
  const _hoisted_2 = {
5
5
  key: 0,
@@ -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
- ;/* empty css */
4
+ ;/* empty css */
5
5
  const _sfc_main = {
6
6
  __name: "Tooltip",
7
7
  props: {
@@ -49,4 +49,4 @@ const _sfc_main = {
49
49
  }
50
50
  };
51
51
  exports.default = _sfc_main;
52
- //# sourceMappingURL=Tooltip.vue2.cjs.map
52
+ //# sourceMappingURL=Tooltip.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.vue2.js","sources":["../../../../../src/components/Tooltip/Tooltip.vue"],"sourcesContent":["<template>\n <div class=\"cursor-pointer tooltip-container\" @mouseover=\"showTooltip\" @mouseleave=\"hideTooltip\">\n <slot></slot>\n <div class=\"tooltip-content\" :style=\"tooltipStyle\">\n {{ text }}\n </div>\n </div>\n</template>\n\n<script setup>\nimport { ref, reactive } from 'vue';\n\nconst props = defineProps({\n text: {\n type: String,\n required: true\n }\n});\n\nconst visible = ref(false);\n\nconst tooltipStyle = reactive({\n position: 'absolute',\n width: 'max-content',\n zIndex: 1000,\n background: '#333',\n color: '#fff',\n padding: '5px 10px',\n borderRadius: '3px',\n fontSize: '14px',\n display: 'none',\n});\n\nfunction showTooltip(event) {\n visible.value = true;\n tooltipStyle.left = `${(event.clientX / 100) + 10 }px`;\n tooltipStyle.top = `${(event.clientY / 100) + 10 }px`;\n tooltipStyle.display = 'block';\n}\n\nfunction hideTooltip() {\n visible.value = false;\n tooltipStyle.display = 'none';\n}\n</script>\n\n<style >\n.tooltip-container {\n position: relative;\n display: inline-block;\n}\n\n.tooltip-content {\n pointer-events: none;\n}\n</style>"],"names":[],"mappings":";;;;;;;;;;;AAmBA,UAAM,UAAU,IAAI,KAAK;AAEzB,UAAM,eAAe,SAAS;AAAA,MAC5B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,cAAc;AAAA,MACd,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAED,aAAS,YAAY,OAAO;AAC1B,cAAQ,QAAQ;AAChB,mBAAa,OAAO,GAAI,MAAM,UAAU,MAAO,EAAE;AACjD,mBAAa,MAAM,GAAI,MAAM,UAAU,MAAO,EAAE;AAChD,mBAAa,UAAU;AAAA,IACzB;AAEA,aAAS,cAAc;AACrB,cAAQ,QAAQ;AAChB,mBAAa,UAAU;AAAA,IACzB;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Tooltip.vue.cjs","sources":["../../../../../src/components/Tooltip/Tooltip.vue"],"sourcesContent":["<template>\n <div class=\"cursor-pointer tooltip-container\" @mouseover=\"showTooltip\" @mouseleave=\"hideTooltip\">\n <slot></slot>\n <div class=\"tooltip-content\" :style=\"tooltipStyle\">\n {{ text }}\n </div>\n </div>\n</template>\n\n<script setup>\nimport { ref, reactive } from 'vue';\n\nconst props = defineProps({\n text: {\n type: String,\n required: true\n }\n});\n\nconst visible = ref(false);\n\nconst tooltipStyle = reactive({\n position: 'absolute',\n width: 'max-content',\n zIndex: 1000,\n background: '#333',\n color: '#fff',\n padding: '5px 10px',\n borderRadius: '3px',\n fontSize: '14px',\n display: 'none',\n});\n\nfunction showTooltip(event) {\n visible.value = true;\n tooltipStyle.left = `${(event.clientX / 100) + 10 }px`;\n tooltipStyle.top = `${(event.clientY / 100) + 10 }px`;\n tooltipStyle.display = 'block';\n}\n\nfunction hideTooltip() {\n visible.value = false;\n tooltipStyle.display = 'none';\n}\n</script>\n\n<style >\n.tooltip-container {\n position: relative;\n display: inline-block;\n}\n\n.tooltip-content {\n pointer-events: none;\n}\n</style>"],"names":["ref","reactive"],"mappings":";;;;;;;;;;;;;AAmBA,UAAM,UAAUA,IAAG,IAAC,KAAK;AAEzB,UAAM,eAAeC,IAAAA,SAAS;AAAA,MAC5B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,cAAc;AAAA,MACd,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAED,aAAS,YAAY,OAAO;AAC1B,cAAQ,QAAQ;AAChB,mBAAa,OAAO,GAAI,MAAM,UAAU,MAAO,EAAE;AACjD,mBAAa,MAAM,GAAI,MAAM,UAAU,MAAO,EAAE;AAChD,mBAAa,UAAU;AAAA,IACzB;AAEA,aAAS,cAAc;AACrB,cAAQ,QAAQ;AAChB,mBAAa,UAAU;AAAA,IACzB;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { ref, reactive, createElementBlock, openBlock, renderSlot, createElementVNode, normalizeStyle, toDisplayString } from "vue";
2
- /* empty css */
2
+ /* empty css */
3
3
  const _sfc_main = {
4
4
  __name: "Tooltip",
5
5
  props: {
@@ -49,4 +49,4 @@ const _sfc_main = {
49
49
  export {
50
50
  _sfc_main as default
51
51
  };
52
- //# sourceMappingURL=Tooltip.vue2.js.map
52
+ //# sourceMappingURL=Tooltip.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.vue.js","sources":["../../../../../src/components/Tooltip/Tooltip.vue"],"sourcesContent":["<template>\n <div class=\"cursor-pointer tooltip-container\" @mouseover=\"showTooltip\" @mouseleave=\"hideTooltip\">\n <slot></slot>\n <div class=\"tooltip-content\" :style=\"tooltipStyle\">\n {{ text }}\n </div>\n </div>\n</template>\n\n<script setup>\nimport { ref, reactive } from 'vue';\n\nconst props = defineProps({\n text: {\n type: String,\n required: true\n }\n});\n\nconst visible = ref(false);\n\nconst tooltipStyle = reactive({\n position: 'absolute',\n width: 'max-content',\n zIndex: 1000,\n background: '#333',\n color: '#fff',\n padding: '5px 10px',\n borderRadius: '3px',\n fontSize: '14px',\n display: 'none',\n});\n\nfunction showTooltip(event) {\n visible.value = true;\n tooltipStyle.left = `${(event.clientX / 100) + 10 }px`;\n tooltipStyle.top = `${(event.clientY / 100) + 10 }px`;\n tooltipStyle.display = 'block';\n}\n\nfunction hideTooltip() {\n visible.value = false;\n tooltipStyle.display = 'none';\n}\n</script>\n\n<style >\n.tooltip-container {\n position: relative;\n display: inline-block;\n}\n\n.tooltip-content {\n pointer-events: none;\n}\n</style>"],"names":[],"mappings":";;;;;;;;;;;AAmBA,UAAM,UAAU,IAAI,KAAK;AAEzB,UAAM,eAAe,SAAS;AAAA,MAC5B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,cAAc;AAAA,MACd,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAED,aAAS,YAAY,OAAO;AAC1B,cAAQ,QAAQ;AAChB,mBAAa,OAAO,GAAI,MAAM,UAAU,MAAO,EAAE;AACjD,mBAAa,MAAM,GAAI,MAAM,UAAU,MAAO,EAAE;AAChD,mBAAa,UAAU;AAAA,IACzB;AAEA,aAAS,cAAc;AACrB,cAAQ,QAAQ;AAChB,mBAAa,UAAU;AAAA,IACzB;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@
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
- const Tooltip = require("../../../../../components/Tooltip/Tooltip.vue2.cjs");
5
+ const Tooltip = require("../../../../../components/Tooltip/Tooltip.vue.cjs");
6
6
  const Dropdown = require("../../../../../components/Dropdown/Dropdown.vue2.cjs");
7
7
  const PlaceholderUserpic = require("../../../../icons/placeholders/PlaceholderUserpic.vue.cjs");
8
8
  const PlaceholderOrganizationPic = require("../../../../icons/placeholders/PlaceholderOrganizationPic.vue.cjs");
@@ -1,6 +1,6 @@
1
1
  import { resolveComponent, createElementBlock, createCommentVNode, openBlock, createElementVNode, createBlock, withModifiers, resolveDynamicComponent, toDisplayString, withCtx, createTextVNode, Fragment, renderList, normalizeClass } from "vue";
2
2
  import { useRouter } from "vue-router";
3
- import _sfc_main$1 from "../../../../../components/Tooltip/Tooltip.vue2.js";
3
+ import _sfc_main$1 from "../../../../../components/Tooltip/Tooltip.vue.js";
4
4
  import _sfc_main$3 from "../../../../../components/Dropdown/Dropdown.vue2.js";
5
5
  import PlaceholderUserpic from "../../../../icons/placeholders/PlaceholderUserpic.vue.js";
6
6
  import PlaceholderOrganizationPic from "../../../../icons/placeholders/PlaceholderOrganizationPic.vue.js";
@@ -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.vue2.cjs");
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.vue2.js";
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";
@@ -171,7 +171,6 @@ const _sfc_main = {
171
171
  key: 1,
172
172
  order: order.value
173
173
  }, null, 8, ["order"])) : vue.createCommentVNode("", true),
174
- vue.createTextVNode(" " + vue.toDisplayString(shopcart.state.organization) + " ", 1),
175
174
  orders.state.current.status !== true && shopcart.state.positions.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
176
175
  vue.createVNode(FormCustomerDetails.default, {
177
176
  customer: orders.state.current.customer
@@ -1 +1 @@
1
- {"version":3,"file":"OrderCreate.vue.cjs","sources":["../../../../../../../src/modules/orders/components/pages/OrderCreate.vue"],"sourcesContent":["<template>\n\n<section class=\"bg-white pd-thin\">\n\n\t<!-- Ask to login -->\n\t<AskToLogin class=\"mn-b-thin\" v-if=\"auth.state.access.status === false\" /> \n\n\t<!-- Order form -->\n\t<div class=\"gap-small mn-b-thin cols-2\">\n\t\t<!-- Empty State -->\n\t\t<EmptyState \n\t\t\tv-if=\"shopcart.state.positions < 1\" \n\t\t/>\t\n\n\t\t<Succes \n\t\t\tv-if=\"order.status === true && shopcart.state.positions.length > 0\" \n\t\t\t:order=\"order\" \n\t\t/>\n\t\t{{shopcart.state.organization}}\n\t\t<!-- Order Form -->\n\t\t<div\n\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\" \n\t\t\tclass=\"rows-1 gap-thin\"\n\t\t>\n\t\t\t<FormCustomerDetails\n\t\t\t\t:customer=\"orders.state.current.customer\"\n\t\t\t/>\n\t\t\t<FormPayment \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t<FormDelivery \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t\n\t\t</div>\n\n\t\t<!-- Order positions -->\n\t\t<div \n\t\t\tv-if=\"shopcart.state.positions.length > 0\" \n\t\t\tclass=\"bg-white br-solid br-light br-1px pd-medium radius-medium\"\n\t\t>\n\t\t\t<h4 class=\"font-second mn-b-thin\">Your Order</h4>\n\n\t\t\t<ul class=\"flex gap-thin flex-wrap mn-b-thin\">\n\t\t\t\t<CardOrderItem \n\t\t\t\t\tv-for=\"product in shopcart.state.positions\" \n\t\t\t\t\t:key=\"product._id\" \n\t\t\t\t\t:editable=\"true\" \n\t\t\t\t\t:product=\"product\" \n\t :increase=\"product => shopcart.actions.incrementItemQuantity(product._id)\"\n\t :decrease=\"product => shopcart.actions.decrementItemQuantity(product._id)\"\n\t :remove=\"product => shopcart.actions.removeProduct(product._id)\"\n\t\t\t\t\t@updateRentDates=\"(product, dates) => shopcart.actions.updateRentDates({ productId: product._id, dates })\"\n\t class=\"w-100 bg-white \"\n\t />\n\t\t\t</ul>\n\n\t\t\t\t<div \n\t\t\t\tclass=\"mn-b-thin\"\n\t\t\t>\t\n\t\t\t\t<PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :deliveryRate=\"deliveryCost\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n :showDeliveryFee=\"globals.state.options?.orders.showDeliveryFee\"\n />\n\t\t\t</div>\n\t\t\t<!-- Send order -->\n\t\t <button \n\t\t \tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t \t:disabled=\"\n\t\t errorName \n\t\t || errorPhoneOrMessenger \n\t\t || errorCity \n\t\t || errorAddress \n\t\t || errorDelivery \n\t\t || errorPayment\n\t\t || isLocationLoading\n\t\t \"\n\t\t @click=\"handleCreate()\" \n\t\t class=\"bg-main mn-b-small pd-small radius-big w-100 button\"\n\t\t >\n\t\t Place an Order\n\t\t </button>\n\n\t\t <p class='mn-b-thin'>\n\t\t\t\tI agree that placing the order places me under an obligation to make a payment in accordance with <a class=\"t-semi font-second t-second\" href=\"/legal/terms-of-use\" target=\"_blank\">Terms of Use.</a>\n\t\t\t</p>\n\t\t\t<p >\n\t\t\t\t\n\t\t\t</p>\n\t\t</div>\n\n\t</div>\n\n\t\n\t\n</section>\n\n</template>\n\n\n<script setup>\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import components\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Block\nimport CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue'\n// Sections\nimport AskToLogin from '@martyrs/src/modules/orders/components/sections/AskToLogin.vue'\nimport Succes from '@martyrs/src/modules/orders/components/sections/Succes.vue'\nimport EmptyState from '@martyrs/src/modules/orders/components/sections/EmptyState.vue'\n\nimport PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\nimport FormCustomerDetails from '@martyrs/src/modules/orders/components/sections/FormCustomerDetails.vue'\nimport FormDelivery from '@martyrs/src/modules/orders/components/sections/FormDelivery.vue'\nimport FormPayment from '@martyrs/src/modules/orders/components/sections/FormPayment.vue'\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import libs\n///////////////////////////////////////////////////////////////////////////////////////////////////\nimport { ref, computed, onMounted, watch } from 'vue'\nimport { useRoute,useRouter } from 'vue-router'\n// Store\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart';\nimport * as organizations from '@martyrs/src/modules/organizations/store/organizations';\nimport * as orders from '@martyrs/src/modules/orders/store/orders';\nimport * as users from '@martyrs/src/modules/auth/views/store/users';\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Variables and computed\n//////////////////////////////////////////////////////////////////////////////////////////////////\nconst isLocationLoading = ref(false)\n// Accessing router and store\nconst route = useRoute()\nconst router = useRouter()\n// COMPUTED\nconst order = computed(() => orders.state.current)\nconst user = computed(() => users.state.current)\n\nconst cartTotalPrice = shopcart.getters.cartTotalPrice\n\nconst deliveryCost = computed(() => {\n const type = orders.state.current.delivery.type\n const distance = orderOrganization.value[0]?.distance || 0\n const config = globals.state.options?.orders?.delivery_formula || {}\n\n return orders.getters.getDeliveryPrice(type, distance, config)\n})\n\n// Organization\nconst orderOrganization = ref({})\n\n\nif (!globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id) { \n\trouter.push({name: 'Sign In'})\t\n}\n\n\norders.mutations.resetOrder()\n\nonMounted(async()=> {\n\tisLocationLoading.value = true\n\n\n\tif (auth.state.user._id) {\n\t\tlet data = await users.actions.read({ _id:auth.state.user._id, user: auth.state.user._id });\n\t\torders.state.current.customer.profile.name = users.state.current.profile.name\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t}\n\n\torders.state.current.organization = shopcart.state.organization\n\n\torderOrganization.value = await organizations.actions.read({\n\t _id: shopcart.state.organization,\n\t location: globals.state.position?.location,\n\t lookup: ['spots']\n\t})\n\t\n isLocationLoading.value = false\n})\n\n\nwatch(\n () => orders.state.current.delivery,\n async (newVal) => {\n if (newVal?.location) {\n \tisLocationLoading.value = true\n\n orderOrganization.value = await organizations.actions.read({\n _id: shopcart.state.organization,\n location: newVal.location,\n lookup: ['spots']\n })\n\n isLocationLoading.value = false\n }\n },\n { deep: true }\n)\n\n\n/////////////////////////////\n// Store Verification\n/////////////////////////////\nconst errorName = computed(() => {\n if (orders.state.current.customer.name?.length < 2) { return true } else { return false }\n});\n\nconst errorPhoneOrMessenger = computed(() => {\n const hasMessengerType = orders.state.current.customer.messenger?.type;\n const hasMessengerValue = orders.state.current.customer.messenger?.value?.length >\t 2;\n const hasPhone = orders.state.current.customer.number?.length > 0;\n // Ошибка, если нет ни номера телефона, ни корректного типа и значения мессенджера\n return !hasPhone && !(hasMessengerType && hasMessengerValue);\n});\n\nconst errorAddress = computed(() => {\n const type = orders.state.current.delivery.type;\n if (type === \"pickup\") {\n return !orders.state.current.delivery.spot;\n } else if (type === \"courier\" || type === \"mail\") {\n const address = orders.state.current.delivery.address;\n return !address || typeof address !== 'string' || address.length < 2;\n }\n return false;\n});\n\nconst errorDelivery = computed(() => {\n if (orders.state.current.delivery.type) {return false } else {return true } \n})\n\nconst errorPayment = computed(() => {\n if (orders.state.current.payment.type) { return false } else {return true } \n})\n/////////////////////////////\n// Methods\n/////////////////////////////\nasync function handleCreate() {\n\n\torders.state.current.status = 'created';\n\n\torders.state.current.owner = {\n\t\ttarget: orderOrganization.value[0]._id,\n\t\ttype: 'organization'\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.creator = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.customer = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\torders.state.current.positions = shopcart.state.positions\n\n \tconst referralCode = localStorage.getItem('referalCode');\n \n if (referralCode) {\n orders.state.current.referralCode = referralCode;\n }\n\n let order = await orders.actions.create(orders.state.current);\n\n if (order) {\n \tawait router.push({\n \t\tname: 'Order',\n \t\tparams: {\n \t\t\torder: order._id\n \t\t}\n \t})\n \t\t\n \tshopcart.actions.resetShopcart()\n\n } else {\n \talert('something wrong')\n }\n}\n</script>\n\n<style lang=\"scss\">\n\n.round-wrapper {\n\tposition: relative;\n\n\t.round {\n\t\tmargin: 0;\n\t\tmargin-right: 1rem;\n\t}\n\n\tinput:checked {\n\t\tbackground: #00ff88;\n\t}\n\n\t.round-checkmark {\n\t\tposition: absolute;\n\t\twidth: 0.5rem;\n\t\theight: 0.5rem;\n\t\tbackground: white;\n\n\t\tleft: 0.5rem;\n\t\ttop: 0.5rem;\n\n\t\topacity: 1;\n\t}\n}\n</style>"],"names":["ref","useRoute","useRouter","computed","orders.state","users.state","shopcart.getters","globals.state","orders.getters","auth.state","orders.mutations","onMounted","users.actions","shopcart.state","organizations.actions","watch","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,UAAM,oBAAoBA,IAAG,IAAC,KAAK;AAErBC,cAAQ,SAAA;AACtB,UAAM,SAASC,UAAS,UAAA;AAExB,UAAM,QAAQC,IAAAA,SAAS,MAAMC,OAAAA,MAAa,OAAO;AACpCD,QAAAA,SAAS,MAAME,MAAW,MAAC,OAAO;AAE/C,UAAM,iBAAiBC,SAAAA,QAAiB;AAExC,UAAM,eAAeH,IAAQ,SAAC,MAAM;;AAClC,YAAM,OAAOC,OAAAA,MAAa,QAAQ,SAAS;AAC3C,YAAM,aAAW,uBAAkB,MAAM,CAAC,MAAzB,mBAA4B,aAAY;AACzD,YAAM,WAASG,mBAAa,MAAC,YAAdA,mBAAuB,WAAvBA,mBAA+B,qBAAoB,CAAA;AAElE,aAAOC,eAAe,iBAAiB,MAAM,UAAU,MAAM;AAAA,IAC/D,CAAC;AAGD,UAAM,oBAAoBR,IAAG,IAAC,CAAE,CAAA;AAGhC,QAAI,CAACO,QAAAA,MAAc,QAAQ,OAAO,8BAA8B,CAACE,KAAU,MAAC,KAAK,KAAK;AACrF,aAAO,KAAK,EAAC,MAAM,UAAS,CAAC;AAAA,IAC9B;AAGAC,WAAAA,UAAiB,WAAU;AAE3BC,QAAAA,UAAU,YAAU;;AACnB,wBAAkB,QAAQ;AAG1B,UAAIF,KAAU,MA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C/B,QAAQK,KAAAA,MAAW,KAAK;AAAA,UACxB,MAAM;AAAA,QACT;AAAA,MACA;AAECL,mBAAa,QAAQ,YAAYS,eAAe;AAE/C,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBT,qBAAa,QAAQ,eAAe;AAAA,MACxC;AAEE,UAAIY,SAAQ,MAAMC,OAAAA,QAAe,OAAOb,OAAAA,MAAa,OAAO;AAE5D,UAAIY,QAAO;AACV,cAAM,OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,iBAAAA,QAAiB,cAAa;AAAA,MAEjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"OrderCreate.vue.cjs","sources":["../../../../../../../src/modules/orders/components/pages/OrderCreate.vue"],"sourcesContent":["<template>\n\n<section class=\"bg-white pd-thin\">\n\n\t<!-- Ask to login -->\n\t<AskToLogin class=\"mn-b-thin\" v-if=\"auth.state.access.status === false\" /> \n\n\t<!-- Order form -->\n\t<div class=\"gap-small mn-b-thin cols-2\">\n\t\t<!-- Empty State -->\n\t\t<EmptyState \n\t\t\tv-if=\"shopcart.state.positions < 1\" \n\t\t/>\t\n\n\t\t<Succes \n\t\t\tv-if=\"order.status === true && shopcart.state.positions.length > 0\" \n\t\t\t:order=\"order\" \n\t\t/>\n\t\t<!-- Order Form -->\n\t\t<div\n\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\" \n\t\t\tclass=\"rows-1 gap-thin\"\n\t\t>\n\t\t\t<FormCustomerDetails\n\t\t\t\t:customer=\"orders.state.current.customer\"\n\t\t\t/>\n\t\t\t<FormPayment \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t<FormDelivery \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t\n\t\t</div>\n\n\t\t<!-- Order positions -->\n\t\t<div \n\t\t\tv-if=\"shopcart.state.positions.length > 0\" \n\t\t\tclass=\"bg-white br-solid br-light br-1px pd-medium radius-medium\"\n\t\t>\n\t\t\t<h4 class=\"font-second mn-b-thin\">Your Order</h4>\n\n\t\t\t<ul class=\"flex gap-thin flex-wrap mn-b-thin\">\n\t\t\t\t<CardOrderItem \n\t\t\t\t\tv-for=\"product in shopcart.state.positions\" \n\t\t\t\t\t:key=\"product._id\" \n\t\t\t\t\t:editable=\"true\" \n\t\t\t\t\t:product=\"product\" \n\t :increase=\"product => shopcart.actions.incrementItemQuantity(product._id)\"\n\t :decrease=\"product => shopcart.actions.decrementItemQuantity(product._id)\"\n\t :remove=\"product => shopcart.actions.removeProduct(product._id)\"\n\t\t\t\t\t@updateRentDates=\"(product, dates) => shopcart.actions.updateRentDates({ productId: product._id, dates })\"\n\t class=\"w-100 bg-white \"\n\t />\n\t\t\t</ul>\n\n\t\t\t\t<div \n\t\t\t\tclass=\"mn-b-thin\"\n\t\t\t>\t\n\t\t\t\t<PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :deliveryRate=\"deliveryCost\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n :showDeliveryFee=\"globals.state.options?.orders.showDeliveryFee\"\n />\n\t\t\t</div>\n\t\t\t<!-- Send order -->\n\t\t <button \n\t\t \tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t \t:disabled=\"\n\t\t errorName \n\t\t || errorPhoneOrMessenger \n\t\t || errorCity \n\t\t || errorAddress \n\t\t || errorDelivery \n\t\t || errorPayment\n\t\t || isLocationLoading\n\t\t \"\n\t\t @click=\"handleCreate()\" \n\t\t class=\"bg-main mn-b-small pd-small radius-big w-100 button\"\n\t\t >\n\t\t Place an Order\n\t\t </button>\n\n\t\t <p class='mn-b-thin'>\n\t\t\t\tI agree that placing the order places me under an obligation to make a payment in accordance with <a class=\"t-semi font-second t-second\" href=\"/legal/terms-of-use\" target=\"_blank\">Terms of Use.</a>\n\t\t\t</p>\n\t\t\t<p >\n\t\t\t\t\n\t\t\t</p>\n\t\t</div>\n\n\t</div>\n\n\t\n\t\n</section>\n\n</template>\n\n\n<script setup>\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import components\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Block\nimport CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue'\n// Sections\nimport AskToLogin from '@martyrs/src/modules/orders/components/sections/AskToLogin.vue'\nimport Succes from '@martyrs/src/modules/orders/components/sections/Succes.vue'\nimport EmptyState from '@martyrs/src/modules/orders/components/sections/EmptyState.vue'\n\nimport PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\nimport FormCustomerDetails from '@martyrs/src/modules/orders/components/sections/FormCustomerDetails.vue'\nimport FormDelivery from '@martyrs/src/modules/orders/components/sections/FormDelivery.vue'\nimport FormPayment from '@martyrs/src/modules/orders/components/sections/FormPayment.vue'\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import libs\n///////////////////////////////////////////////////////////////////////////////////////////////////\nimport { ref, computed, onMounted, watch } from 'vue'\nimport { useRoute,useRouter } from 'vue-router'\n// Store\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart';\nimport * as organizations from '@martyrs/src/modules/organizations/store/organizations';\nimport * as orders from '@martyrs/src/modules/orders/store/orders';\nimport * as users from '@martyrs/src/modules/auth/views/store/users';\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Variables and computed\n//////////////////////////////////////////////////////////////////////////////////////////////////\nconst isLocationLoading = ref(false)\n// Accessing router and store\nconst route = useRoute()\nconst router = useRouter()\n// COMPUTED\nconst order = computed(() => orders.state.current)\nconst user = computed(() => users.state.current)\n\nconst cartTotalPrice = shopcart.getters.cartTotalPrice\n\nconst deliveryCost = computed(() => {\n const type = orders.state.current.delivery.type\n const distance = orderOrganization.value[0]?.distance || 0\n const config = globals.state.options?.orders?.delivery_formula || {}\n\n return orders.getters.getDeliveryPrice(type, distance, config)\n})\n\n// Organization\nconst orderOrganization = ref({})\n\n\nif (!globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id) { \n\trouter.push({name: 'Sign In'})\t\n}\n\n\norders.mutations.resetOrder()\n\nonMounted(async()=> {\n\tisLocationLoading.value = true\n\n\n\tif (auth.state.user._id) {\n\t\tlet data = await users.actions.read({ _id:auth.state.user._id, user: auth.state.user._id });\n\t\torders.state.current.customer.profile.name = users.state.current.profile.name\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t}\n\n\torders.state.current.organization = shopcart.state.organization\n\n\torderOrganization.value = await organizations.actions.read({\n\t _id: shopcart.state.organization,\n\t location: globals.state.position?.location,\n\t lookup: ['spots']\n\t})\n\t\n isLocationLoading.value = false\n})\n\n\nwatch(\n () => orders.state.current.delivery,\n async (newVal) => {\n if (newVal?.location) {\n \tisLocationLoading.value = true\n\n orderOrganization.value = await organizations.actions.read({\n _id: shopcart.state.organization,\n location: newVal.location,\n lookup: ['spots']\n })\n\n isLocationLoading.value = false\n }\n },\n { deep: true }\n)\n\n\n/////////////////////////////\n// Store Verification\n/////////////////////////////\nconst errorName = computed(() => {\n if (orders.state.current.customer.name?.length < 2) { return true } else { return false }\n});\n\nconst errorPhoneOrMessenger = computed(() => {\n const hasMessengerType = orders.state.current.customer.messenger?.type;\n const hasMessengerValue = orders.state.current.customer.messenger?.value?.length >\t 2;\n const hasPhone = orders.state.current.customer.number?.length > 0;\n // Ошибка, если нет ни номера телефона, ни корректного типа и значения мессенджера\n return !hasPhone && !(hasMessengerType && hasMessengerValue);\n});\n\nconst errorAddress = computed(() => {\n const type = orders.state.current.delivery.type;\n if (type === \"pickup\") {\n return !orders.state.current.delivery.spot;\n } else if (type === \"courier\" || type === \"mail\") {\n const address = orders.state.current.delivery.address;\n return !address || typeof address !== 'string' || address.length < 2;\n }\n return false;\n});\n\nconst errorDelivery = computed(() => {\n if (orders.state.current.delivery.type) {return false } else {return true } \n})\n\nconst errorPayment = computed(() => {\n if (orders.state.current.payment.type) { return false } else {return true } \n})\n/////////////////////////////\n// Methods\n/////////////////////////////\nasync function handleCreate() {\n\n\torders.state.current.status = 'created';\n\n\torders.state.current.owner = {\n\t\ttarget: orderOrganization.value[0]._id,\n\t\ttype: 'organization'\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.creator = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.customer = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\torders.state.current.positions = shopcart.state.positions\n\n \tconst referralCode = localStorage.getItem('referalCode');\n \n if (referralCode) {\n orders.state.current.referralCode = referralCode;\n }\n\n let order = await orders.actions.create(orders.state.current);\n\n if (order) {\n \tawait router.push({\n \t\tname: 'Order',\n \t\tparams: {\n \t\t\torder: order._id\n \t\t}\n \t})\n \t\t\n \tshopcart.actions.resetShopcart()\n\n } else {\n \talert('something wrong')\n }\n}\n</script>\n\n<style lang=\"scss\">\n\n.round-wrapper {\n\tposition: relative;\n\n\t.round {\n\t\tmargin: 0;\n\t\tmargin-right: 1rem;\n\t}\n\n\tinput:checked {\n\t\tbackground: #00ff88;\n\t}\n\n\t.round-checkmark {\n\t\tposition: absolute;\n\t\twidth: 0.5rem;\n\t\theight: 0.5rem;\n\t\tbackground: white;\n\n\t\tleft: 0.5rem;\n\t\ttop: 0.5rem;\n\n\t\topacity: 1;\n\t}\n}\n</style>"],"names":["ref","useRoute","useRouter","computed","orders.state","users.state","shopcart.getters","globals.state","orders.getters","auth.state","orders.mutations","onMounted","users.actions","shopcart.state","organizations.actions","watch","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,UAAM,oBAAoBA,IAAG,IAAC,KAAK;AAErBC,cAAQ,SAAA;AACtB,UAAM,SAASC,UAAS,UAAA;AAExB,UAAM,QAAQC,IAAAA,SAAS,MAAMC,OAAAA,MAAa,OAAO;AACpCD,QAAAA,SAAS,MAAME,MAAW,MAAC,OAAO;AAE/C,UAAM,iBAAiBC,SAAAA,QAAiB;AAExC,UAAM,eAAeH,IAAQ,SAAC,MAAM;;AAClC,YAAM,OAAOC,OAAAA,MAAa,QAAQ,SAAS;AAC3C,YAAM,aAAW,uBAAkB,MAAM,CAAC,MAAzB,mBAA4B,aAAY;AACzD,YAAM,WAASG,mBAAa,MAAC,YAAdA,mBAAuB,WAAvBA,mBAA+B,qBAAoB,CAAA;AAElE,aAAOC,eAAe,iBAAiB,MAAM,UAAU,MAAM;AAAA,IAC/D,CAAC;AAGD,UAAM,oBAAoBR,IAAG,IAAC,CAAE,CAAA;AAGhC,QAAI,CAACO,QAAAA,MAAc,QAAQ,OAAO,8BAA8B,CAACE,KAAU,MAAC,KAAK,KAAK;AACrF,aAAO,KAAK,EAAC,MAAM,UAAS,CAAC;AAAA,IAC9B;AAGAC,WAAAA,UAAiB,WAAU;AAE3BC,QAAAA,UAAU,YAAU;;AACnB,wBAAkB,QAAQ;AAG1B,UAAIF,KAAU,MAAC,KAAK,KAAK;AACb,cAAMG,cAAc,K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A,UACxB,MAAM;AAAA,QACT;AAAA,MACA;AAECL,mBAAa,QAAQ,YAAYS,eAAe;AAE/C,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBT,qBAAa,QAAQ,eAAe;AAAA,MACxC;AAEE,UAAIY,SAAQ,MAAMC,OAAAA,QAAe,OAAOb,OAAAA,MAAa,OAAO;AAE5D,UAAIY,QAAO;AACV,cAAM,OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,iBAAAA,QAAiB,cAAa;AAAA,MAEjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { ref, computed, onMounted, watch, createElementBlock, openBlock, createBlock, createCommentVNode, createElementVNode, createTextVNode, toDisplayString, createVNode, Fragment, renderList, unref } from "vue";
1
+ import { ref, computed, onMounted, watch, createElementBlock, openBlock, createBlock, createCommentVNode, createElementVNode, createVNode, Fragment, renderList, unref, createTextVNode } from "vue";
2
2
  import _sfc_main$7 from "../blocks/CardOrderItem.vue.js";
3
3
  import _sfc_main$1 from "../sections/AskToLogin.vue.js";
4
4
  import _sfc_main$3 from "../sections/Succes.vue.js";
@@ -169,7 +169,6 @@ const _sfc_main = {
169
169
  key: 1,
170
170
  order: order.value
171
171
  }, null, 8, ["order"])) : createCommentVNode("", true),
172
- createTextVNode(" " + toDisplayString(state$4.organization) + " ", 1),
173
172
  state.current.status !== true && state$4.positions.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [
174
173
  createVNode(_sfc_main$4, {
175
174
  customer: state.current.customer
@@ -1 +1 @@
1
- {"version":3,"file":"OrderCreate.vue.js","sources":["../../../../../../../src/modules/orders/components/pages/OrderCreate.vue"],"sourcesContent":["<template>\n\n<section class=\"bg-white pd-thin\">\n\n\t<!-- Ask to login -->\n\t<AskToLogin class=\"mn-b-thin\" v-if=\"auth.state.access.status === false\" /> \n\n\t<!-- Order form -->\n\t<div class=\"gap-small mn-b-thin cols-2\">\n\t\t<!-- Empty State -->\n\t\t<EmptyState \n\t\t\tv-if=\"shopcart.state.positions < 1\" \n\t\t/>\t\n\n\t\t<Succes \n\t\t\tv-if=\"order.status === true && shopcart.state.positions.length > 0\" \n\t\t\t:order=\"order\" \n\t\t/>\n\t\t{{shopcart.state.organization}}\n\t\t<!-- Order Form -->\n\t\t<div\n\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\" \n\t\t\tclass=\"rows-1 gap-thin\"\n\t\t>\n\t\t\t<FormCustomerDetails\n\t\t\t\t:customer=\"orders.state.current.customer\"\n\t\t\t/>\n\t\t\t<FormPayment \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t<FormDelivery \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t\n\t\t</div>\n\n\t\t<!-- Order positions -->\n\t\t<div \n\t\t\tv-if=\"shopcart.state.positions.length > 0\" \n\t\t\tclass=\"bg-white br-solid br-light br-1px pd-medium radius-medium\"\n\t\t>\n\t\t\t<h4 class=\"font-second mn-b-thin\">Your Order</h4>\n\n\t\t\t<ul class=\"flex gap-thin flex-wrap mn-b-thin\">\n\t\t\t\t<CardOrderItem \n\t\t\t\t\tv-for=\"product in shopcart.state.positions\" \n\t\t\t\t\t:key=\"product._id\" \n\t\t\t\t\t:editable=\"true\" \n\t\t\t\t\t:product=\"product\" \n\t :increase=\"product => shopcart.actions.incrementItemQuantity(product._id)\"\n\t :decrease=\"product => shopcart.actions.decrementItemQuantity(product._id)\"\n\t :remove=\"product => shopcart.actions.removeProduct(product._id)\"\n\t\t\t\t\t@updateRentDates=\"(product, dates) => shopcart.actions.updateRentDates({ productId: product._id, dates })\"\n\t class=\"w-100 bg-white \"\n\t />\n\t\t\t</ul>\n\n\t\t\t\t<div \n\t\t\t\tclass=\"mn-b-thin\"\n\t\t\t>\t\n\t\t\t\t<PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :deliveryRate=\"deliveryCost\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n :showDeliveryFee=\"globals.state.options?.orders.showDeliveryFee\"\n />\n\t\t\t</div>\n\t\t\t<!-- Send order -->\n\t\t <button \n\t\t \tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t \t:disabled=\"\n\t\t errorName \n\t\t || errorPhoneOrMessenger \n\t\t || errorCity \n\t\t || errorAddress \n\t\t || errorDelivery \n\t\t || errorPayment\n\t\t || isLocationLoading\n\t\t \"\n\t\t @click=\"handleCreate()\" \n\t\t class=\"bg-main mn-b-small pd-small radius-big w-100 button\"\n\t\t >\n\t\t Place an Order\n\t\t </button>\n\n\t\t <p class='mn-b-thin'>\n\t\t\t\tI agree that placing the order places me under an obligation to make a payment in accordance with <a class=\"t-semi font-second t-second\" href=\"/legal/terms-of-use\" target=\"_blank\">Terms of Use.</a>\n\t\t\t</p>\n\t\t\t<p >\n\t\t\t\t\n\t\t\t</p>\n\t\t</div>\n\n\t</div>\n\n\t\n\t\n</section>\n\n</template>\n\n\n<script setup>\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import components\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Block\nimport CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue'\n// Sections\nimport AskToLogin from '@martyrs/src/modules/orders/components/sections/AskToLogin.vue'\nimport Succes from '@martyrs/src/modules/orders/components/sections/Succes.vue'\nimport EmptyState from '@martyrs/src/modules/orders/components/sections/EmptyState.vue'\n\nimport PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\nimport FormCustomerDetails from '@martyrs/src/modules/orders/components/sections/FormCustomerDetails.vue'\nimport FormDelivery from '@martyrs/src/modules/orders/components/sections/FormDelivery.vue'\nimport FormPayment from '@martyrs/src/modules/orders/components/sections/FormPayment.vue'\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import libs\n///////////////////////////////////////////////////////////////////////////////////////////////////\nimport { ref, computed, onMounted, watch } from 'vue'\nimport { useRoute,useRouter } from 'vue-router'\n// Store\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart';\nimport * as organizations from '@martyrs/src/modules/organizations/store/organizations';\nimport * as orders from '@martyrs/src/modules/orders/store/orders';\nimport * as users from '@martyrs/src/modules/auth/views/store/users';\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Variables and computed\n//////////////////////////////////////////////////////////////////////////////////////////////////\nconst isLocationLoading = ref(false)\n// Accessing router and store\nconst route = useRoute()\nconst router = useRouter()\n// COMPUTED\nconst order = computed(() => orders.state.current)\nconst user = computed(() => users.state.current)\n\nconst cartTotalPrice = shopcart.getters.cartTotalPrice\n\nconst deliveryCost = computed(() => {\n const type = orders.state.current.delivery.type\n const distance = orderOrganization.value[0]?.distance || 0\n const config = globals.state.options?.orders?.delivery_formula || {}\n\n return orders.getters.getDeliveryPrice(type, distance, config)\n})\n\n// Organization\nconst orderOrganization = ref({})\n\n\nif (!globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id) { \n\trouter.push({name: 'Sign In'})\t\n}\n\n\norders.mutations.resetOrder()\n\nonMounted(async()=> {\n\tisLocationLoading.value = true\n\n\n\tif (auth.state.user._id) {\n\t\tlet data = await users.actions.read({ _id:auth.state.user._id, user: auth.state.user._id });\n\t\torders.state.current.customer.profile.name = users.state.current.profile.name\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t}\n\n\torders.state.current.organization = shopcart.state.organization\n\n\torderOrganization.value = await organizations.actions.read({\n\t _id: shopcart.state.organization,\n\t location: globals.state.position?.location,\n\t lookup: ['spots']\n\t})\n\t\n isLocationLoading.value = false\n})\n\n\nwatch(\n () => orders.state.current.delivery,\n async (newVal) => {\n if (newVal?.location) {\n \tisLocationLoading.value = true\n\n orderOrganization.value = await organizations.actions.read({\n _id: shopcart.state.organization,\n location: newVal.location,\n lookup: ['spots']\n })\n\n isLocationLoading.value = false\n }\n },\n { deep: true }\n)\n\n\n/////////////////////////////\n// Store Verification\n/////////////////////////////\nconst errorName = computed(() => {\n if (orders.state.current.customer.name?.length < 2) { return true } else { return false }\n});\n\nconst errorPhoneOrMessenger = computed(() => {\n const hasMessengerType = orders.state.current.customer.messenger?.type;\n const hasMessengerValue = orders.state.current.customer.messenger?.value?.length >\t 2;\n const hasPhone = orders.state.current.customer.number?.length > 0;\n // Ошибка, если нет ни номера телефона, ни корректного типа и значения мессенджера\n return !hasPhone && !(hasMessengerType && hasMessengerValue);\n});\n\nconst errorAddress = computed(() => {\n const type = orders.state.current.delivery.type;\n if (type === \"pickup\") {\n return !orders.state.current.delivery.spot;\n } else if (type === \"courier\" || type === \"mail\") {\n const address = orders.state.current.delivery.address;\n return !address || typeof address !== 'string' || address.length < 2;\n }\n return false;\n});\n\nconst errorDelivery = computed(() => {\n if (orders.state.current.delivery.type) {return false } else {return true } \n})\n\nconst errorPayment = computed(() => {\n if (orders.state.current.payment.type) { return false } else {return true } \n})\n/////////////////////////////\n// Methods\n/////////////////////////////\nasync function handleCreate() {\n\n\torders.state.current.status = 'created';\n\n\torders.state.current.owner = {\n\t\ttarget: orderOrganization.value[0]._id,\n\t\ttype: 'organization'\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.creator = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.customer = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\torders.state.current.positions = shopcart.state.positions\n\n \tconst referralCode = localStorage.getItem('referalCode');\n \n if (referralCode) {\n orders.state.current.referralCode = referralCode;\n }\n\n let order = await orders.actions.create(orders.state.current);\n\n if (order) {\n \tawait router.push({\n \t\tname: 'Order',\n \t\tparams: {\n \t\t\torder: order._id\n \t\t}\n \t})\n \t\t\n \tshopcart.actions.resetShopcart()\n\n } else {\n \talert('something wrong')\n }\n}\n</script>\n\n<style lang=\"scss\">\n\n.round-wrapper {\n\tposition: relative;\n\n\t.round {\n\t\tmargin: 0;\n\t\tmargin-right: 1rem;\n\t}\n\n\tinput:checked {\n\t\tbackground: #00ff88;\n\t}\n\n\t.round-checkmark {\n\t\tposition: absolute;\n\t\twidth: 0.5rem;\n\t\theight: 0.5rem;\n\t\tbackground: white;\n\n\t\tleft: 0.5rem;\n\t\ttop: 0.5rem;\n\n\t\topacity: 1;\n\t}\n}\n</style>"],"names":["orders.state","users.state","shopcart.getters","globals.state","orders.getters","auth.state","orders.mutations","users.actions","shopcart.state","organizations.actions","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,UAAM,oBAAoB,IAAI,KAAK;AAErB,aAAQ;AACtB,UAAM,SAAS,UAAS;AAExB,UAAM,QAAQ,SAAS,MAAMA,MAAa,OAAO;AACpC,aAAS,MAAMC,QAAY,OAAO;AAE/C,UAAM,iBAAiBC,QAAiB;AAExC,UAAM,eAAe,SAAS,MAAM;;AAClC,YAAM,OAAOF,MAAa,QAAQ,SAAS;AAC3C,YAAM,aAAW,uBAAkB,MAAM,CAAC,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,KAAK;AACxBL,cAAa,QAAQ,UAAU;AAAA,UAC9B,QAAQK,QAAW,KAAK;AAAA,UACxB,MAAM;AAAA,QACT;AAAA,MACA;AAEC,UAAIA,QAAW,KAAK,KAAK;AACxBL,cAAa,QAAQ,WAAW;AAAA,UAC/B,QAAQK,QAAW,KAAK;AAAA,UACxB,MAAM;AAAA,QACT;AAAA,MACA;AAECL,YAAa,QAAQ,YAAYQ,QAAe;AAE/C,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBR,cAAa,QAAQ,eAAe;AAAA,MACxC;AAEE,UAAIU,SAAQ,MAAMC,UAAe,OAAOX,MAAa,OAAO;AAE5D,UAAIU,QAAO;AACV,cAAM,OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,kBAAiB,cAAa;AAAA,MAEjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"OrderCreate.vue.js","sources":["../../../../../../../src/modules/orders/components/pages/OrderCreate.vue"],"sourcesContent":["<template>\n\n<section class=\"bg-white pd-thin\">\n\n\t<!-- Ask to login -->\n\t<AskToLogin class=\"mn-b-thin\" v-if=\"auth.state.access.status === false\" /> \n\n\t<!-- Order form -->\n\t<div class=\"gap-small mn-b-thin cols-2\">\n\t\t<!-- Empty State -->\n\t\t<EmptyState \n\t\t\tv-if=\"shopcart.state.positions < 1\" \n\t\t/>\t\n\n\t\t<Succes \n\t\t\tv-if=\"order.status === true && shopcart.state.positions.length > 0\" \n\t\t\t:order=\"order\" \n\t\t/>\n\t\t<!-- Order Form -->\n\t\t<div\n\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\" \n\t\t\tclass=\"rows-1 gap-thin\"\n\t\t>\n\t\t\t<FormCustomerDetails\n\t\t\t\t:customer=\"orders.state.current.customer\"\n\t\t\t/>\n\t\t\t<FormPayment \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t<FormDelivery \t\n\t\t\t\tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t\t\t:order=\"orders.state.current\" \n\t\t\t\t:organization=\"orderOrganization[0]\" \n\t\t\t/>\n\t\t\t\n\t\t</div>\n\n\t\t<!-- Order positions -->\n\t\t<div \n\t\t\tv-if=\"shopcart.state.positions.length > 0\" \n\t\t\tclass=\"bg-white br-solid br-light br-1px pd-medium radius-medium\"\n\t\t>\n\t\t\t<h4 class=\"font-second mn-b-thin\">Your Order</h4>\n\n\t\t\t<ul class=\"flex gap-thin flex-wrap mn-b-thin\">\n\t\t\t\t<CardOrderItem \n\t\t\t\t\tv-for=\"product in shopcart.state.positions\" \n\t\t\t\t\t:key=\"product._id\" \n\t\t\t\t\t:editable=\"true\" \n\t\t\t\t\t:product=\"product\" \n\t :increase=\"product => shopcart.actions.incrementItemQuantity(product._id)\"\n\t :decrease=\"product => shopcart.actions.decrementItemQuantity(product._id)\"\n\t :remove=\"product => shopcart.actions.removeProduct(product._id)\"\n\t\t\t\t\t@updateRentDates=\"(product, dates) => shopcart.actions.updateRentDates({ productId: product._id, dates })\"\n\t class=\"w-100 bg-white \"\n\t />\n\t\t\t</ul>\n\n\t\t\t\t<div \n\t\t\t\tclass=\"mn-b-thin\"\n\t\t\t>\t\n\t\t\t\t<PriceTotal \n :totalPrice=\"cartTotalPrice\"\n :deliveryRate=\"deliveryCost\"\n :currency=\"returnCurrency()\"\n :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n :showDeliveryFee=\"globals.state.options?.orders.showDeliveryFee\"\n />\n\t\t\t</div>\n\t\t\t<!-- Send order -->\n\t\t <button \n\t\t \tv-if=\"orders.state.current.status !== true && shopcart.state.positions.length > 0\"\n\t\t \t:disabled=\"\n\t\t errorName \n\t\t || errorPhoneOrMessenger \n\t\t || errorCity \n\t\t || errorAddress \n\t\t || errorDelivery \n\t\t || errorPayment\n\t\t || isLocationLoading\n\t\t \"\n\t\t @click=\"handleCreate()\" \n\t\t class=\"bg-main mn-b-small pd-small radius-big w-100 button\"\n\t\t >\n\t\t Place an Order\n\t\t </button>\n\n\t\t <p class='mn-b-thin'>\n\t\t\t\tI agree that placing the order places me under an obligation to make a payment in accordance with <a class=\"t-semi font-second t-second\" href=\"/legal/terms-of-use\" target=\"_blank\">Terms of Use.</a>\n\t\t\t</p>\n\t\t\t<p >\n\t\t\t\t\n\t\t\t</p>\n\t\t</div>\n\n\t</div>\n\n\t\n\t\n</section>\n\n</template>\n\n\n<script setup>\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import components\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Block\nimport CardOrderItem from '@martyrs/src/modules/orders/components/blocks/CardOrderItem.vue'\n// Sections\nimport AskToLogin from '@martyrs/src/modules/orders/components/sections/AskToLogin.vue'\nimport Succes from '@martyrs/src/modules/orders/components/sections/Succes.vue'\nimport EmptyState from '@martyrs/src/modules/orders/components/sections/EmptyState.vue'\n\nimport PriceTotal from '@martyrs/src/modules/orders/components/elements/PriceTotal.vue';\n\nimport FormCustomerDetails from '@martyrs/src/modules/orders/components/sections/FormCustomerDetails.vue'\nimport FormDelivery from '@martyrs/src/modules/orders/components/sections/FormDelivery.vue'\nimport FormPayment from '@martyrs/src/modules/orders/components/sections/FormPayment.vue'\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Import libs\n///////////////////////////////////////////////////////////////////////////////////////////////////\nimport { ref, computed, onMounted, watch } from 'vue'\nimport { useRoute,useRouter } from 'vue-router'\n// Store\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart';\nimport * as organizations from '@martyrs/src/modules/organizations/store/organizations';\nimport * as orders from '@martyrs/src/modules/orders/store/orders';\nimport * as users from '@martyrs/src/modules/auth/views/store/users';\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Variables and computed\n//////////////////////////////////////////////////////////////////////////////////////////////////\nconst isLocationLoading = ref(false)\n// Accessing router and store\nconst route = useRoute()\nconst router = useRouter()\n// COMPUTED\nconst order = computed(() => orders.state.current)\nconst user = computed(() => users.state.current)\n\nconst cartTotalPrice = shopcart.getters.cartTotalPrice\n\nconst deliveryCost = computed(() => {\n const type = orders.state.current.delivery.type\n const distance = orderOrganization.value[0]?.distance || 0\n const config = globals.state.options?.orders?.delivery_formula || {}\n\n return orders.getters.getDeliveryPrice(type, distance, config)\n})\n\n// Organization\nconst orderOrganization = ref({})\n\n\nif (!globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user._id) { \n\trouter.push({name: 'Sign In'})\t\n}\n\n\norders.mutations.resetOrder()\n\nonMounted(async()=> {\n\tisLocationLoading.value = true\n\n\n\tif (auth.state.user._id) {\n\t\tlet data = await users.actions.read({ _id:auth.state.user._id, user: auth.state.user._id });\n\t\torders.state.current.customer.profile.name = users.state.current.profile.name\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t\torders.state.current.customer.phone = users.state.current.phone\n\t}\n\n\torders.state.current.organization = shopcart.state.organization\n\n\torderOrganization.value = await organizations.actions.read({\n\t _id: shopcart.state.organization,\n\t location: globals.state.position?.location,\n\t lookup: ['spots']\n\t})\n\t\n isLocationLoading.value = false\n})\n\n\nwatch(\n () => orders.state.current.delivery,\n async (newVal) => {\n if (newVal?.location) {\n \tisLocationLoading.value = true\n\n orderOrganization.value = await organizations.actions.read({\n _id: shopcart.state.organization,\n location: newVal.location,\n lookup: ['spots']\n })\n\n isLocationLoading.value = false\n }\n },\n { deep: true }\n)\n\n\n/////////////////////////////\n// Store Verification\n/////////////////////////////\nconst errorName = computed(() => {\n if (orders.state.current.customer.name?.length < 2) { return true } else { return false }\n});\n\nconst errorPhoneOrMessenger = computed(() => {\n const hasMessengerType = orders.state.current.customer.messenger?.type;\n const hasMessengerValue = orders.state.current.customer.messenger?.value?.length >\t 2;\n const hasPhone = orders.state.current.customer.number?.length > 0;\n // Ошибка, если нет ни номера телефона, ни корректного типа и значения мессенджера\n return !hasPhone && !(hasMessengerType && hasMessengerValue);\n});\n\nconst errorAddress = computed(() => {\n const type = orders.state.current.delivery.type;\n if (type === \"pickup\") {\n return !orders.state.current.delivery.spot;\n } else if (type === \"courier\" || type === \"mail\") {\n const address = orders.state.current.delivery.address;\n return !address || typeof address !== 'string' || address.length < 2;\n }\n return false;\n});\n\nconst errorDelivery = computed(() => {\n if (orders.state.current.delivery.type) {return false } else {return true } \n})\n\nconst errorPayment = computed(() => {\n if (orders.state.current.payment.type) { return false } else {return true } \n})\n/////////////////////////////\n// Methods\n/////////////////////////////\nasync function handleCreate() {\n\n\torders.state.current.status = 'created';\n\n\torders.state.current.owner = {\n\t\ttarget: orderOrganization.value[0]._id,\n\t\ttype: 'organization'\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.creator = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\tif (auth.state.user._id) {\n\t\torders.state.current.customer = {\n\t\t\ttarget: auth.state.user._id,\n\t\t\ttype: 'user'\n\t\t}\n\t}\n\n\torders.state.current.positions = shopcart.state.positions\n\n \tconst referralCode = localStorage.getItem('referalCode');\n \n if (referralCode) {\n orders.state.current.referralCode = referralCode;\n }\n\n let order = await orders.actions.create(orders.state.current);\n\n if (order) {\n \tawait router.push({\n \t\tname: 'Order',\n \t\tparams: {\n \t\t\torder: order._id\n \t\t}\n \t})\n \t\t\n \tshopcart.actions.resetShopcart()\n\n } else {\n \talert('something wrong')\n }\n}\n</script>\n\n<style lang=\"scss\">\n\n.round-wrapper {\n\tposition: relative;\n\n\t.round {\n\t\tmargin: 0;\n\t\tmargin-right: 1rem;\n\t}\n\n\tinput:checked {\n\t\tbackground: #00ff88;\n\t}\n\n\t.round-checkmark {\n\t\tposition: absolute;\n\t\twidth: 0.5rem;\n\t\theight: 0.5rem;\n\t\tbackground: white;\n\n\t\tleft: 0.5rem;\n\t\ttop: 0.5rem;\n\n\t\topacity: 1;\n\t}\n}\n</style>"],"names":["orders.state","users.state","shopcart.getters","globals.state","orders.getters","auth.state","orders.mutations","users.actions","shopcart.state","organizations.actions","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,UAAM,oBAAoB,IAAI,KAAK;AAErB,aAAQ;AACtB,UAAM,SAAS,UAAS;AAExB,UAAM,QAAQ,SAAS,MAAMA,MAAa,OAAO;AACpC,aAAS,MAAMC,QAAY,OAAO;AAE/C,UAAM,iBAAiBC,QAAiB;AAExC,UAAM,eAAe,SAAS,MAAM;;AAClC,YAAM,OAAOF,MAAa,QAAQ,SAAS;AAC3C,YAAM,aAAW,uBAAkB,MAAM,CAAC,MAAzB,mBAA4B,aAAY;AACzD,YAAM,WAASG,mBAAc,YAAdA,mBAAuB,WAAvBA,mBAA+B,qBAAoB,CAAA;AAElE,aAAOC,UAAe,iBAAiB,MAAM,UAAU,MAAM;AAAA,IAC/D,CAAC;AAGD,UAAM,oBAAoB,IAAI,CAAE,CAAA;AAGhC,QAAI,CAACD,QAAc,QAAQ,OAAO,8BAA8B,CAACE,QAAW,KAAK,KAAK;AACrF,aAAO,KAAK,EAAC,MAAM,UAAS,CAAC;AAAA,IAC9B;AAGAC,cAAiB,WAAU;AAE3B,cAAU,YAAU;;AACnB,wBAAkB,QAAQ;AAG1B,UAAID,QAAW,KAAK,KAAK;AACb,cAAME,QAAc,KAAK,EAAE,KAA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OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,kBAAiB,cAAa;AAAA,MAEjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -26,6 +26,7 @@ const actions = {
26
26
  }
27
27
  },
28
28
  addProductToCart(product, organization, date) {
29
+ console.log("organization shopcart is", organization);
29
30
  const cartItem = state.positions.find(
30
31
  (item) => item._id === product._id
31
32
  );
@@ -1 +1 @@
1
- {"version":3,"file":"shopcart.cjs","sources":["../../../../../../src/modules/orders/store/shopcart.js"],"sourcesContent":["/////////////////////////////\n// DEPENDENCIES\n/////////////////////////////\nimport { reactive, watch, computed } from \"vue\";\n// Dependencies\nimport Cookies from 'js-cookie'\n// Globals \nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n\n/////////////////////////////\n// State\n/////////////////////////////\nconst state = reactive({\n organization: null,\n positions: [],\n currentState: false\n});\n\n/////////////////////////////\n// Helpers\n/////////////////////////////\nconst helpers = {\n createCartItem(product, organization, type = 'sale') {\n return {\n _id: product._id,\n images: product.images,\n name: product.name,\n price: product.price,\n listing: product.listing,\n quantity: 1,\n org_id: organization,\n type: type\n };\n },\n\n saveToStorage() {\n localStorage.setItem(CART_STORAGE_KEY, JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n async validateProduct(product) {\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct) {\n return false;\n }\n\n return serverProduct.price === product.price &&\n serverProduct.name === product.name &&\n serverProduct.available !== false;\n }\n};\n\n/////////////////////////////\n// SYNC PRODUCT IN SHOPCART\n/////////////////////////////\n// Constants\nconst CART_STORAGE_KEY = 'shopcart';\nconst SYNC_INTERVAL = 30000; // 30 seconds in milliseconds\n\n// API service\nconst api = {\n async fetchProduct(productId) {\n try {\n const response = await fetch(`/api/products/read`, { _id: productId});\n return await response.json();\n } catch (error) {\n console.error('Failed to fetch product:', error);\n return null;\n }\n }\n};\n\nasync function syncWithServer() {\n try {\n const invalidProducts = [];\n \n for (let i = 0; i < state.positions.length; i++) {\n const product = state.positions[i];\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct || \n serverProduct.price !== product.price || \n serverProduct.name !== product.name || \n serverProduct.available === false) {\n invalidProducts.push(product._id);\n }\n }\n\n if (invalidProducts.length > 0) {\n state.positions = state.positions.filter(\n product => !invalidProducts.includes(product._id)\n );\n helpers.saveToStorage();\n setError('Some products were removed from cart due to changes on server');\n }\n } catch (error) {\n console.error('Failed to sync with server:', error);\n }\n}\n// Initialize periodic sync\nlet syncInterval;\n\nconst startPeriodicSync = () => {\n syncInterval = setInterval(syncWithServer, SYNC_INTERVAL);\n};\n\nconst stopPeriodicSync = () => {\n if (syncInterval) {\n clearInterval(syncInterval);\n }\n};\n\n// Start sync when module is imported\n// startPeriodicSync();\n/////////////////////////////\n// Actions\n/////////////////////////////\nconst actions = {\n\n toggleShopcart () {\n state.currentState = state.currentState ? false : true;\n },\n\n setShopcart() {\n try {\n const storedShopcart = localStorage.getItem('shopcart');\n\n if (storedShopcart) {\n const shopcartData = JSON.parse(storedShopcart);\n state.positions = shopcartData.positions; // Восстанавливаем продукты\n state.organization = shopcartData.organization; // Восстанавливаем _id организации\n } \n } catch (error) {\n console.error(error);\n throw error;\n }\n },\n\n\n addProductToCart(product, organization, date) {\n const cartItem = state.positions.find(\n (item) => item._id === product._id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n } else {\n state.positions.push({\n _id: product._id,\n images: product.images,\n name: product.name,\n listing: product.listing,\n price: product.price,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n\n // Обновляем объект корзины в localStorage, включая _id организации\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: organization // Сохраняем _id организации в корне объекта корзины\n }));\n },\n\n\n removeProduct(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n\n if (cartItemIndex > -1) {\n state.positions.splice(cartItemIndex, 1);\n \n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n decrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n \n if (cartItemIndex > -1) {\n cartItem.quantity--;\n \n if (cartItem.quantity < 1) {\n state.positions.splice(cartItemIndex, 1);\n }\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n incrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n updateRentDates({ productId, dates }) {\n const product = state.positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n\n resetShopcart() {\n state.positions = [];\n \n localStorage.removeItem('shopcart');\n },\n};\n\n/////////////////////////////\n// Getters\n/////////////////////////////\nconst getters = {\n cartTotalPrice: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n // Проверяем тип листинга\n if (product.listing === 'rent') {\n const start = new Date(product.date.start)\n const end = new Date(product.date.end)\n const diffTime = Math.abs(end - start)\n return total + product.price * (Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1);\n } else {\n // Для обычных товаров умножаем на количество\n return total + product.price * (product.quantity || 1);\n }\n }, 0));\n }),\n cartTotalAmount: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n return total + product.quantity;\n }, 0));\n }),\n getStoreCartState: computed(() => {\n return Number(state.currentState);\n }),\n};\n/////////////////////////////\n// History\n/////////////////////////////\nconst history = []\nhistory.push(state) \n\n/////////////////////////////\n// Watch\n/////////////////////////////\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\n/////////////////////////////\n// Module Export\n/////////////////////////////\nexport {\n state,\n actions,\n getters\n}"],"names":["reactive","computed","watch"],"mappings":";;;;;AAYK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,cAAc;AAAA,EACd,WAAW,CAAE;AAAA,EACb,cAAc;AAChB,CAAC;AAwGI,MAAC,UAAU;AAAA,EAEd,iBAAkB;AAChB,UAAM,eAAe,MAAM,eAAe,QAAQ;AAAA,EACnD;AAAA,EAED,cAAc;AACZ,QAAI;AACF,YAAM,iBAAiB,aAAa,QAAQ,UAAU;AAEtD,UAAI,gBAAgB;AAClB,cAAM,eAAe,KAAK,MAAM,cAAc;AAC9C,cAAM,YAAY,aAAa;AAC/B,cAAM,eAAe,aAAa;AAAA,MACnC;AAAA,IACF,SAAQ,OAAO;AACd,cAAQ,MAAM,KAAK;AACnB,YAAM;AAAA,IACZ;AAAA,EACG;AAAA,EAGD,iBAAiB,SAAS,cAAc,MAAM;AAC5C,UAAM,WAAW,MAAM,UAAU;AAAA,MAC/B,CAAC,SAAS,KAAK,QAAQ,QAAQ;AAAA,IAChC;AAED,QAAI,UAAU;AACZ,eAAS;AAAA,IACf,OAAW;AACL,YAAM,UAAU,KAAK;AAAA,QACnB,KAAK,QAAQ;AAAA,QACb,QAAQ,QAAQ;AAAA,QAChB,MAAM,QAAQ;AAAA,QACd,SAAS,QAAQ;AAAA,QACjB,OAAO,QAAQ;AAAA,QACf,UAAU;AAAA,QACV;AAAA,QACA,QAAQ;AAAA;AAAA,MAChB,CAAO;AAAA,IACP;AAGI,iBAAa,QAAQ,YAAY,KAAK,UA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AQ,OAAO;AAAA,IACrB;AAEI,iBAAa,QAAQ,YAAY,KAAK,UAAU;AAAA,MAC9C,WAAW,MAAM;AAAA,MACjB,cAAc,MAAM;AAAA,IAC1B,CAAK,CAAC;AAAA,EACH;AAAA,EAGD,gBAAgB;AACd,UAAM,YAAY,CAAE;AAEpB,iBAAa,WAAW,UAAU;AAAA,EACnC;AACH;AAKK,MAAC,UAAU;AAAA,EACd,gBAAgBC,IAAQ,SAAC,MAAM;AAC7B,WAAO,OAAO,MAAM,UAAU,OAAO,CAAC,OAAO,YAAY;AAEvD,UAAI,QAAQ,YAAY,QAAQ;AAC9B,cAAM,QAAQ,IAAI,KAAK,QAAQ,KAAK,KAAK;AACzC,cAAM,MAAM,IAAI,KAAK,QAAQ,KAAK,GAAG;AACrC,cAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,eAAO,QAAQ,QAAQ,SAAS,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,MACtF,OAAa;AAEL,eAAO,QAAQ,QAAQ,SAAS,QAAQ,YAAY;AAAA,MAC5D;AAAA,IACK,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,iBAAiBA,IAAQ,SAAC,MAAM;AAC9B,WAAO,OAAO,MAAM,UAAU,OAAO,CAAC,OAAO,YAAY;AACvD,aAAO,QAAQ,QAAQ;AAAA,IACxB,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,mBAAmBA,IAAQ,SAAC,MAAM;AAChC,WAAO,OAAO,MAAM,YAAY;AAAA,EACpC,CAAG;AACH;AAUAC,IAAAA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;;;;"}
1
+ {"version":3,"file":"shopcart.cjs","sources":["../../../../../../src/modules/orders/store/shopcart.js"],"sourcesContent":["/////////////////////////////\n// DEPENDENCIES\n/////////////////////////////\nimport { reactive, watch, computed } from \"vue\";\n// Dependencies\nimport Cookies from 'js-cookie'\n// Globals \nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n\n/////////////////////////////\n// State\n/////////////////////////////\nconst state = reactive({\n organization: null,\n positions: [],\n currentState: false\n});\n\n/////////////////////////////\n// Helpers\n/////////////////////////////\nconst helpers = {\n createCartItem(product, organization, type = 'sale') {\n return {\n _id: product._id,\n images: product.images,\n name: product.name,\n price: product.price,\n listing: product.listing,\n quantity: 1,\n org_id: organization,\n type: type\n };\n },\n\n saveToStorage() {\n localStorage.setItem(CART_STORAGE_KEY, JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n async validateProduct(product) {\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct) {\n return false;\n }\n\n return serverProduct.price === product.price &&\n serverProduct.name === product.name &&\n serverProduct.available !== false;\n }\n};\n\n/////////////////////////////\n// SYNC PRODUCT IN SHOPCART\n/////////////////////////////\n// Constants\nconst CART_STORAGE_KEY = 'shopcart';\nconst SYNC_INTERVAL = 30000; // 30 seconds in milliseconds\n\n// API service\nconst api = {\n async fetchProduct(productId) {\n try {\n const response = await fetch(`/api/products/read`, { _id: productId});\n return await response.json();\n } catch (error) {\n console.error('Failed to fetch product:', error);\n return null;\n }\n }\n};\n\nasync function syncWithServer() {\n try {\n const invalidProducts = [];\n \n for (let i = 0; i < state.positions.length; i++) {\n const product = state.positions[i];\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct || \n serverProduct.price !== product.price || \n serverProduct.name !== product.name || \n serverProduct.available === false) {\n invalidProducts.push(product._id);\n }\n }\n\n if (invalidProducts.length > 0) {\n state.positions = state.positions.filter(\n product => !invalidProducts.includes(product._id)\n );\n helpers.saveToStorage();\n setError('Some products were removed from cart due to changes on server');\n }\n } catch (error) {\n console.error('Failed to sync with server:', error);\n }\n}\n// Initialize periodic sync\nlet syncInterval;\n\nconst startPeriodicSync = () => {\n syncInterval = setInterval(syncWithServer, SYNC_INTERVAL);\n};\n\nconst stopPeriodicSync = () => {\n if (syncInterval) {\n clearInterval(syncInterval);\n }\n};\n\n// Start sync when module is imported\n// startPeriodicSync();\n/////////////////////////////\n// Actions\n/////////////////////////////\nconst actions = {\n\n toggleShopcart () {\n state.currentState = state.currentState ? false : true;\n },\n\n setShopcart() {\n try {\n const storedShopcart = localStorage.getItem('shopcart');\n\n if (storedShopcart) {\n const shopcartData = JSON.parse(storedShopcart);\n state.positions = shopcartData.positions; // Восстанавливаем продукты\n state.organization = shopcartData.organization; // Восстанавливаем _id организации\n } \n } catch (error) {\n console.error(error);\n throw error;\n }\n },\n\n\n addProductToCart(product, organization, date) {\n console.log('organization shopcart is', organization)\n const cartItem = state.positions.find(\n (item) => item._id === product._id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n } else {\n state.positions.push({\n _id: product._id,\n images: product.images,\n name: product.name,\n listing: product.listing,\n price: product.price,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n\n // Обновляем объект корзины в localStorage, включая _id организации\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: organization // Сохраняем _id организации в корне объекта корзины\n }));\n },\n\n\n removeProduct(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n\n if (cartItemIndex > -1) {\n state.positions.splice(cartItemIndex, 1);\n \n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n decrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n \n if (cartItemIndex > -1) {\n cartItem.quantity--;\n \n if (cartItem.quantity < 1) {\n state.positions.splice(cartItemIndex, 1);\n }\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n incrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n updateRentDates({ productId, dates }) {\n const product = state.positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n\n resetShopcart() {\n state.positions = [];\n \n localStorage.removeItem('shopcart');\n },\n};\n\n/////////////////////////////\n// Getters\n/////////////////////////////\nconst getters = {\n cartTotalPrice: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n // Проверяем тип листинга\n if (product.listing === 'rent') {\n const start = new Date(product.date.start)\n const end = new Date(product.date.end)\n const diffTime = Math.abs(end - start)\n return total + product.price * (Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1);\n } else {\n // Для обычных товаров умножаем на количество\n return total + product.price * (product.quantity || 1);\n }\n }, 0));\n }),\n cartTotalAmount: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n return total + product.quantity;\n }, 0));\n }),\n getStoreCartState: computed(() => {\n return Number(state.currentState);\n }),\n};\n/////////////////////////////\n// History\n/////////////////////////////\nconst history = []\nhistory.push(state) \n\n/////////////////////////////\n// Watch\n/////////////////////////////\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\n/////////////////////////////\n// Module Export\n/////////////////////////////\nexport {\n state,\n actions,\n getters\n}"],"names":["reactive","computed","watch"],"mappings":";;;;;AAYK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,cAAc;AAAA,EACd,WAAW,CAAE;AAAA,EACb,cAAc;AAChB,CAAC;AAwGI,MAAC,UAAU;AAAA,EAEd,iBAAkB;AAChB,UAAM,eAAe,MAAM,eAAe,QAAQ;AAAA,EACnD;AAAA,EAED,cAAc;AACZ,QAAI;AACF,YAAM,iBAAiB,aAAa,QAAQ,UAAU;AAEtD,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K,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,MACtF,OAAa;AAEL,eAAO,QAAQ,QAAQ,SAAS,QAAQ,YAAY;AAAA,MAC5D;AAAA,IACK,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,iBAAiBA,IAAQ,SAAC,MAAM;AAC9B,WAAO,OAAO,MAAM,UAAU,OAAO,CAAC,OAAO,YAAY;AACvD,aAAO,QAAQ,QAAQ;AAAA,IACxB,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,mBAAmBA,IAAQ,SAAC,MAAM;AAChC,WAAO,OAAO,MAAM,YAAY;AAAA,EACpC,CAAG;AACH;AAUAC,IAAAA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;;;;"}
@@ -24,6 +24,7 @@ const actions = {
24
24
  }
25
25
  },
26
26
  addProductToCart(product, organization, date) {
27
+ console.log("organization shopcart is", organization);
27
28
  const cartItem = state.positions.find(
28
29
  (item) => item._id === product._id
29
30
  );
@@ -1 +1 @@
1
- {"version":3,"file":"shopcart.js","sources":["../../../../../../src/modules/orders/store/shopcart.js"],"sourcesContent":["/////////////////////////////\n// DEPENDENCIES\n/////////////////////////////\nimport { reactive, watch, computed } from \"vue\";\n// Dependencies\nimport Cookies from 'js-cookie'\n// Globals \nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n\n/////////////////////////////\n// State\n/////////////////////////////\nconst state = reactive({\n organization: null,\n positions: [],\n currentState: false\n});\n\n/////////////////////////////\n// Helpers\n/////////////////////////////\nconst helpers = {\n createCartItem(product, organization, type = 'sale') {\n return {\n _id: product._id,\n images: product.images,\n name: product.name,\n price: product.price,\n listing: product.listing,\n quantity: 1,\n org_id: organization,\n type: type\n };\n },\n\n saveToStorage() {\n localStorage.setItem(CART_STORAGE_KEY, JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n async validateProduct(product) {\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct) {\n return false;\n }\n\n return serverProduct.price === product.price &&\n serverProduct.name === product.name &&\n serverProduct.available !== false;\n }\n};\n\n/////////////////////////////\n// SYNC PRODUCT IN SHOPCART\n/////////////////////////////\n// Constants\nconst CART_STORAGE_KEY = 'shopcart';\nconst SYNC_INTERVAL = 30000; // 30 seconds in milliseconds\n\n// API service\nconst api = {\n async fetchProduct(productId) {\n try {\n const response = await fetch(`/api/products/read`, { _id: productId});\n return await response.json();\n } catch (error) {\n console.error('Failed to fetch product:', error);\n return null;\n }\n }\n};\n\nasync function syncWithServer() {\n try {\n const invalidProducts = [];\n \n for (let i = 0; i < state.positions.length; i++) {\n const product = state.positions[i];\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct || \n serverProduct.price !== product.price || \n serverProduct.name !== product.name || \n serverProduct.available === false) {\n invalidProducts.push(product._id);\n }\n }\n\n if (invalidProducts.length > 0) {\n state.positions = state.positions.filter(\n product => !invalidProducts.includes(product._id)\n );\n helpers.saveToStorage();\n setError('Some products were removed from cart due to changes on server');\n }\n } catch (error) {\n console.error('Failed to sync with server:', error);\n }\n}\n// Initialize periodic sync\nlet syncInterval;\n\nconst startPeriodicSync = () => {\n syncInterval = setInterval(syncWithServer, SYNC_INTERVAL);\n};\n\nconst stopPeriodicSync = () => {\n if (syncInterval) {\n clearInterval(syncInterval);\n }\n};\n\n// Start sync when module is imported\n// startPeriodicSync();\n/////////////////////////////\n// Actions\n/////////////////////////////\nconst actions = {\n\n toggleShopcart () {\n state.currentState = state.currentState ? false : true;\n },\n\n setShopcart() {\n try {\n const storedShopcart = localStorage.getItem('shopcart');\n\n if (storedShopcart) {\n const shopcartData = JSON.parse(storedShopcart);\n state.positions = shopcartData.positions; // Восстанавливаем продукты\n state.organization = shopcartData.organization; // Восстанавливаем _id организации\n } \n } catch (error) {\n console.error(error);\n throw error;\n }\n },\n\n\n addProductToCart(product, organization, date) {\n const cartItem = state.positions.find(\n (item) => item._id === product._id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n } else {\n state.positions.push({\n _id: product._id,\n images: product.images,\n name: product.name,\n listing: product.listing,\n price: product.price,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n\n // Обновляем объект корзины в localStorage, включая _id организации\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: organization // Сохраняем _id организации в корне объекта корзины\n }));\n },\n\n\n removeProduct(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n\n if (cartItemIndex > -1) {\n state.positions.splice(cartItemIndex, 1);\n \n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n decrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n \n if (cartItemIndex > -1) {\n cartItem.quantity--;\n \n if (cartItem.quantity < 1) {\n state.positions.splice(cartItemIndex, 1);\n }\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n incrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n updateRentDates({ productId, dates }) {\n const product = state.positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n\n resetShopcart() {\n state.positions = [];\n \n localStorage.removeItem('shopcart');\n },\n};\n\n/////////////////////////////\n// Getters\n/////////////////////////////\nconst getters = {\n cartTotalPrice: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n // Проверяем тип листинга\n if (product.listing === 'rent') {\n const start = new Date(product.date.start)\n const end = new Date(product.date.end)\n const diffTime = Math.abs(end - start)\n return total + product.price * (Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1);\n } else {\n // Для обычных товаров умножаем на количество\n return total + product.price * (product.quantity || 1);\n }\n }, 0));\n }),\n cartTotalAmount: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n return total + product.quantity;\n }, 0));\n }),\n getStoreCartState: computed(() => {\n return Number(state.currentState);\n }),\n};\n/////////////////////////////\n// History\n/////////////////////////////\nconst history = []\nhistory.push(state) \n\n/////////////////////////////\n// Watch\n/////////////////////////////\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\n/////////////////////////////\n// Module Export\n/////////////////////////////\nexport {\n state,\n actions,\n getters\n}"],"names":[],"mappings":";;;AAYK,MAAC,QAAQ,SAAS;AAAA,EACrB,cAAc;AAAA,EACd,WAAW,CAAE;AAAA,EACb,cAAc;AAChB,CAAC;AAwGI,MAAC,UAAU;AAAA,EAEd,iBAAkB;AAChB,UAAM,eAAe,MAAM,eAAe,QAAQ;AAAA,EACnD;AAAA,EAED,cAAc;AACZ,QAAI;AACF,YAAM,iBAAiB,aAAa,QAAQ,UAAU;AAEtD,UAAI,gBAAgB;AAClB,cAAM,eAAe,KAAK,MAAM,cAAc;AAC9C,cAAM,YAAY,aAAa;AAC/B,cAAM,eAAe,aAAa;AAAA,MACnC;AAAA,IACF,SAAQ,OAAO;AACd,cAAQ,MAAM,KAAK;AACnB,YAAM;AAAA,IACZ;AAAA,EACG;AAAA,EAGD,iBAAiB,SAAS,cAAc,MAAM;AAC5C,UAAM,WAAW,MAAM,UAAU;AAAA,MAC/B,CAAC,SAAS,KAAK,QAAQ,QAAQ;AAAA,IAChC;AAED,QAAI,UAAU;AACZ,eAAS;AAAA,IACf,OAAW;AACL,YAAM,UAAU,KAAK;AAAA,QACnB,KAAK,QAAQ;AAAA,QACb,QAAQ,QAAQ;AAAA,QACh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src/modules/orders/store/shopcart.js"],"sourcesContent":["/////////////////////////////\n// DEPENDENCIES\n/////////////////////////////\nimport { reactive, watch, computed } from \"vue\";\n// Dependencies\nimport Cookies from 'js-cookie'\n// Globals \nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n\n/////////////////////////////\n// State\n/////////////////////////////\nconst state = reactive({\n organization: null,\n positions: [],\n currentState: false\n});\n\n/////////////////////////////\n// Helpers\n/////////////////////////////\nconst helpers = {\n createCartItem(product, organization, type = 'sale') {\n return {\n _id: product._id,\n images: product.images,\n name: product.name,\n price: product.price,\n listing: product.listing,\n quantity: 1,\n org_id: organization,\n type: type\n };\n },\n\n saveToStorage() {\n localStorage.setItem(CART_STORAGE_KEY, JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n async validateProduct(product) {\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct) {\n return false;\n }\n\n return serverProduct.price === product.price &&\n serverProduct.name === product.name &&\n serverProduct.available !== false;\n }\n};\n\n/////////////////////////////\n// SYNC PRODUCT IN SHOPCART\n/////////////////////////////\n// Constants\nconst CART_STORAGE_KEY = 'shopcart';\nconst SYNC_INTERVAL = 30000; // 30 seconds in milliseconds\n\n// API service\nconst api = {\n async fetchProduct(productId) {\n try {\n const response = await fetch(`/api/products/read`, { _id: productId});\n return await response.json();\n } catch (error) {\n console.error('Failed to fetch product:', error);\n return null;\n }\n }\n};\n\nasync function syncWithServer() {\n try {\n const invalidProducts = [];\n \n for (let i = 0; i < state.positions.length; i++) {\n const product = state.positions[i];\n const serverProduct = await api.fetchProduct(product._id);\n \n if (!serverProduct || \n serverProduct.price !== product.price || \n serverProduct.name !== product.name || \n serverProduct.available === false) {\n invalidProducts.push(product._id);\n }\n }\n\n if (invalidProducts.length > 0) {\n state.positions = state.positions.filter(\n product => !invalidProducts.includes(product._id)\n );\n helpers.saveToStorage();\n setError('Some products were removed from cart due to changes on server');\n }\n } catch (error) {\n console.error('Failed to sync with server:', error);\n }\n}\n// Initialize periodic sync\nlet syncInterval;\n\nconst startPeriodicSync = () => {\n syncInterval = setInterval(syncWithServer, SYNC_INTERVAL);\n};\n\nconst stopPeriodicSync = () => {\n if (syncInterval) {\n clearInterval(syncInterval);\n }\n};\n\n// Start sync when module is imported\n// startPeriodicSync();\n/////////////////////////////\n// Actions\n/////////////////////////////\nconst actions = {\n\n toggleShopcart () {\n state.currentState = state.currentState ? false : true;\n },\n\n setShopcart() {\n try {\n const storedShopcart = localStorage.getItem('shopcart');\n\n if (storedShopcart) {\n const shopcartData = JSON.parse(storedShopcart);\n state.positions = shopcartData.positions; // Восстанавливаем продукты\n state.organization = shopcartData.organization; // Восстанавливаем _id организации\n } \n } catch (error) {\n console.error(error);\n throw error;\n }\n },\n\n\n addProductToCart(product, organization, date) {\n console.log('organization shopcart is', organization)\n const cartItem = state.positions.find(\n (item) => item._id === product._id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n } else {\n state.positions.push({\n _id: product._id,\n images: product.images,\n name: product.name,\n listing: product.listing,\n price: product.price,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n\n // Обновляем объект корзины в localStorage, включая _id организации\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: organization // Сохраняем _id организации в корне объекта корзины\n }));\n },\n\n\n removeProduct(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n\n if (cartItemIndex > -1) {\n state.positions.splice(cartItemIndex, 1);\n \n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n decrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n const cartItemIndex = state.positions.indexOf(cartItem);\n \n if (cartItemIndex > -1) {\n cartItem.quantity--;\n \n if (cartItem.quantity < 1) {\n state.positions.splice(cartItemIndex, 1);\n }\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n\n incrementItemQuantity(_id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n\n // Сохраняем весь объект корзины, а не только позиции\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n }\n },\n\n updateRentDates({ productId, dates }) {\n const product = state.positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n\n localStorage.setItem('shopcart', JSON.stringify({\n positions: state.positions,\n organization: state.organization\n }));\n },\n\n\n resetShopcart() {\n state.positions = [];\n \n localStorage.removeItem('shopcart');\n },\n};\n\n/////////////////////////////\n// Getters\n/////////////////////////////\nconst getters = {\n cartTotalPrice: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n // Проверяем тип листинга\n if (product.listing === 'rent') {\n const start = new Date(product.date.start)\n const end = new Date(product.date.end)\n const diffTime = Math.abs(end - start)\n return total + product.price * (Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1);\n } else {\n // Для обычных товаров умножаем на количество\n return total + product.price * (product.quantity || 1);\n }\n }, 0));\n }),\n cartTotalAmount: computed(() => {\n return Number(state.positions.reduce((total, product) => {\n return total + product.quantity;\n }, 0));\n }),\n getStoreCartState: computed(() => {\n return Number(state.currentState);\n }),\n};\n/////////////////////////////\n// History\n/////////////////////////////\nconst history = []\nhistory.push(state) \n\n/////////////////////////////\n// Watch\n/////////////////////////////\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\n/////////////////////////////\n// Module Export\n/////////////////////////////\nexport {\n state,\n actions,\n getters\n}"],"names":[],"mappings":";;;AAYK,MAAC,QAAQ,SAAS;AAAA,EACrB,cAAc;AAAA,EACd,WAAW,CAAE;AAAA,EACb,cAAc;AAChB,CAAC;AAwGI,MAAC,UAAU;AAAA,EAEd,iBAAkB;AAChB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,KAAK,QAAQ,KAAK,GAAG;AACrC,cAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,eAAO,QAAQ,QAAQ,SAAS,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,MACtF,OAAa;AAEL,eAAO,QAAQ,QAAQ,SAAS,QAAQ,YAAY;AAAA,MAC5D;AAAA,IACK,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,iBAAiB,SAAS,MAAM;AAC9B,WAAO,OAAO,MAAM,UAAU,OAAO,CAAC,OAAO,YAAY;AACvD,aAAO,QAAQ,QAAQ;AAAA,IACxB,GAAE,CAAC,CAAC;AAAA,EACT,CAAG;AAAA,EACD,mBAAmB,SAAS,MAAM;AAChC,WAAO,OAAO,MAAM,YAAY;AAAA,EACpC,CAAG;AACH;AAUA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;"}
@@ -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");
@@ -2,7 +2,7 @@ import { ref, onMounted, computed, resolveComponent, createElementBlock, openBlo
2
2
  import { useRoute, useRouter } from "vue-router";
3
3
  import _sfc_main$4 from "../../../../components/Feed/Feed.vue.js";
4
4
  /* empty css */
5
- /* empty css */
5
+ /* empty css */
6
6
  import _sfc_main$2 from "../../../../components/Popup/Popup.vue.js";
7
7
  import _sfc_main$1 from "../../../globals/views/components/sections/SectionPageTitle.vue.js";
8
8
  import _sfc_main$3 from "../sections/MembersAdd.vue.js";
@@ -6,7 +6,7 @@ const mixins = require("../../../../globals/views/mixins/mixins.cjs");
6
6
  const pages = require("../../store/pages.cjs");
7
7
  const Button = require("../../../../../components/Button/Button.vue.cjs");
8
8
  ;/* empty css */
9
- ;/* empty css */
9
+ ;/* empty css */
10
10
  const Constructor = require("../../../../constructor/components/sections/Constructor.vue.cjs");
11
11
  const _hoisted_1 = { key: 0 };
12
12
  const _hoisted_2 = {
@@ -4,7 +4,7 @@ import { useGlobalMixins } from "../../../../globals/views/mixins/mixins.js";
4
4
  import { actions, state } from "../../store/pages.js";
5
5
  import _sfc_main$2 from "../../../../../components/Button/Button.vue.js";
6
6
  /* empty css */
7
- /* empty css */
7
+ /* empty css */
8
8
  import _sfc_main$1 from "../../../../constructor/components/sections/Constructor.vue.js";
9
9
  const _hoisted_1 = { key: 0 };
10
10
  const _hoisted_2 = {
@@ -80,19 +80,20 @@ const _sfc_main = {
80
80
  });
81
81
  async function addToCart(product2, selectedDates = null) {
82
82
  try {
83
- if (shopcart.state.organization && shopcart.state.organization !== product2.owner.target) {
83
+ if (shopcart.state.organization && shopcart.state.organization !== product2.owner.target._id) {
84
84
  const result = await proxy.$alert({
85
85
  title: "Replace items in your cart?",
86
86
  message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,
87
87
  actions: [
88
88
  { label: "Cancel", value: false },
89
- { label: "Start New Order", value: true }
89
+ { label: "Replace", value: true }
90
90
  ]
91
91
  });
92
92
  if (!result) throw error;
93
- shopcart.state.organization = product2.owner.target._id;
94
- shopcart.state.positions = [];
95
93
  }
94
+ shopcart.state.organization = product2.owner.target._id;
95
+ shopcart.state.positions = [];
96
+ console.log("organization is", product2.owner.target._id);
96
97
  await shopcart.actions.addProductToCart(product2, product2.owner.target._id, selectedDates);
97
98
  return true;
98
99
  } catch (error2) {
@@ -1 +1 @@
1
- {"version":3,"file":"Product.vue.cjs","sources":["../../../../../../../src/modules/products/components/pages/Product.vue"],"sourcesContent":["<template>\n <div v-if=\"products.state.current\" class=\"h-100 w-100 mobile:pd-thin pd-big bg-white\">\n <div class=\"cols-2-1_2 w-100 gap-medium\">\n\n <ImagesThumbnails\n :images=\"images\"\n :product=\"product\"\n />\n\n <div class=\"pos-relative w-100 h-100 flex-column flex-h-center flex\">\n <IconEdit\n v-if=\"accesses && hasAccess(route.params._id, 'products', 'edit', accesses)\"\n @click=\"$router.push({ name: 'ProductEdit', params: { _id: product.owner.target, product: product._id } })\"\n class=\"pos-absolute pos-t-regular pos-r-regular i-regular t-transp\"\n />\n\n\n\n <h2 class=\"w-100 h1-product mn-b-small\">{{ product.name }}</h2>\n \n <Price :product=\"product\" size=\"big\" class=\"flex gap-micro flex-center pd-small br-solid br-1px br-black-transp-10 w-max mn-b-medium\" />\n\n <p v-if=\"product.description && !product.localization < 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ product.description }}\n </p>\n <p v-if=\"product.localization && product.localization.length > 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ t('description') }}\n </p>\n\n <div class=\"cols-2 mn-b-small w-100 gap-small\">\n <div\n v-if=\"product.information.length > 0\"\n v-for=\"information in product.information\"\n class=\"w-100 pd-small radius-small bg-light product-information\"\n >\n <p class=\"t-demi\">{{ information.name }}</p>\n <p>{{ information.value }}</p>\n </div>\n </div>\n\n <p class=\"t-medium mn-b-small\">Provided by</p>\n <CardOrganization \n v-if=\"product.owner\"\n :organization=\"product.owner.target\"\n :showRating=\"true\"\n :showFollowers=\"false\"\n :showProducts=\"false\"\n class=\"bg-light mn-b-thin w-100 o-hidden radius-medium pd-small \"\n />\n\n\n\n <div class=\"w-max-33r\">\n <div class=\"w-max-33r\">\n\t\t <div v-if=\"product.listing === 'rent'\">\n\t\t <button @click=\"openPopup\" class=\"cursor-pointer pd-small radius-big w-max mobile:w-100 bg-main button\">\n\t\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t\t <IconShopcartAdd class=\"i-semi\" />\n\t\t <span>{{ t('addtoorder') }}</span>\n\t\t </div>\n\t\t </button>\n\t\t <PopupDateSelector\n\t\t :product=\"product\"\n\t\t :isOpen=\"isPopupOpen\"\n\t\t :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0.15\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n\t\t :onConfirm=\"selectedDates => addToCart(product, selectedDates)\"\n\t\t @close=\"closePopup\"\n\t\t />\n\t\t </div>\n\t <div v-else>\n\t <Button\n\t v-if=\"product.available > 0\"\n\t :submit=\"() => addToCart(product, null)\"\n\t class=\"h-3r w-max mobile:w-100 bg-main button\"\n\t >\n\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t <IconShopcartAdd class=\"i-semi\" />\n\t <span>{{ t('addtoorder') }}</span>\n\t </div>\n\t </Button>\n\t <div\n\t v-else\n\t class=\"flex-center flex uppercase radius-big t-black w-max pd-small t-medium bg-grey h-3r w-100 mn-r-smallbutton\"\n\t >\n\t Out of Stock\n\t </div>\n\t </div>\n\t </div>\n </div>\n </div>\n </div>\n\n <div class=\"h-max mn-t-big pos-relative\">\n <h3 class=\"pd-b-small\">Most Popular</h3>\n <PopularProducts class=\"mn-r-big-negative mn-l-big-negative\"/>\n </div>\n </div>\n</template>\n\n<script setup>\nimport { computed, ref, onMounted, getCurrentInstance } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\n\n\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth'\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals'\nimport * as products from '@martyrs/src/modules/products/store/products'\nimport * as categories from '@martyrs/src/modules/products/store/categories'\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\nimport Button from '@martyrs/src/components/Button/Button.vue'\nimport Popup from '@martyrs/src/components/Popup/Popup.vue'\nimport Tab from '@martyrs/src/components/Tab/Tab.vue'\nimport Calendar from '@martyrs/src/components/DatePicker/Calendar.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconShopcartAdd from '@martyrs/src/modules/icons/actions/IconShopcartAdd.vue'\nimport ImagesThumbnails from '@martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue'\nimport Price from '@martyrs/src/modules/products/components/elements/Price.vue'\nimport PopularProducts from '@martyrs/src/modules/products/components/sections/PopularProducts.vue'\n\n import CardOrganization from '@martyrs/src/modules/organizations/components/blocks/CardOrganization.vue'\n\nconst route = useRoute()\nconst router = useRouter()\nconst { proxy } = getCurrentInstance()\n\nconst product = computed(() => products.state.current)\nconst images = computed(() => products.state.current.images)\n\nconst tabProduct = ref('description')\n\nconst text = {\n en: { addtoorder: 'Add to Cart', fastorder: 'Fast Order' },\n ru: { addtoorder: 'Добавить в корзину', fastorder: 'Быстрый заказ' }\n}\n\nconst { t } = useI18n({ messages: text })\n\nconst isPopupOpen = ref(false)\n\nfunction openPopup() {\n isPopupOpen.value = true\n}\n\nfunction closePopup() {\n isPopupOpen.value = false\n}\n\nconst emits = defineEmits(['page-loading', 'page-loaded']);\n \nconst pageProduct = ref(null)\nconst orderOrganization = ref(null)\n\nproducts.state.current = null\nonMounted(async () => {\n\n emits('page-loading');\n await products.actions.read({ _id: route.params.product })\n emits('page-loaded');\n\n // route.meta.title.en = product.value.name\n // route.meta.title.ru = roduct.value.name\n\n})\n\n// onBeforeMounted\n\nfunction validateToCard(product) {\n return !(product.available > 0)\n}\n\nasync function addToCart(product, selectedDates = null) {\n try {\n // Если организация товара отличается от текущей в корзине\n if (shopcart.state.organization && shopcart.state.organization !== product.owner.target) {\n const result = await proxy.$alert({\n title: 'Replace items in your cart?',\n message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,\n actions: [\n { label: 'Cancel', value: false },\n { label: 'Start New Order', value: true }\n ]\n })\n\n if (!result) throw error\n\n shopcart.state.organization = product.owner.target._id\n shopcart.state.positions = []\n }\n\n await shopcart.actions.addProductToCart(product, product.owner.target._id, selectedDates)\n return true\n } catch (error) {\n console.error('Error while adding product to cart:', error)\n throw error\n }\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["useRoute","useRouter","getCurrentInstance","computed","products.state","ref","useI18n","onMounted","products.actions","product","shopcart.state","shopcart.actions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,UAAM,QAAQA,UAAQ,SAAA;AACPC,cAAS,UAAA;AACxB,UAAM,EAAE,MAAO,IAAGC,IAAkB,mBAAA;AAEpC,UAAM,UAAUC,IAAAA,SAAS,MAAMC,SAAAA,MAAe,OAAO;AACrD,UAAM,SAASD,IAAQ,SAAC,MAAMC,SAAc,MAAC,QAAQ,MAAM;AAExCC,QAAAA,IAAI,aAAa;AAEpC,UAAM,OAAO;AAAA,MACX,IAAI,EAAE,YAAY,eAAe,WAAW,aAAc;AAAA,MAC1D,IAAI,EAAE,YAAY,sBAAsB,WAAW,gBAAe;AAAA,IACpE;AAEA,UAAM,EAAE,EAAC,IAAKC,QAAAA,QAAQ,EAAE,UAAU,KAAM,CAAA;AAExC,UAAM,cAAcD,IAAG,IAAC,KAAK;AAE7B,aAAS,YAAY;AACnB,kBAAY,QAAQ;AAAA,IACtB;AAEA,aAAS,aAAa;AACpB,kBAAY,QAAQ;AAAA,IACtB;AAEA,UAAM,QAAQ;AAEMA,QAAAA,IAAI,IAAI;AACFA,QAAAA,IAAI,IAAI;AAElCD,aAAc,MAAC,UAAU;AACzBG,QAAAA,UAAU,YAAY;AAEpB,YAAM,cAAc;AACpB,YAAMC,SAAAA,QAAiB,KAAK,EAAE,KAAK,MAAM,OAAO,QAAS,CAAA;AACzD,YAAM,aAAa;AAAA,IAKrB,CAAC;AAQD,mBAAe,UAAUC,UAAS,gBAAgB,MAAM;AACtD,UAAI;AAEF,YAAIC,SAAAA,MAAe,gBAAgBA,SAAc,MAAC,iBAAiBD,SAAQ,MAAM,QAAQ;AACvF,gBAAM,SAAS,MAAM,MAAM,OAAO;AAAA,YAChC,OAAO;AAAA,YACP,SAAS;AAAA,YACT,SAAS;AAAA,cACP,EAAE,OAAO,UAAU,OAAO,MAAO;AAAA,cACjC,EAAE,OAAO,mBAAmB,OAAO,KAAI;AAAA,YACjD;AAAA,UACO,CAAA;AAED,cAAI,CAAC,OAAQ,OAAM;AAEnBC,mBAAAA,MAAe,eAAeD,SAAQ,MAAM,OAAO;AACnDC,mBAAAA,MAAe,YAAY,CAAA;AAAA,QACjC;AAEI,cAAMC,SAAAA,QAAiB,iBAAiBF,UAASA,SAAQ,MAAM,OAAO,KAAK,aAAa;AACxF,eAAO;AAAA,MACR,SAAQG,QAAO;AACd,gBAAQ,MAAM,uCAAuCA,MAAK;AAC1D,cAAMA;AAAA,MACV;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Product.vue.cjs","sources":["../../../../../../../src/modules/products/components/pages/Product.vue"],"sourcesContent":["<template>\n <div v-if=\"products.state.current\" class=\"h-100 w-100 mobile:pd-thin pd-big bg-white\">\n <div class=\"cols-2-1_2 w-100 gap-medium\">\n\n <ImagesThumbnails\n :images=\"images\"\n :product=\"product\"\n />\n\n <div class=\"pos-relative w-100 h-100 flex-column flex-h-center flex\">\n <IconEdit\n v-if=\"accesses && hasAccess(route.params._id, 'products', 'edit', accesses)\"\n @click=\"$router.push({ name: 'ProductEdit', params: { _id: product.owner.target, product: product._id } })\"\n class=\"pos-absolute pos-t-regular pos-r-regular i-regular t-transp\"\n />\n\n\n\n <h2 class=\"w-100 h1-product mn-b-small\">{{ product.name }}</h2>\n \n <Price :product=\"product\" size=\"big\" class=\"flex gap-micro flex-center pd-small br-solid br-1px br-black-transp-10 w-max mn-b-medium\" />\n\n <p v-if=\"product.description && !product.localization < 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ product.description }}\n </p>\n <p v-if=\"product.localization && product.localization.length > 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ t('description') }}\n </p>\n\n <div class=\"cols-2 mn-b-small w-100 gap-small\">\n <div\n v-if=\"product.information.length > 0\"\n v-for=\"information in product.information\"\n class=\"w-100 pd-small radius-small bg-light product-information\"\n >\n <p class=\"t-demi\">{{ information.name }}</p>\n <p>{{ information.value }}</p>\n </div>\n </div>\n\n <p class=\"t-medium mn-b-small\">Provided by</p>\n <CardOrganization \n v-if=\"product.owner\"\n :organization=\"product.owner.target\"\n :showRating=\"true\"\n :showFollowers=\"false\"\n :showProducts=\"false\"\n class=\"bg-light mn-b-thin w-100 o-hidden radius-medium pd-small \"\n />\n\n\n\n <div class=\"w-max-33r\">\n <div class=\"w-max-33r\">\n\t\t <div v-if=\"product.listing === 'rent'\">\n\t\t <button @click=\"openPopup\" class=\"cursor-pointer pd-small radius-big w-max mobile:w-100 bg-main button\">\n\t\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t\t <IconShopcartAdd class=\"i-semi\" />\n\t\t <span>{{ t('addtoorder') }}</span>\n\t\t </div>\n\t\t </button>\n\t\t <PopupDateSelector\n\t\t :product=\"product\"\n\t\t :isOpen=\"isPopupOpen\"\n\t\t :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0.15\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n\t\t :onConfirm=\"selectedDates => addToCart(product, selectedDates)\"\n\t\t @close=\"closePopup\"\n\t\t />\n\t\t </div>\n\t <div v-else>\n\t <Button\n\t v-if=\"product.available > 0\"\n\t :submit=\"() => addToCart(product, null)\"\n\t class=\"h-3r w-max mobile:w-100 bg-main button\"\n\t >\n\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t <IconShopcartAdd class=\"i-semi\" />\n\t <span>{{ t('addtoorder') }}</span>\n\t </div>\n\t </Button>\n\t <div\n\t v-else\n\t class=\"flex-center flex uppercase radius-big t-black w-max pd-small t-medium bg-grey h-3r w-100 mn-r-smallbutton\"\n\t >\n\t Out of Stock\n\t </div>\n\t </div>\n\t </div>\n </div>\n </div>\n </div>\n\n <div class=\"h-max mn-t-big pos-relative\">\n <h3 class=\"pd-b-small\">Most Popular</h3>\n <PopularProducts class=\"mn-r-big-negative mn-l-big-negative\"/>\n </div>\n </div>\n</template>\n\n<script setup>\nimport { computed, ref, onMounted, getCurrentInstance } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\n\n\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth'\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals'\nimport * as products from '@martyrs/src/modules/products/store/products'\nimport * as categories from '@martyrs/src/modules/products/store/categories'\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\nimport Button from '@martyrs/src/components/Button/Button.vue'\nimport Popup from '@martyrs/src/components/Popup/Popup.vue'\nimport Tab from '@martyrs/src/components/Tab/Tab.vue'\nimport Calendar from '@martyrs/src/components/DatePicker/Calendar.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconShopcartAdd from '@martyrs/src/modules/icons/actions/IconShopcartAdd.vue'\nimport ImagesThumbnails from '@martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue'\nimport Price from '@martyrs/src/modules/products/components/elements/Price.vue'\nimport PopularProducts from '@martyrs/src/modules/products/components/sections/PopularProducts.vue'\n\n import CardOrganization from '@martyrs/src/modules/organizations/components/blocks/CardOrganization.vue'\n\nconst route = useRoute()\nconst router = useRouter()\nconst { proxy } = getCurrentInstance()\n\nconst product = computed(() => products.state.current)\nconst images = computed(() => products.state.current.images)\n\nconst tabProduct = ref('description')\n\nconst text = {\n en: { addtoorder: 'Add to Cart', fastorder: 'Fast Order' },\n ru: { addtoorder: 'Добавить в корзину', fastorder: 'Быстрый заказ' }\n}\n\nconst { t } = useI18n({ messages: text })\n\nconst isPopupOpen = ref(false)\n\nfunction openPopup() {\n isPopupOpen.value = true\n}\n\nfunction closePopup() {\n isPopupOpen.value = false\n}\n\nconst emits = defineEmits(['page-loading', 'page-loaded']);\n \nconst pageProduct = ref(null)\nconst orderOrganization = ref(null)\n\nproducts.state.current = null\nonMounted(async () => {\n\n emits('page-loading');\n await products.actions.read({ _id: route.params.product })\n emits('page-loaded');\n\n // route.meta.title.en = product.value.name\n // route.meta.title.ru = roduct.value.name\n\n})\n\n// onBeforeMounted\n\nfunction validateToCard(product) {\n return !(product.available > 0)\n}\n\nasync function addToCart(product, selectedDates = null) {\n try {\n // Если организация товара отличается от текущей в корзине\n if (shopcart.state.organization && shopcart.state.organization !== product.owner.target._id) {\n const result = await proxy.$alert({\n title: 'Replace items in your cart?',\n message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,\n actions: [\n { label: 'Cancel', value: false },\n { label: 'Replace', value: true }\n ]\n })\n\n if (!result) throw error\n }\n\n shopcart.state.organization = product.owner.target._id\n shopcart.state.positions = []\n\n console.log('organization is', product.owner.target._id)\n await shopcart.actions.addProductToCart(product, product.owner.target._id, selectedDates)\n return true\n } catch (error) {\n console.error('Error while adding product to cart:', error)\n throw error\n }\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["useRoute","useRouter","getCurrentInstance","computed","products.state","ref","useI18n","onMounted","products.actions","product","shopcart.state","shopcart.actions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,UAAM,QAAQA,UAAQ,SAAA;AACPC,cAAS,UAAA;AACxB,UAAM,EAAE,MAAO,IAAGC,IAAkB,mBAAA;AAEpC,UAAM,UAAUC,IAAAA,SAAS,MAAMC,SAAAA,MAAe,OAAO;AACrD,UAAM,SAASD,IAAQ,SAAC,MAAMC,SAAc,MAAC,QAAQ,MAAM;AAExCC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ACd,gBAAQ,MAAM,uCAAuCA,MAAK;AAC1D,cAAMA;AAAA,MACV;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -78,19 +78,20 @@ const _sfc_main = {
78
78
  });
79
79
  async function addToCart(product2, selectedDates = null) {
80
80
  try {
81
- if (state$2.organization && state$2.organization !== product2.owner.target) {
81
+ if (state$2.organization && state$2.organization !== product2.owner.target._id) {
82
82
  const result = await proxy.$alert({
83
83
  title: "Replace items in your cart?",
84
84
  message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,
85
85
  actions: [
86
86
  { label: "Cancel", value: false },
87
- { label: "Start New Order", value: true }
87
+ { label: "Replace", value: true }
88
88
  ]
89
89
  });
90
90
  if (!result) throw error;
91
- state$2.organization = product2.owner.target._id;
92
- state$2.positions = [];
93
91
  }
92
+ state$2.organization = product2.owner.target._id;
93
+ state$2.positions = [];
94
+ console.log("organization is", product2.owner.target._id);
94
95
  await actions$1.addProductToCart(product2, product2.owner.target._id, selectedDates);
95
96
  return true;
96
97
  } catch (error2) {
@@ -1 +1 @@
1
- {"version":3,"file":"Product.vue.js","sources":["../../../../../../../src/modules/products/components/pages/Product.vue"],"sourcesContent":["<template>\n <div v-if=\"products.state.current\" class=\"h-100 w-100 mobile:pd-thin pd-big bg-white\">\n <div class=\"cols-2-1_2 w-100 gap-medium\">\n\n <ImagesThumbnails\n :images=\"images\"\n :product=\"product\"\n />\n\n <div class=\"pos-relative w-100 h-100 flex-column flex-h-center flex\">\n <IconEdit\n v-if=\"accesses && hasAccess(route.params._id, 'products', 'edit', accesses)\"\n @click=\"$router.push({ name: 'ProductEdit', params: { _id: product.owner.target, product: product._id } })\"\n class=\"pos-absolute pos-t-regular pos-r-regular i-regular t-transp\"\n />\n\n\n\n <h2 class=\"w-100 h1-product mn-b-small\">{{ product.name }}</h2>\n \n <Price :product=\"product\" size=\"big\" class=\"flex gap-micro flex-center pd-small br-solid br-1px br-black-transp-10 w-max mn-b-medium\" />\n\n <p v-if=\"product.description && !product.localization < 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ product.description }}\n </p>\n <p v-if=\"product.localization && product.localization.length > 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ t('description') }}\n </p>\n\n <div class=\"cols-2 mn-b-small w-100 gap-small\">\n <div\n v-if=\"product.information.length > 0\"\n v-for=\"information in product.information\"\n class=\"w-100 pd-small radius-small bg-light product-information\"\n >\n <p class=\"t-demi\">{{ information.name }}</p>\n <p>{{ information.value }}</p>\n </div>\n </div>\n\n <p class=\"t-medium mn-b-small\">Provided by</p>\n <CardOrganization \n v-if=\"product.owner\"\n :organization=\"product.owner.target\"\n :showRating=\"true\"\n :showFollowers=\"false\"\n :showProducts=\"false\"\n class=\"bg-light mn-b-thin w-100 o-hidden radius-medium pd-small \"\n />\n\n\n\n <div class=\"w-max-33r\">\n <div class=\"w-max-33r\">\n\t\t <div v-if=\"product.listing === 'rent'\">\n\t\t <button @click=\"openPopup\" class=\"cursor-pointer pd-small radius-big w-max mobile:w-100 bg-main button\">\n\t\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t\t <IconShopcartAdd class=\"i-semi\" />\n\t\t <span>{{ t('addtoorder') }}</span>\n\t\t </div>\n\t\t </button>\n\t\t <PopupDateSelector\n\t\t :product=\"product\"\n\t\t :isOpen=\"isPopupOpen\"\n\t\t :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0.15\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n\t\t :onConfirm=\"selectedDates => addToCart(product, selectedDates)\"\n\t\t @close=\"closePopup\"\n\t\t />\n\t\t </div>\n\t <div v-else>\n\t <Button\n\t v-if=\"product.available > 0\"\n\t :submit=\"() => addToCart(product, null)\"\n\t class=\"h-3r w-max mobile:w-100 bg-main button\"\n\t >\n\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t <IconShopcartAdd class=\"i-semi\" />\n\t <span>{{ t('addtoorder') }}</span>\n\t </div>\n\t </Button>\n\t <div\n\t v-else\n\t class=\"flex-center flex uppercase radius-big t-black w-max pd-small t-medium bg-grey h-3r w-100 mn-r-smallbutton\"\n\t >\n\t Out of Stock\n\t </div>\n\t </div>\n\t </div>\n </div>\n </div>\n </div>\n\n <div class=\"h-max mn-t-big pos-relative\">\n <h3 class=\"pd-b-small\">Most Popular</h3>\n <PopularProducts class=\"mn-r-big-negative mn-l-big-negative\"/>\n </div>\n </div>\n</template>\n\n<script setup>\nimport { computed, ref, onMounted, getCurrentInstance } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\n\n\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth'\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals'\nimport * as products from '@martyrs/src/modules/products/store/products'\nimport * as categories from '@martyrs/src/modules/products/store/categories'\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\nimport Button from '@martyrs/src/components/Button/Button.vue'\nimport Popup from '@martyrs/src/components/Popup/Popup.vue'\nimport Tab from '@martyrs/src/components/Tab/Tab.vue'\nimport Calendar from '@martyrs/src/components/DatePicker/Calendar.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconShopcartAdd from '@martyrs/src/modules/icons/actions/IconShopcartAdd.vue'\nimport ImagesThumbnails from '@martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue'\nimport Price from '@martyrs/src/modules/products/components/elements/Price.vue'\nimport PopularProducts from '@martyrs/src/modules/products/components/sections/PopularProducts.vue'\n\n import CardOrganization from '@martyrs/src/modules/organizations/components/blocks/CardOrganization.vue'\n\nconst route = useRoute()\nconst router = useRouter()\nconst { proxy } = getCurrentInstance()\n\nconst product = computed(() => products.state.current)\nconst images = computed(() => products.state.current.images)\n\nconst tabProduct = ref('description')\n\nconst text = {\n en: { addtoorder: 'Add to Cart', fastorder: 'Fast Order' },\n ru: { addtoorder: 'Добавить в корзину', fastorder: 'Быстрый заказ' }\n}\n\nconst { t } = useI18n({ messages: text })\n\nconst isPopupOpen = ref(false)\n\nfunction openPopup() {\n isPopupOpen.value = true\n}\n\nfunction closePopup() {\n isPopupOpen.value = false\n}\n\nconst emits = defineEmits(['page-loading', 'page-loaded']);\n \nconst pageProduct = ref(null)\nconst orderOrganization = ref(null)\n\nproducts.state.current = null\nonMounted(async () => {\n\n emits('page-loading');\n await products.actions.read({ _id: route.params.product })\n emits('page-loaded');\n\n // route.meta.title.en = product.value.name\n // route.meta.title.ru = roduct.value.name\n\n})\n\n// onBeforeMounted\n\nfunction validateToCard(product) {\n return !(product.available > 0)\n}\n\nasync function addToCart(product, selectedDates = null) {\n try {\n // Если организация товара отличается от текущей в корзине\n if (shopcart.state.organization && shopcart.state.organization !== product.owner.target) {\n const result = await proxy.$alert({\n title: 'Replace items in your cart?',\n message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,\n actions: [\n { label: 'Cancel', value: false },\n { label: 'Start New Order', value: true }\n ]\n })\n\n if (!result) throw error\n\n shopcart.state.organization = product.owner.target._id\n shopcart.state.positions = []\n }\n\n await shopcart.actions.addProductToCart(product, product.owner.target._id, selectedDates)\n return true\n } catch (error) {\n console.error('Error while adding product to cart:', error)\n throw error\n }\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["products.state","products.actions","product","shopcart.state","shopcart.actions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,UAAM,QAAQ,SAAQ;AACP,cAAS;AACxB,UAAM,EAAE,MAAO,IAAG,mBAAkB;AAEpC,UAAM,UAAU,SAAS,MAAMA,MAAe,OAAO;AACrD,UA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Product.vue.js","sources":["../../../../../../../src/modules/products/components/pages/Product.vue"],"sourcesContent":["<template>\n <div v-if=\"products.state.current\" class=\"h-100 w-100 mobile:pd-thin pd-big bg-white\">\n <div class=\"cols-2-1_2 w-100 gap-medium\">\n\n <ImagesThumbnails\n :images=\"images\"\n :product=\"product\"\n />\n\n <div class=\"pos-relative w-100 h-100 flex-column flex-h-center flex\">\n <IconEdit\n v-if=\"accesses && hasAccess(route.params._id, 'products', 'edit', accesses)\"\n @click=\"$router.push({ name: 'ProductEdit', params: { _id: product.owner.target, product: product._id } })\"\n class=\"pos-absolute pos-t-regular pos-r-regular i-regular t-transp\"\n />\n\n\n\n <h2 class=\"w-100 h1-product mn-b-small\">{{ product.name }}</h2>\n \n <Price :product=\"product\" size=\"big\" class=\"flex gap-micro flex-center pd-small br-solid br-1px br-black-transp-10 w-max mn-b-medium\" />\n\n <p v-if=\"product.description && !product.localization < 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ product.description }}\n </p>\n <p v-if=\"product.localization && product.localization.length > 1 && !recommendation\" class=\"w-100 t-transp mn-b-small\">\n {{ t('description') }}\n </p>\n\n <div class=\"cols-2 mn-b-small w-100 gap-small\">\n <div\n v-if=\"product.information.length > 0\"\n v-for=\"information in product.information\"\n class=\"w-100 pd-small radius-small bg-light product-information\"\n >\n <p class=\"t-demi\">{{ information.name }}</p>\n <p>{{ information.value }}</p>\n </div>\n </div>\n\n <p class=\"t-medium mn-b-small\">Provided by</p>\n <CardOrganization \n v-if=\"product.owner\"\n :organization=\"product.owner.target\"\n :showRating=\"true\"\n :showFollowers=\"false\"\n :showProducts=\"false\"\n class=\"bg-light mn-b-thin w-100 o-hidden radius-medium pd-small \"\n />\n\n\n\n <div class=\"w-max-33r\">\n <div class=\"w-max-33r\">\n\t\t <div v-if=\"product.listing === 'rent'\">\n\t\t <button @click=\"openPopup\" class=\"cursor-pointer pd-small radius-big w-max mobile:w-100 bg-main button\">\n\t\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t\t <IconShopcartAdd class=\"i-semi\" />\n\t\t <span>{{ t('addtoorder') }}</span>\n\t\t </div>\n\t\t </button>\n\t\t <PopupDateSelector\n\t\t :product=\"product\"\n\t\t :isOpen=\"isPopupOpen\"\n\t\t :showFees=\"globals.state.options?.orders.showFees\"\n :feesRate=\"globals.state.options?.orders.feesRate || 0.15\"\n :showVat=\"globals.state.options?.orders.showVat\"\n :vatRate=\"globals.state.options?.orders.vatRate || 0\"\n\t\t :onConfirm=\"selectedDates => addToCart(product, selectedDates)\"\n\t\t @close=\"closePopup\"\n\t\t />\n\t\t </div>\n\t <div v-else>\n\t <Button\n\t v-if=\"product.available > 0\"\n\t :submit=\"() => addToCart(product, null)\"\n\t class=\"h-3r w-max mobile:w-100 bg-main button\"\n\t >\n\t <div class=\"gap-thin flex flex-center flex-nowrap\">\n\t <IconShopcartAdd class=\"i-semi\" />\n\t <span>{{ t('addtoorder') }}</span>\n\t </div>\n\t </Button>\n\t <div\n\t v-else\n\t class=\"flex-center flex uppercase radius-big t-black w-max pd-small t-medium bg-grey h-3r w-100 mn-r-smallbutton\"\n\t >\n\t Out of Stock\n\t </div>\n\t </div>\n\t </div>\n </div>\n </div>\n </div>\n\n <div class=\"h-max mn-t-big pos-relative\">\n <h3 class=\"pd-b-small\">Most Popular</h3>\n <PopularProducts class=\"mn-r-big-negative mn-l-big-negative\"/>\n </div>\n </div>\n</template>\n\n<script setup>\nimport { computed, ref, onMounted, getCurrentInstance } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\n\n\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth'\nimport * as globals from '@martyrs/src/modules/globals/views/store/globals'\nimport * as products from '@martyrs/src/modules/products/store/products'\nimport * as categories from '@martyrs/src/modules/products/store/categories'\nimport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\nimport Button from '@martyrs/src/components/Button/Button.vue'\nimport Popup from '@martyrs/src/components/Popup/Popup.vue'\nimport Tab from '@martyrs/src/components/Tab/Tab.vue'\nimport Calendar from '@martyrs/src/components/DatePicker/Calendar.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconShopcartAdd from '@martyrs/src/modules/icons/actions/IconShopcartAdd.vue'\nimport ImagesThumbnails from '@martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue'\nimport Price from '@martyrs/src/modules/products/components/elements/Price.vue'\nimport PopularProducts from '@martyrs/src/modules/products/components/sections/PopularProducts.vue'\n\n import CardOrganization from '@martyrs/src/modules/organizations/components/blocks/CardOrganization.vue'\n\nconst route = useRoute()\nconst router = useRouter()\nconst { proxy } = getCurrentInstance()\n\nconst product = computed(() => products.state.current)\nconst images = computed(() => products.state.current.images)\n\nconst tabProduct = ref('description')\n\nconst text = {\n en: { addtoorder: 'Add to Cart', fastorder: 'Fast Order' },\n ru: { addtoorder: 'Добавить в корзину', fastorder: 'Быстрый заказ' }\n}\n\nconst { t } = useI18n({ messages: text })\n\nconst isPopupOpen = ref(false)\n\nfunction openPopup() {\n isPopupOpen.value = true\n}\n\nfunction closePopup() {\n isPopupOpen.value = false\n}\n\nconst emits = defineEmits(['page-loading', 'page-loaded']);\n \nconst pageProduct = ref(null)\nconst orderOrganization = ref(null)\n\nproducts.state.current = null\nonMounted(async () => {\n\n emits('page-loading');\n await products.actions.read({ _id: route.params.product })\n emits('page-loaded');\n\n // route.meta.title.en = product.value.name\n // route.meta.title.ru = roduct.value.name\n\n})\n\n// onBeforeMounted\n\nfunction validateToCard(product) {\n return !(product.available > 0)\n}\n\nasync function addToCart(product, selectedDates = null) {\n try {\n // Если организация товара отличается от текущей в корзине\n if (shopcart.state.organization && shopcart.state.organization !== product.owner.target._id) {\n const result = await proxy.$alert({\n title: 'Replace items in your cart?',\n message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,\n actions: [\n { label: 'Cancel', value: false },\n { label: 'Replace', value: true }\n ]\n })\n\n if (!result) throw error\n }\n\n shopcart.state.organization = product.owner.target._id\n shopcart.state.positions = []\n\n console.log('organization is', product.owner.target._id)\n await shopcart.actions.addProductToCart(product, product.owner.target._id, selectedDates)\n return true\n } catch (error) {\n console.error('Error while adding product to cart:', error)\n throw error\n }\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["products.state","products.actions","product","shopcart.state","shopcart.actions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,UAAM,QAAQ,SAAQ;AACP,cAAS;AACxB,UAAM,EAAE,MAAO,IAAG,mBAAkB;AAEpC,UAAM,UAAU,SAAS,MAAMA,MAAe,OAAO;AACrD,UAAM,SAAS,SAAS,MAAMA,MAAe,QAAQ,MAAM;AAExC,QAAI,aAAa;AAEpC,UAAM,OAAO;AAAA,MACX,IAAI,EAAE,YAAY,eAAe,WAAW,aAAc;AAAA,MAC1D,IAAI,EAAE,YAAY,sBAAsB,WAAW,gBAAe;AAAA,IACpE;AAEA,UAAM,EAAE,EAAC,IAAK,QAAQ,EAAE,UAAU,KAAM,CAAA;AAExC,UAAM,cAAc,IAAI,KAAK;AAE7B,aAAS,YAAY;AACnB,kBAAY,QAAQ;AAAA,IACtB;AAEA,aAAS,aAAa;AACpB,kBAAY,QAAQ;AAAA,IACtB;AAEA,UAAM,QAAQ;AAEM,QAAI,IAAI;AACF,QAAI,IAAI;AAElCA,UAAe,UAAU;AACzB,cAAU,YAAY;AAEpB,YAAM,cAAc;AACpB,YAAMC,QAAiB,KAAK,EAAE,KAAK,MAAM,OAAO,QAAS,CAAA;AACzD,YAAM,aAAa;AAAA,IAKrB,CAAC;AAQD,mBAAe,UAAUC,UAAS,gBAAgB,MAAM;AACtD,UAAI;AAEF,YAAIC,QAAe,gBAAgBA,QAAe,iBAAiBD,SAAQ,MAAM,OAAO,KAAK;AAC3F,gBAAM,SAAS,MAAM,MAAM,OAAO;AAAA,YAChC,OAAO;AAAA,YACP,SAAS;AAAA,YACT,SAAS;AAAA,cACP,EAAE,OAAO,UAAU,OAAO,MAAO;AAAA,cACjC,EAAE,OAAO,WAAW,OAAO,KAAI;AAAA,YACzC;AAAA,UACO,CAAA;AAED,cAAI,CAAC,OAAQ,OAAM;AAAA,QACzB;AAEIC,gBAAe,eAAeD,SAAQ,MAAM,OAAO;AACnDC,gBAAe,YAAY,CAAA;AAE3B,gBAAQ,IAAI,mBAAmBD,SAAQ,MAAM,OAAO,GAAG;AACvD,cAAME,UAAiB,iBAAiBF,UAASA,SAAQ,MAAM,OAAO,KAAK,aAAa;AACxF,eAAO;AAAA,MACR,SAAQG,QAAO;AACd,gBAAQ,MAAM,uCAAuCA,MAAK;AAC1D,cAAMA;AAAA,MACV;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/martyrs",
3
- "version": "0.2.463",
3
+ "version": "0.2.464",
4
4
  "description": "Fullstack framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -16,7 +16,6 @@
16
16
  v-if="order.status === true && shopcart.state.positions.length > 0"
17
17
  :order="order"
18
18
  />
19
- {{shopcart.state.organization}}
20
19
  <!-- Order Form -->
21
20
  <div
22
21
  v-if="orders.state.current.status !== true && shopcart.state.positions.length > 0"
@@ -141,6 +141,7 @@ const actions = {
141
141
 
142
142
 
143
143
  addProductToCart(product, organization, date) {
144
+ console.log('organization shopcart is', organization)
144
145
  const cartItem = state.positions.find(
145
146
  (item) => item._id === product._id
146
147
  );
@@ -177,22 +177,23 @@ function validateToCard(product) {
177
177
  async function addToCart(product, selectedDates = null) {
178
178
  try {
179
179
  // Если организация товара отличается от текущей в корзине
180
- if (shopcart.state.organization && shopcart.state.organization !== product.owner.target) {
180
+ if (shopcart.state.organization && shopcart.state.organization !== product.owner.target._id) {
181
181
  const result = await proxy.$alert({
182
182
  title: 'Replace items in your cart?',
183
183
  message: `Your cart has items from another vendor. If you continue, we'll clear it so you can order from this one instead.`,
184
184
  actions: [
185
185
  { label: 'Cancel', value: false },
186
- { label: 'Start New Order', value: true }
186
+ { label: 'Replace', value: true }
187
187
  ]
188
188
  })
189
189
 
190
190
  if (!result) throw error
191
-
192
- shopcart.state.organization = product.owner.target._id
193
- shopcart.state.positions = []
194
191
  }
195
192
 
193
+ shopcart.state.organization = product.owner.target._id
194
+ shopcart.state.positions = []
195
+
196
+ console.log('organization is', product.owner.target._id)
196
197
  await shopcart.actions.addProductToCart(product, product.owner.target._id, selectedDates)
197
198
  return true
198
199
  } catch (error) {
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.vue2.cjs","sources":["../../../../../src/components/Tooltip/Tooltip.vue"],"sourcesContent":["<template>\n <div class=\"cursor-pointer tooltip-container\" @mouseover=\"showTooltip\" @mouseleave=\"hideTooltip\">\n <slot></slot>\n <div class=\"tooltip-content\" :style=\"tooltipStyle\">\n {{ text }}\n </div>\n </div>\n</template>\n\n<script setup>\nimport { ref, reactive } from 'vue';\n\nconst props = defineProps({\n text: {\n type: String,\n required: true\n }\n});\n\nconst visible = ref(false);\n\nconst tooltipStyle = reactive({\n position: 'absolute',\n width: 'max-content',\n zIndex: 1000,\n background: '#333',\n color: '#fff',\n padding: '5px 10px',\n borderRadius: '3px',\n fontSize: '14px',\n display: 'none',\n});\n\nfunction showTooltip(event) {\n visible.value = true;\n tooltipStyle.left = `${(event.clientX / 100) + 10 }px`;\n tooltipStyle.top = `${(event.clientY / 100) + 10 }px`;\n tooltipStyle.display = 'block';\n}\n\nfunction hideTooltip() {\n visible.value = false;\n tooltipStyle.display = 'none';\n}\n</script>\n\n<style >\n.tooltip-container {\n position: relative;\n display: inline-block;\n}\n\n.tooltip-content {\n pointer-events: none;\n}\n</style>"],"names":["ref","reactive"],"mappings":";;;;;;;;;;;;;AAmBA,UAAM,UAAUA,IAAG,IAAC,KAAK;AAEzB,UAAM,eAAeC,IAAAA,SAAS;AAAA,MAC5B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,cAAc;AAAA,MACd,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAED,aAAS,YAAY,OAAO;AAC1B,cAAQ,QAAQ;AAChB,mBAAa,OAAO,GAAI,MAAM,UAAU,MAAO,EAAE;AACjD,mBAAa,MAAM,GAAI,MAAM,UAAU,MAAO,EAAE;AAChD,mBAAa,UAAU;AAAA,IACzB;AAEA,aAAS,cAAc;AACrB,cAAQ,QAAQ;AAChB,mBAAa,UAAU;AAAA,IACzB;;;;;;;;;;;;;;;;;"}