@ozdao/martyrs 0.2.446 → 0.2.447

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/CardOrderItem.vue.cjs +2 -2
  10. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.cjs.map +1 -1
  11. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js +2 -2
  12. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js.map +1 -1
  13. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs +1 -1
  14. package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js +1 -1
  15. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  16. package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  17. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +19 -4
  18. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
  19. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +20 -5
  20. package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
  21. package/dist/martyrs/src/modules/orders/store/orders.cjs +1 -1
  22. package/dist/martyrs/src/modules/orders/store/orders.cjs.map +1 -1
  23. package/dist/martyrs/src/modules/orders/store/orders.js +1 -1
  24. package/dist/martyrs/src/modules/orders/store/orders.js.map +1 -1
  25. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  26. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
  27. package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
  28. package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
  29. package/package.json +1 -1
  30. package/src/modules/orders/components/blocks/CardOrderItem.vue +2 -2
  31. package/src/modules/orders/components/pages/OrderCreate.vue +27 -6
  32. package/src/modules/orders/store/orders.js +1 -1
  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.vue.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.vue.js";
5
5
  import PlaceholderUserpic from "../../../../icons/placeholders/PlaceholderUserpic.vue.js";
6
6
  import PlaceholderOrganizationPic from "../../../../icons/placeholders/PlaceholderOrganizationPic.vue.js";
@@ -105,10 +105,10 @@ const _sfc_main = {
105
105
  vue.createElementVNode("p", _hoisted_6, vue.toDisplayString(__props.product.name), 1),
106
106
  vue.createElementVNode("div", null, [
107
107
  vue.createElementVNode("p", null, [
108
- vue.createElementVNode("span", _hoisted_7, vue.toDisplayString(__props.product.price_currency || _ctx.returnCurrency()) + vue.toDisplayString((__props.product.listing === "rent" ? rentalDays.value || __props.product.quantity || 0 : __props.product.quantity || 0) * __props.product.price), 1),
108
+ vue.createElementVNode("span", _hoisted_7, vue.toDisplayString(_ctx.returnCurrency()) + vue.toDisplayString((__props.product.listing === "rent" ? rentalDays.value || __props.product.quantity || 0 : __props.product.quantity || 0) * __props.product.price), 1),
109
109
  vue.createElementVNode("span", _hoisted_8, [
110
110
  __props.product.quantity ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
111
- vue.createTextVNode(vue.toDisplayString(__props.product.price_currency || _ctx.returnCurrency()) + vue.toDisplayString(__props.product.price), 1)
111
+ vue.createTextVNode(vue.toDisplayString(_ctx.returnCurrency()) + vue.toDisplayString(__props.product.price), 1)
112
112
  ], 64)) : vue.createCommentVNode("", true),
113
113
  _cache[4] || (_cache[4] = vue.createTextVNode(" × ")),
114
114
  __props.product.listing === "rent" && rentDates.value.start && rentDates.value.end ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
@@ -1 +1 @@
1
- {"version":3,"file":"CardOrderItem.vue.cjs","sources":["../../../../../../../src/modules/orders/components/blocks/CardOrderItem.vue"],"sourcesContent":["<template>\n <div class=\"gap-small pos-relative cols-1\">\n <div class=\"pos-relative w-100 gap-thin flex-stretch flex-nowrap flex\">\n <div class=\"bg-light h-100 o-hidden pos-relative radius-small aspect-1x1\"\n style=\"flex: 1 0 auto\"\n >\n <!-- Item Image -->\n <img loading=\"lazy\" \n class=\"w-100 object-fit-cover pos-absolute h-100\" \n v-if=\"product.images[0]\" \n :src=\"(FILE_SERVER_URL || '') + product.images[0]\"\n >\n <PlaceholderImage\n v-if=\"!product.images[0]\" \n class=\"bg-light pos-absolute radius-small w-100 h-100\"\n />\n </div>\n \n <!-- Item Description -->\n <div class=\"w-100 pos-relative\">\n <!-- Name -->\n <p class=\"t-truncate t-medium\">{{ product.name }}</p>\n <div>\n <p>\n <span class=\"t-second mn-r-micro d-inline-block t-demi\">\n {{ product.price_currency || returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}\n </span>\n\n <span class=\"p-small t-transp\">\n <template v-if=\"product.quantity\">{{product.price_currency || returnCurrency() }}{{product.price}} </template>\n × \n <template v-if=\"product.listing === 'rent' && rentDates.start && rentDates.end\">\n {{ rentalDays }} days\n </template>\n \n <template v-else>\n {{ product.quantity || 0 }} {{ product.unit || 'pcs' }}\n </template>\n </span>\n </p> \n </div>\n \n <!-- Control Buttons -->\n <div v-if=\"editable || product.listing === 'rent'\" class=\"mn-t-thin gap-thin flex-nojustify flex\">\n <!-- For Rent Items: Edit Dates Button -->\n <div v-if=\"(product.listing === 'rent') && (rentDates.start && rentDates.end)\" class=\"flex gap-thin flex-v-center cursor-pointer pd-thin w-100 bg-light radius-small\">\n <IconCalendar\n @click=\"openRentDatePopup\"\n class=\"cursor-pointer i-medium\"\n />\n <!-- Rent Dates Display -->\n <p @click=\"editable ? openRentDatePopup : null\" class=\"t-medium t-transp\">\n {{ formatDate(rentDates.start, { dayMonth: true, language: locale }) }} - {{ formatDate(rentDates.end, { dayMonth: true, language: locale }) }}\n </p>\n </div>\n\n <!-- For Regular Items: Quantity Control Buttons -->\n <template v-if=\"editable &&product.listing !== 'rent'\">\n <IconAdd\n @click=\"increase_(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconMinus\n @click=\"decrease(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconDelete\n @click=\"remove(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n </template>\n\n <IconEdit\n v-if=\"product.listing === 'rent' && editable\"\n @click=\"openRentDatePopup\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-small radius-small\"\n />\n </div>\n </div>\n </div>\n \n <!-- Rent Date Popup -->\n <PopupDateSelector\n :isOpen=\"isRentDatePopupOpen\"\n :product=\"product\"\n :initialDates=\"rentDates\"\n :showFees=\"true\"\n :showVat=\"true\"\n :feesRate=\"0.15\"\n :vatRate=\"0.2\"\n :showCancelButton=\"true\"\n :onCancel=\"() => remove(product)\"\n @confirm=\"updateRentDates\"\n @close=\"closeRentDatePopup\"\n />\n </div>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\nimport { format } from 'date-fns'\nimport IconAdd from '@martyrs/src/modules/icons/navigation/IconAdd.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconMinus from '@martyrs/src/modules/icons/navigation/IconMinus.vue'\nimport IconDelete from '@martyrs/src/modules/icons/navigation/IconDelete.vue'\nimport IconCalendar from '@martyrs/src/modules/icons/entities/IconCalendar.vue'\nimport PlaceholderImage from '@martyrs/src/modules/icons/placeholders/PlaceholderImage.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\n\nconst router = useRouter()\nconst emits = defineEmits(['increase', 'decrease', 'remove', 'updateRentDates'])\n\nconst props = defineProps({\n product: Object,\n editable: Boolean,\n increase: Function,\n decrease: Function,\n remove: Function,\n})\n\nconst { locale } = useI18n()\n\n// Rental dates state - initialize from product if available\nconst rentDates = ref({\n start: props.product.date?.start || null,\n end: props.product.date?.end || null\n})\n\n// Rental days calculation\nconst rentalDays = computed(() => {\n if (!rentDates.value.start || !rentDates.value.end) return 0\n \n const start = new Date(rentDates.value.start)\n const end = new Date(rentDates.value.end)\n const diffTime = Math.abs(end - start)\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1\n})\n\n// Popup state\nconst isRentDatePopupOpen = ref(false)\n\n// Methods for buttons\nfunction increase_(product) {\n if (props.increase) {\n props.increase(product)\n }\n emits('increase', product)\n}\n\nfunction decrease(product) {\n if (props.decrease) {\n props.decrease(product)\n }\n emits('decrease', product)\n}\n\nfunction remove(product) {\n if (props.remove) {\n props.remove(product)\n }\n emits('remove', product)\n}\n\n// Rent date popup functions\nfunction openRentDatePopup() {\n isRentDatePopupOpen.value = true\n}\n\nfunction closeRentDatePopup() {\nisRentDatePopupOpen.value = false\n}\n\nfunction updateRentDates(dates) {\n rentDates.value = dates\n emits('updateRentDates', props.product, dates)\n closeRentDatePopup()\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["useRouter","useI18n","ref","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GeA,cAAS,UAAA;AACxB,UAAM,QAAQ;AAEd,UAAM,QAAQ;AAQd,UAAM,EAAE,OAAQ,IAAGC,QAAO,QAAA;AAG1B,UAAM,YAAYC,IAAAA,IAAI;AAAA,MACpB,SAAO,WAAM,QAAQ,SAAd,mBAAoB,UAAS;AAAA,MACpC,OAAK,WAAM,QAAQ,SAAd,mBAAoB,QAAO;AAAA,IAClC,CAAC;AAGD,UAAM,aAAaC,IAAQ,SAAC,MAAM;AAChC,UAAI,CAAC,UAAU,MAAM,SAAS,CAAC,UAAU,MAAM,IAAK,QAAO;AAE3D,YAAM,QAAQ,IAAI,KAAK,UAAU,MAAM,KAAK;AAC5C,YAAM,MAAM,IAAI,KAAK,UAAU,MAAM,GAAG;AACxC,YAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,aAAO,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,IACvD,CAAC;AAGD,UAAM,sBAAsBD,IAAG,IAAC,KAAK;AAGrC,aAAS,UAAU,SAAS;AAC1B,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,SAAS,SAAS;AACzB,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,OAAO,SAAS;AACvB,UAAI,MAAM,QAAQ;AAChB,cAAM,OAAO,OAAO;AAAA,MACxB;AACE,YAAM,UAAU,OAAO;AAAA,IACzB;AAGA,aAAS,oBAAoB;AAC3B,0BAAoB,QAAQ;AAAA,IAC9B;AAEA,aAAS,qBAAqB;AAC9B,0BAAoB,QAAQ;AAAA,IAC5B;AAEA,aAAS,gBAAgB,OAAO;AAC9B,gBAAU,QAAQ;AAClB,YAAM,mBAAmB,MAAM,SAAS,KAAK;AAC7C,yBAAkB;AAAA,IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CardOrderItem.vue.cjs","sources":["../../../../../../../src/modules/orders/components/blocks/CardOrderItem.vue"],"sourcesContent":["<template>\n <div class=\"gap-small pos-relative cols-1\">\n <div class=\"pos-relative w-100 gap-thin flex-stretch flex-nowrap flex\">\n <div class=\"bg-light h-100 o-hidden pos-relative radius-small aspect-1x1\"\n style=\"flex: 1 0 auto\"\n >\n <!-- Item Image -->\n <img loading=\"lazy\" \n class=\"w-100 object-fit-cover pos-absolute h-100\" \n v-if=\"product.images[0]\" \n :src=\"(FILE_SERVER_URL || '') + product.images[0]\"\n >\n <PlaceholderImage\n v-if=\"!product.images[0]\" \n class=\"bg-light pos-absolute radius-small w-100 h-100\"\n />\n </div>\n \n <!-- Item Description -->\n <div class=\"w-100 pos-relative\">\n <!-- Name -->\n <p class=\"t-truncate t-medium\">{{ product.name }}</p>\n <div>\n <p>\n <span class=\"t-second mn-r-micro d-inline-block t-demi\">\n {{ returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}\n </span>\n\n <span class=\"p-small t-transp\">\n <template v-if=\"product.quantity\">{{returnCurrency() }}{{product.price}} </template>\n × \n <template v-if=\"product.listing === 'rent' && rentDates.start && rentDates.end\">\n {{ rentalDays }} days\n </template>\n \n <template v-else>\n {{ product.quantity || 0 }} {{ product.unit || 'pcs' }}\n </template>\n </span>\n </p> \n </div>\n \n <!-- Control Buttons -->\n <div v-if=\"editable || product.listing === 'rent'\" class=\"mn-t-thin gap-thin flex-nojustify flex\">\n <!-- For Rent Items: Edit Dates Button -->\n <div v-if=\"(product.listing === 'rent') && (rentDates.start && rentDates.end)\" class=\"flex gap-thin flex-v-center cursor-pointer pd-thin w-100 bg-light radius-small\">\n <IconCalendar\n @click=\"openRentDatePopup\"\n class=\"cursor-pointer i-medium\"\n />\n <!-- Rent Dates Display -->\n <p @click=\"editable ? openRentDatePopup : null\" class=\"t-medium t-transp\">\n {{ formatDate(rentDates.start, { dayMonth: true, language: locale }) }} - {{ formatDate(rentDates.end, { dayMonth: true, language: locale }) }}\n </p>\n </div>\n\n <!-- For Regular Items: Quantity Control Buttons -->\n <template v-if=\"editable &&product.listing !== 'rent'\">\n <IconAdd\n @click=\"increase_(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconMinus\n @click=\"decrease(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconDelete\n @click=\"remove(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n </template>\n\n <IconEdit\n v-if=\"product.listing === 'rent' && editable\"\n @click=\"openRentDatePopup\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-small radius-small\"\n />\n </div>\n </div>\n </div>\n \n <!-- Rent Date Popup -->\n <PopupDateSelector\n :isOpen=\"isRentDatePopupOpen\"\n :product=\"product\"\n :initialDates=\"rentDates\"\n :showFees=\"true\"\n :showVat=\"true\"\n :feesRate=\"0.15\"\n :vatRate=\"0.2\"\n :showCancelButton=\"true\"\n :onCancel=\"() => remove(product)\"\n @confirm=\"updateRentDates\"\n @close=\"closeRentDatePopup\"\n />\n </div>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\nimport { format } from 'date-fns'\nimport IconAdd from '@martyrs/src/modules/icons/navigation/IconAdd.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconMinus from '@martyrs/src/modules/icons/navigation/IconMinus.vue'\nimport IconDelete from '@martyrs/src/modules/icons/navigation/IconDelete.vue'\nimport IconCalendar from '@martyrs/src/modules/icons/entities/IconCalendar.vue'\nimport PlaceholderImage from '@martyrs/src/modules/icons/placeholders/PlaceholderImage.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\n\nconst router = useRouter()\nconst emits = defineEmits(['increase', 'decrease', 'remove', 'updateRentDates'])\n\nconst props = defineProps({\n product: Object,\n editable: Boolean,\n increase: Function,\n decrease: Function,\n remove: Function,\n})\n\nconst { locale } = useI18n()\n\n// Rental dates state - initialize from product if available\nconst rentDates = ref({\n start: props.product.date?.start || null,\n end: props.product.date?.end || null\n})\n\n// Rental days calculation\nconst rentalDays = computed(() => {\n if (!rentDates.value.start || !rentDates.value.end) return 0\n \n const start = new Date(rentDates.value.start)\n const end = new Date(rentDates.value.end)\n const diffTime = Math.abs(end - start)\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1\n})\n\n// Popup state\nconst isRentDatePopupOpen = ref(false)\n\n// Methods for buttons\nfunction increase_(product) {\n if (props.increase) {\n props.increase(product)\n }\n emits('increase', product)\n}\n\nfunction decrease(product) {\n if (props.decrease) {\n props.decrease(product)\n }\n emits('decrease', product)\n}\n\nfunction remove(product) {\n if (props.remove) {\n props.remove(product)\n }\n emits('remove', product)\n}\n\n// Rent date popup functions\nfunction openRentDatePopup() {\n isRentDatePopupOpen.value = true\n}\n\nfunction closeRentDatePopup() {\nisRentDatePopupOpen.value = false\n}\n\nfunction updateRentDates(dates) {\n rentDates.value = dates\n emits('updateRentDates', props.product, dates)\n closeRentDatePopup()\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":["useRouter","useI18n","ref","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GeA,cAAS,UAAA;AACxB,UAAM,QAAQ;AAEd,UAAM,QAAQ;AAQd,UAAM,EAAE,OAAQ,IAAGC,QAAO,QAAA;AAG1B,UAAM,YAAYC,IAAAA,IAAI;AAAA,MACpB,SAAO,WAAM,QAAQ,SAAd,mBAAoB,UAAS;AAAA,MACpC,OAAK,WAAM,QAAQ,SAAd,mBAAoB,QAAO;AAAA,IAClC,CAAC;AAGD,UAAM,aAAaC,IAAQ,SAAC,MAAM;AAChC,UAAI,CAAC,UAAU,MAAM,SAAS,CAAC,UAAU,MAAM,IAAK,QAAO;AAE3D,YAAM,QAAQ,IAAI,KAAK,UAAU,MAAM,KAAK;AAC5C,YAAM,MAAM,IAAI,KAAK,UAAU,MAAM,GAAG;AACxC,YAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,aAAO,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,IACvD,CAAC;AAGD,UAAM,sBAAsBD,IAAG,IAAC,KAAK;AAGrC,aAAS,UAAU,SAAS;AAC1B,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,SAAS,SAAS;AACzB,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,OAAO,SAAS;AACvB,UAAI,MAAM,QAAQ;AAChB,cAAM,OAAO,OAAO;AAAA,MACxB;AACE,YAAM,UAAU,OAAO;AAAA,IACzB;AAGA,aAAS,oBAAoB;AAC3B,0BAAoB,QAAQ;AAAA,IAC9B;AAEA,aAAS,qBAAqB;AAC9B,0BAAoB,QAAQ;AAAA,IAC5B;AAEA,aAAS,gBAAgB,OAAO;AAC9B,gBAAU,QAAQ;AAClB,YAAM,mBAAmB,MAAM,SAAS,KAAK;AAC7C,yBAAkB;AAAA,IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -103,10 +103,10 @@ const _sfc_main = {
103
103
  createElementVNode("p", _hoisted_6, toDisplayString(__props.product.name), 1),
104
104
  createElementVNode("div", null, [
105
105
  createElementVNode("p", null, [
106
- createElementVNode("span", _hoisted_7, toDisplayString(__props.product.price_currency || _ctx.returnCurrency()) + toDisplayString((__props.product.listing === "rent" ? rentalDays.value || __props.product.quantity || 0 : __props.product.quantity || 0) * __props.product.price), 1),
106
+ createElementVNode("span", _hoisted_7, toDisplayString(_ctx.returnCurrency()) + toDisplayString((__props.product.listing === "rent" ? rentalDays.value || __props.product.quantity || 0 : __props.product.quantity || 0) * __props.product.price), 1),
107
107
  createElementVNode("span", _hoisted_8, [
108
108
  __props.product.quantity ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
109
- createTextVNode(toDisplayString(__props.product.price_currency || _ctx.returnCurrency()) + toDisplayString(__props.product.price), 1)
109
+ createTextVNode(toDisplayString(_ctx.returnCurrency()) + toDisplayString(__props.product.price), 1)
110
110
  ], 64)) : createCommentVNode("", true),
111
111
  _cache[4] || (_cache[4] = createTextVNode(" × ")),
112
112
  __props.product.listing === "rent" && rentDates.value.start && rentDates.value.end ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
@@ -1 +1 @@
1
- {"version":3,"file":"CardOrderItem.vue.js","sources":["../../../../../../../src/modules/orders/components/blocks/CardOrderItem.vue"],"sourcesContent":["<template>\n <div class=\"gap-small pos-relative cols-1\">\n <div class=\"pos-relative w-100 gap-thin flex-stretch flex-nowrap flex\">\n <div class=\"bg-light h-100 o-hidden pos-relative radius-small aspect-1x1\"\n style=\"flex: 1 0 auto\"\n >\n <!-- Item Image -->\n <img loading=\"lazy\" \n class=\"w-100 object-fit-cover pos-absolute h-100\" \n v-if=\"product.images[0]\" \n :src=\"(FILE_SERVER_URL || '') + product.images[0]\"\n >\n <PlaceholderImage\n v-if=\"!product.images[0]\" \n class=\"bg-light pos-absolute radius-small w-100 h-100\"\n />\n </div>\n \n <!-- Item Description -->\n <div class=\"w-100 pos-relative\">\n <!-- Name -->\n <p class=\"t-truncate t-medium\">{{ product.name }}</p>\n <div>\n <p>\n <span class=\"t-second mn-r-micro d-inline-block t-demi\">\n {{ product.price_currency || returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}\n </span>\n\n <span class=\"p-small t-transp\">\n <template v-if=\"product.quantity\">{{product.price_currency || returnCurrency() }}{{product.price}} </template>\n × \n <template v-if=\"product.listing === 'rent' && rentDates.start && rentDates.end\">\n {{ rentalDays }} days\n </template>\n \n <template v-else>\n {{ product.quantity || 0 }} {{ product.unit || 'pcs' }}\n </template>\n </span>\n </p> \n </div>\n \n <!-- Control Buttons -->\n <div v-if=\"editable || product.listing === 'rent'\" class=\"mn-t-thin gap-thin flex-nojustify flex\">\n <!-- For Rent Items: Edit Dates Button -->\n <div v-if=\"(product.listing === 'rent') && (rentDates.start && rentDates.end)\" class=\"flex gap-thin flex-v-center cursor-pointer pd-thin w-100 bg-light radius-small\">\n <IconCalendar\n @click=\"openRentDatePopup\"\n class=\"cursor-pointer i-medium\"\n />\n <!-- Rent Dates Display -->\n <p @click=\"editable ? openRentDatePopup : null\" class=\"t-medium t-transp\">\n {{ formatDate(rentDates.start, { dayMonth: true, language: locale }) }} - {{ formatDate(rentDates.end, { dayMonth: true, language: locale }) }}\n </p>\n </div>\n\n <!-- For Regular Items: Quantity Control Buttons -->\n <template v-if=\"editable &&product.listing !== 'rent'\">\n <IconAdd\n @click=\"increase_(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconMinus\n @click=\"decrease(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconDelete\n @click=\"remove(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n </template>\n\n <IconEdit\n v-if=\"product.listing === 'rent' && editable\"\n @click=\"openRentDatePopup\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-small radius-small\"\n />\n </div>\n </div>\n </div>\n \n <!-- Rent Date Popup -->\n <PopupDateSelector\n :isOpen=\"isRentDatePopupOpen\"\n :product=\"product\"\n :initialDates=\"rentDates\"\n :showFees=\"true\"\n :showVat=\"true\"\n :feesRate=\"0.15\"\n :vatRate=\"0.2\"\n :showCancelButton=\"true\"\n :onCancel=\"() => remove(product)\"\n @confirm=\"updateRentDates\"\n @close=\"closeRentDatePopup\"\n />\n </div>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\nimport { format } from 'date-fns'\nimport IconAdd from '@martyrs/src/modules/icons/navigation/IconAdd.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconMinus from '@martyrs/src/modules/icons/navigation/IconMinus.vue'\nimport IconDelete from '@martyrs/src/modules/icons/navigation/IconDelete.vue'\nimport IconCalendar from '@martyrs/src/modules/icons/entities/IconCalendar.vue'\nimport PlaceholderImage from '@martyrs/src/modules/icons/placeholders/PlaceholderImage.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\n\nconst router = useRouter()\nconst emits = defineEmits(['increase', 'decrease', 'remove', 'updateRentDates'])\n\nconst props = defineProps({\n product: Object,\n editable: Boolean,\n increase: Function,\n decrease: Function,\n remove: Function,\n})\n\nconst { locale } = useI18n()\n\n// Rental dates state - initialize from product if available\nconst rentDates = ref({\n start: props.product.date?.start || null,\n end: props.product.date?.end || null\n})\n\n// Rental days calculation\nconst rentalDays = computed(() => {\n if (!rentDates.value.start || !rentDates.value.end) return 0\n \n const start = new Date(rentDates.value.start)\n const end = new Date(rentDates.value.end)\n const diffTime = Math.abs(end - start)\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1\n})\n\n// Popup state\nconst isRentDatePopupOpen = ref(false)\n\n// Methods for buttons\nfunction increase_(product) {\n if (props.increase) {\n props.increase(product)\n }\n emits('increase', product)\n}\n\nfunction decrease(product) {\n if (props.decrease) {\n props.decrease(product)\n }\n emits('decrease', product)\n}\n\nfunction remove(product) {\n if (props.remove) {\n props.remove(product)\n }\n emits('remove', product)\n}\n\n// Rent date popup functions\nfunction openRentDatePopup() {\n isRentDatePopupOpen.value = true\n}\n\nfunction closeRentDatePopup() {\nisRentDatePopupOpen.value = false\n}\n\nfunction updateRentDates(dates) {\n rentDates.value = dates\n emits('updateRentDates', props.product, dates)\n closeRentDatePopup()\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ge,cAAS;AACxB,UAAM,QAAQ;AAEd,UAAM,QAAQ;AAQd,UAAM,EAAE,OAAQ,IAAG,QAAO;AAG1B,UAAM,YAAY,IAAI;AAAA,MACpB,SAAO,WAAM,QAAQ,SAAd,mBAAoB,UAAS;AAAA,MACpC,OAAK,WAAM,QAAQ,SAAd,mBAAoB,QAAO;AAAA,IAClC,CAAC;AAGD,UAAM,aAAa,SAAS,MAAM;AAChC,UAAI,CAAC,UAAU,MAAM,SAAS,CAAC,UAAU,MAAM,IAAK,QAAO;AAE3D,YAAM,QAAQ,IAAI,KAAK,UAAU,MAAM,KAAK;AAC5C,YAAM,MAAM,IAAI,KAAK,UAAU,MAAM,GAAG;AACxC,YAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,aAAO,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,IACvD,CAAC;AAGD,UAAM,sBAAsB,IAAI,KAAK;AAGrC,aAAS,UAAU,SAAS;AAC1B,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,SAAS,SAAS;AACzB,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,OAAO,SAAS;AACvB,UAAI,MAAM,QAAQ;AAChB,cAAM,OAAO,OAAO;AAAA,MACxB;AACE,YAAM,UAAU,OAAO;AAAA,IACzB;AAGA,aAAS,oBAAoB;AAC3B,0BAAoB,QAAQ;AAAA,IAC9B;AAEA,aAAS,qBAAqB;AAC9B,0BAAoB,QAAQ;AAAA,IAC5B;AAEA,aAAS,gBAAgB,OAAO;AAC9B,gBAAU,QAAQ;AAClB,YAAM,mBAAmB,MAAM,SAAS,KAAK;AAC7C,yBAAkB;AAAA,IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CardOrderItem.vue.js","sources":["../../../../../../../src/modules/orders/components/blocks/CardOrderItem.vue"],"sourcesContent":["<template>\n <div class=\"gap-small pos-relative cols-1\">\n <div class=\"pos-relative w-100 gap-thin flex-stretch flex-nowrap flex\">\n <div class=\"bg-light h-100 o-hidden pos-relative radius-small aspect-1x1\"\n style=\"flex: 1 0 auto\"\n >\n <!-- Item Image -->\n <img loading=\"lazy\" \n class=\"w-100 object-fit-cover pos-absolute h-100\" \n v-if=\"product.images[0]\" \n :src=\"(FILE_SERVER_URL || '') + product.images[0]\"\n >\n <PlaceholderImage\n v-if=\"!product.images[0]\" \n class=\"bg-light pos-absolute radius-small w-100 h-100\"\n />\n </div>\n \n <!-- Item Description -->\n <div class=\"w-100 pos-relative\">\n <!-- Name -->\n <p class=\"t-truncate t-medium\">{{ product.name }}</p>\n <div>\n <p>\n <span class=\"t-second mn-r-micro d-inline-block t-demi\">\n {{ returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}\n </span>\n\n <span class=\"p-small t-transp\">\n <template v-if=\"product.quantity\">{{returnCurrency() }}{{product.price}} </template>\n × \n <template v-if=\"product.listing === 'rent' && rentDates.start && rentDates.end\">\n {{ rentalDays }} days\n </template>\n \n <template v-else>\n {{ product.quantity || 0 }} {{ product.unit || 'pcs' }}\n </template>\n </span>\n </p> \n </div>\n \n <!-- Control Buttons -->\n <div v-if=\"editable || product.listing === 'rent'\" class=\"mn-t-thin gap-thin flex-nojustify flex\">\n <!-- For Rent Items: Edit Dates Button -->\n <div v-if=\"(product.listing === 'rent') && (rentDates.start && rentDates.end)\" class=\"flex gap-thin flex-v-center cursor-pointer pd-thin w-100 bg-light radius-small\">\n <IconCalendar\n @click=\"openRentDatePopup\"\n class=\"cursor-pointer i-medium\"\n />\n <!-- Rent Dates Display -->\n <p @click=\"editable ? openRentDatePopup : null\" class=\"t-medium t-transp\">\n {{ formatDate(rentDates.start, { dayMonth: true, language: locale }) }} - {{ formatDate(rentDates.end, { dayMonth: true, language: locale }) }}\n </p>\n </div>\n\n <!-- For Regular Items: Quantity Control Buttons -->\n <template v-if=\"editable &&product.listing !== 'rent'\">\n <IconAdd\n @click=\"increase_(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconMinus\n @click=\"decrease(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n <IconDelete\n @click=\"remove(product)\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-thin radius-small\"\n />\n </template>\n\n <IconEdit\n v-if=\"product.listing === 'rent' && editable\"\n @click=\"openRentDatePopup\"\n class=\"hover-scale-1 cursor-pointer bg-light i-big pd-small radius-small\"\n />\n </div>\n </div>\n </div>\n \n <!-- Rent Date Popup -->\n <PopupDateSelector\n :isOpen=\"isRentDatePopupOpen\"\n :product=\"product\"\n :initialDates=\"rentDates\"\n :showFees=\"true\"\n :showVat=\"true\"\n :feesRate=\"0.15\"\n :vatRate=\"0.2\"\n :showCancelButton=\"true\"\n :onCancel=\"() => remove(product)\"\n @confirm=\"updateRentDates\"\n @close=\"closeRentDatePopup\"\n />\n </div>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport { useI18n } from 'vue-i18n'\nimport { format } from 'date-fns'\nimport IconAdd from '@martyrs/src/modules/icons/navigation/IconAdd.vue'\nimport IconEdit from '@martyrs/src/modules/icons/navigation/IconEdit.vue'\nimport IconMinus from '@martyrs/src/modules/icons/navigation/IconMinus.vue'\nimport IconDelete from '@martyrs/src/modules/icons/navigation/IconDelete.vue'\nimport IconCalendar from '@martyrs/src/modules/icons/entities/IconCalendar.vue'\nimport PlaceholderImage from '@martyrs/src/modules/icons/placeholders/PlaceholderImage.vue'\nimport PopupDateSelector from '@martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue'\n\nconst router = useRouter()\nconst emits = defineEmits(['increase', 'decrease', 'remove', 'updateRentDates'])\n\nconst props = defineProps({\n product: Object,\n editable: Boolean,\n increase: Function,\n decrease: Function,\n remove: Function,\n})\n\nconst { locale } = useI18n()\n\n// Rental dates state - initialize from product if available\nconst rentDates = ref({\n start: props.product.date?.start || null,\n end: props.product.date?.end || null\n})\n\n// Rental days calculation\nconst rentalDays = computed(() => {\n if (!rentDates.value.start || !rentDates.value.end) return 0\n \n const start = new Date(rentDates.value.start)\n const end = new Date(rentDates.value.end)\n const diffTime = Math.abs(end - start)\n return Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1\n})\n\n// Popup state\nconst isRentDatePopupOpen = ref(false)\n\n// Methods for buttons\nfunction increase_(product) {\n if (props.increase) {\n props.increase(product)\n }\n emits('increase', product)\n}\n\nfunction decrease(product) {\n if (props.decrease) {\n props.decrease(product)\n }\n emits('decrease', product)\n}\n\nfunction remove(product) {\n if (props.remove) {\n props.remove(product)\n }\n emits('remove', product)\n}\n\n// Rent date popup functions\nfunction openRentDatePopup() {\n isRentDatePopupOpen.value = true\n}\n\nfunction closeRentDatePopup() {\nisRentDatePopupOpen.value = false\n}\n\nfunction updateRentDates(dates) {\n rentDates.value = dates\n emits('updateRentDates', props.product, dates)\n closeRentDatePopup()\n}\n</script>\n\n<style lang=\"scss\">\n</style>"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ge,cAAS;AACxB,UAAM,QAAQ;AAEd,UAAM,QAAQ;AAQd,UAAM,EAAE,OAAQ,IAAG,QAAO;AAG1B,UAAM,YAAY,IAAI;AAAA,MACpB,SAAO,WAAM,QAAQ,SAAd,mBAAoB,UAAS;AAAA,MACpC,OAAK,WAAM,QAAQ,SAAd,mBAAoB,QAAO;AAAA,IAClC,CAAC;AAGD,UAAM,aAAa,SAAS,MAAM;AAChC,UAAI,CAAC,UAAU,MAAM,SAAS,CAAC,UAAU,MAAM,IAAK,QAAO;AAE3D,YAAM,QAAQ,IAAI,KAAK,UAAU,MAAM,KAAK;AAC5C,YAAM,MAAM,IAAI,KAAK,UAAU,MAAM,GAAG;AACxC,YAAM,WAAW,KAAK,IAAI,MAAM,KAAK;AACrC,aAAO,KAAK,KAAK,YAAY,MAAO,KAAK,KAAK,GAAG,IAAI;AAAA,IACvD,CAAC;AAGD,UAAM,sBAAsB,IAAI,KAAK;AAGrC,aAAS,UAAU,SAAS;AAC1B,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,SAAS,SAAS;AACzB,UAAI,MAAM,UAAU;AAClB,cAAM,SAAS,OAAO;AAAA,MAC1B;AACE,YAAM,YAAY,OAAO;AAAA,IAC3B;AAEA,aAAS,OAAO,SAAS;AACvB,UAAI,MAAM,QAAQ;AAChB,cAAM,OAAO,OAAO;AAAA,MACxB;AACE,YAAM,UAAU,OAAO;AAAA,IACzB;AAGA,aAAS,oBAAoB;AAC3B,0BAAoB,QAAQ;AAAA,IAC9B;AAEA,aAAS,qBAAqB;AAC9B,0BAAoB,QAAQ;AAAA,IAC5B;AAEA,aAAS,gBAAgB,OAAO;AAC9B,gBAAU,QAAQ;AAClB,YAAM,mBAAmB,MAAM,SAAS,KAAK;AAC7C,yBAAkB;AAAA,IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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";
@@ -33,6 +33,7 @@ const _hoisted_7 = ["disabled"];
33
33
  const _sfc_main = {
34
34
  __name: "OrderCreate",
35
35
  setup(__props) {
36
+ const isLocationLoading = vue.ref(false);
36
37
  vueRouter.useRoute();
37
38
  const router = vueRouter.useRouter();
38
39
  const order = vue.computed(() => orders.state.current);
@@ -51,6 +52,7 @@ const _sfc_main = {
51
52
  }
52
53
  vue.onMounted(async () => {
53
54
  var _a;
55
+ isLocationLoading.value = true;
54
56
  if (auth.state.user._id) {
55
57
  await users.actions.read({ _id: auth.state.user._id, user: auth.state.user._id });
56
58
  orders.state.current.customer.profile.name = users.state.current.profile.name;
@@ -63,7 +65,23 @@ const _sfc_main = {
63
65
  location: (_a = globals.state.position) == null ? void 0 : _a.location,
64
66
  lookup: ["spots"]
65
67
  });
68
+ isLocationLoading.value = false;
66
69
  });
70
+ vue.watch(
71
+ () => orders.state.current.delivery,
72
+ async (newVal) => {
73
+ if (newVal == null ? void 0 : newVal.location) {
74
+ isLocationLoading.value = true;
75
+ orderOrganization.value = await organizations.actions.read({
76
+ _id: shopcart.state.organization,
77
+ location: newVal.location,
78
+ lookup: ["spots"]
79
+ });
80
+ isLocationLoading.value = false;
81
+ }
82
+ },
83
+ { deep: true }
84
+ );
67
85
  const errorName = vue.computed(() => {
68
86
  var _a;
69
87
  if (((_a = orders.state.current.customer.name) == null ? void 0 : _a.length) < 2) {
@@ -122,9 +140,6 @@ const _sfc_main = {
122
140
  };
123
141
  }
124
142
  orders.state.current.positions = shopcart.state.positions;
125
- vue.watch(() => shopcart.state.positions, (newVal) => {
126
- if (newVal) orders.state.current.positions === newVal;
127
- });
128
143
  const referralCode = localStorage.getItem("referalCode");
129
144
  if (referralCode) {
130
145
  orders.state.current.referralCode = referralCode;
@@ -200,7 +215,7 @@ const _sfc_main = {
200
215
  ]),
201
216
  orders.state.current.status !== true && shopcart.state.positions.length > 0 ? (vue.openBlock(), vue.createElementBlock("button", {
202
217
  key: 0,
203
- disabled: errorName.value || errorPhoneOrMessenger.value || _ctx.errorCity || errorAddress.value || errorDelivery.value || errorPayment.value,
218
+ disabled: errorName.value || errorPhoneOrMessenger.value || _ctx.errorCity || errorAddress.value || errorDelivery.value || errorPayment.value || isLocationLoading.value,
204
219
  onClick: _cache[0] || (_cache[0] = ($event) => handleCreate()),
205
220
  class: "bg-main mn-b-small pd-small radius-big w-100 button"
206
221
  }, " Place an Order ", 8, _hoisted_7)) : vue.createCommentVNode("", true),
@@ -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<!-- 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 \"\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///////////////////////////////////////////////////////////////////////////////////////////////////\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\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\t\nonMounted(async()=> {\n\t\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})\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: shopcart.state.organization,\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\twatch(() => shopcart.state.positions, (newVal) => {\n\t if (newVal) orders.state.current.positions === newVal\n\t})\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 } 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":["useRoute","useRouter","computed","orders.state","users.state","shopcart.getters","globals.state","orders.getters","ref","auth.state","onMounted","users.actions","shopcart.state","organizations.actions","watch","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IcA,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;AACxC,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,oBAAoBC,IAAG,IAAC,CAAE,C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Ac;AAAA,MAChD,CAAA;AAEA,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBA,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,MACjC,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\t\nonMounted(async()=> {\n\tisLocationLoading.value = true\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: shopcart.state.organization,\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 } 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","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;AAEAC,QAAAA,UAAU,YAAU;;AACnB,wBAAkB,QAAQ;AAE1B,UAAID,KAAU,MAAC,KAAK,KAAK;AACb,cAAME,cAAc,KAAK,EAAE,KAAIF,KAAU,MAAC,KAAK,KAAK,MAAMA,WAAW,KAAK,IAAK,CAAA;AAC1FL,eAAY,MAAC,QAAQ,SAAS,QAAQ,OAAOC,MAAW,MAAC,QAAQ,QAAQ;AACzED,e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AAEE,UAAIW,SAAQ,MAAMC,OAAAA,QAAe,OAAOZ,OAAAA,MAAa,OAAO;AAE5D,UAAIW,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,MACjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { computed, ref, onMounted, createElementBlock, openBlock, createBlock, createCommentVNode, createElementVNode, createVNode, Fragment, renderList, unref, createTextVNode, watch } 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";
@@ -31,6 +31,7 @@ const _hoisted_7 = ["disabled"];
31
31
  const _sfc_main = {
32
32
  __name: "OrderCreate",
33
33
  setup(__props) {
34
+ const isLocationLoading = ref(false);
34
35
  useRoute();
35
36
  const router = useRouter();
36
37
  const order = computed(() => state.current);
@@ -49,6 +50,7 @@ const _sfc_main = {
49
50
  }
50
51
  onMounted(async () => {
51
52
  var _a;
53
+ isLocationLoading.value = true;
52
54
  if (state$3.user._id) {
53
55
  await actions.read({ _id: state$3.user._id, user: state$3.user._id });
54
56
  state.current.customer.profile.name = state$1.current.profile.name;
@@ -61,7 +63,23 @@ const _sfc_main = {
61
63
  location: (_a = state$2.position) == null ? void 0 : _a.location,
62
64
  lookup: ["spots"]
63
65
  });
66
+ isLocationLoading.value = false;
64
67
  });
68
+ watch(
69
+ () => state.current.delivery,
70
+ async (newVal) => {
71
+ if (newVal == null ? void 0 : newVal.location) {
72
+ isLocationLoading.value = true;
73
+ orderOrganization.value = await actions$1.read({
74
+ _id: state$4.organization,
75
+ location: newVal.location,
76
+ lookup: ["spots"]
77
+ });
78
+ isLocationLoading.value = false;
79
+ }
80
+ },
81
+ { deep: true }
82
+ );
65
83
  const errorName = computed(() => {
66
84
  var _a;
67
85
  if (((_a = state.current.customer.name) == null ? void 0 : _a.length) < 2) {
@@ -120,9 +138,6 @@ const _sfc_main = {
120
138
  };
121
139
  }
122
140
  state.current.positions = state$4.positions;
123
- watch(() => state$4.positions, (newVal) => {
124
- if (newVal) state.current.positions === newVal;
125
- });
126
141
  const referralCode = localStorage.getItem("referalCode");
127
142
  if (referralCode) {
128
143
  state.current.referralCode = referralCode;
@@ -198,7 +213,7 @@ const _sfc_main = {
198
213
  ]),
199
214
  state.current.status !== true && state$4.positions.length > 0 ? (openBlock(), createElementBlock("button", {
200
215
  key: 0,
201
- disabled: errorName.value || errorPhoneOrMessenger.value || _ctx.errorCity || errorAddress.value || errorDelivery.value || errorPayment.value,
216
+ disabled: errorName.value || errorPhoneOrMessenger.value || _ctx.errorCity || errorAddress.value || errorDelivery.value || errorPayment.value || isLocationLoading.value,
202
217
  onClick: _cache[0] || (_cache[0] = ($event) => handleCreate()),
203
218
  class: "bg-main mn-b-small pd-small radius-big w-100 button"
204
219
  }, " Place an Order ", 8, _hoisted_7)) : createCommentVNode("", true),
@@ -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<!-- 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 \"\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///////////////////////////////////////////////////////////////////////////////////////////////////\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\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\t\nonMounted(async()=> {\n\t\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})\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: shopcart.state.organization,\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\twatch(() => shopcart.state.positions, (newVal) => {\n\t if (newVal) orders.state.current.positions === newVal\n\t})\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 } 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","users.actions","shopcart.state","organizations.actions","order","orders.actions","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4Ic,aAAQ;AACtB,UAAM,SAAS,UAAS;AAExB,UAAM,QAAQ,SAAS,MAAMA,MAAa,OAAO;AACpC,aAAS,MAAMC,QAAY,OAAO;AAE/C,UAAM,iBAAiBC,QAAiB;AACxC,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;AAEA,cAAU,YAAU;;AAGnB,UAAIA,QAAW,KAAK,KAAK;AACb,cAAMC,QAAc,KAAK,EAAE,KAAID,QAAW,KAAK,KAAK,MAAMA,QAAW,KAAK,IAAK,CAAA;AAC1FL,cAAa,QAAQ,SAAS,QAAQ,OAAOC,QAAY,QAAQ,QAAQ;AACzED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e,SAAS,MAAM;AAClC,UAAIA,MAAa,QAAQ,QAAQ,MAAM;AAAE,eAAO;AAAA,MAAK,OAAQ;AAAC,eAAO;AAAA,MAAM;AAAA,IAC7E,CAAC;AAID,mBAAe,eAAe;AAE7BA,YAAa,QAAQ,SAAS;AAE9BA,YAAa,QAAQ,QAAQ;AAAA,QAC5B,QAAQO,QAAe;AAAA,QACvB,MAAM;AAAA,MACR;AAEC,UAAIF,QAAW,KAAK,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,YAAYO,QAAe;AAEhD,YAAM,MAAMA,QAAe,WAAW,CAAC,WAAW;AAChD,YAAI,OAAQP,OAAa,QAAQ,cAAc;AAAA,MAChD,CAAA;AAEA,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBA,cAAa,QAAQ,eAAe;AAAA,MACxC;AAEE,UAAIS,SAAQ,MAAMC,UAAe,OAAOV,MAAa,OAAO;AAE5D,UAAIS,QAAO;AACV,cAAM,OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,kBAAiB,cAAa;AAAA,MACjC,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\t\nonMounted(async()=> {\n\tisLocationLoading.value = true\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: shopcart.state.organization,\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 } 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","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,U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a,QAAQ,WAAW;AAAA,UAC/B,QAAQK,QAAW,KAAK;AAAA,UACxB,MAAM;AAAA,QACT;AAAA,MACA;AAECL,YAAa,QAAQ,YAAYO,QAAe;AAE/C,YAAM,eAAe,aAAa,QAAQ,aAAa;AAEvD,UAAI,cAAc;AAChBP,cAAa,QAAQ,eAAe;AAAA,MACxC;AAEE,UAAIS,SAAQ,MAAMC,UAAe,OAAOV,MAAa,OAAO;AAE5D,UAAIS,QAAO;AACV,cAAM,OAAO,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,QAAQ;AAAA,YACP,OAAOA,OAAM;AAAA,UAClB;AAAA,QACI,CAAA;AAEDE,kBAAiB,cAAa;AAAA,MACjC,OAAS;AACN,cAAM,iBAAiB;AAAA,MAC1B;AAAA,IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -147,7 +147,7 @@ const getters = {
147
147
  },
148
148
  getDeliveryPrice(type, distance = 0, config = {}) {
149
149
  if (type === "pickup") return config.pickupCost || 0;
150
- if (type === "mail") return config.mailCost || 300;
150
+ if (type === "post") return config.mailCost || 300;
151
151
  if (type === "courier") {
152
152
  const base = config.courierBase || 100;
153
153
  const perKm = config.courierPerKm || 20;
@@ -1 +1 @@
1
- {"version":3,"file":"orders.cjs","sources":["../../../../../../src/modules/orders/store/orders.js"],"sourcesContent":["// Dependencies\nimport { reactive, ref, computed, toRefs, watch } from \"vue\";\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n// Init State\nimport orderInitState from \"@martyrs/src/modules/orders/store/models/order\"\n\n\nconst state = reactive({\n all: [], \n current: {\n ...orderInitState\n }\n});\n\nconst actions = {\n async create(order) {\n try {\n const response = await $axios.post('/api/orders/create', order);\n\n state.all.push(response.data);\n\n return response.data;\n } catch (error) {\n setError(error);\n }\n },\n\n async read( options = {}) {\n try {\n \n console.log('options is', options)\n const response = await $axios.get('/api/orders/read', { params: options });\n\n if (options._id) {\n set(response.data[0], 'current')\n } else {\n set(response.data, 'all')\n }\n\n return response.data; \n } catch (err) {\n setError(err)\n throw err;\n }\n },\n\n async update(order) {\n try {\n const response = await $axios.post(`/api/orders/update`, order);\n\n const index = state.all.findIndex(o => o._id === order._id);\n \n if (index !== -1) {\n state.all[index] = response.data;\n }\n\n return response.data; \n } catch (error) {\n setError(error);\n }\n },\n\n async delete(orderID) {\n try {\n await $axios.delete(`/api/orders/${orderID}`);\n state.all = state.all.filter(o => o._id !== orderID);\n } catch (error) {\n setError(error);\n }\n },\n\n async changePaymentStatus(orderID, status) {\n try {\n const response = await $axios.post(`/api/orders/payment/${orderID}`, { status });\n const index = state.all.findIndex(o => o._id === orderID);\n if (index !== -1) {\n state.all[index] = response.data;\n }\n } catch (error) {\n setError(error);\n }\n },\n}\n\nconst mutations = { \n updateRentDates({ positions, productId, dates }) {\n const product = positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n },\n\n\n addProductToCart(state, 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 price_currency: product.price_currency,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n },\n\n\n removeProduct(state, _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(state, _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 },\n\n\n incrementItemQuantity(state, _id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n }\n },\n\n\n resetCustomer(stateObject) { \n Object.assign(stateObject, customerInitState);\n }, \n resetOrder(stateObject) {\n state.current = { ...orderInitState }\n // Object.assign(stateObject, orderInitState);\n } \n}\n\nconst getters = {\n getTotal(positions) {\n return Number(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 getDeliveryPrice(type, distance = 0, config = {}) {\n if (type === 'pickup') return config.pickupCost || 0;\n if (type === 'mail') return config.mailCost || 300;\n\n if (type === 'courier') {\n const base = config.courierBase || 100;\n const perKm = config.courierPerKm || 20;\n const discount = config.courierDiscountFactor || 7.5;\n\n return Math.trunc(base + perKm * distance - discount * (distance / 10));\n }\n\n return 0;\n }\n}\n\nfunction set(eventData, property) { \n state[property] = eventData\n}\n\nconst history = []\n\nhistory.push(state) \n\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\nexport {\n state,\n actions,\n mutations,\n getters\n}"],"names":["reactive","orderInitState","order","$axios","setError","state","watch"],"mappings":";;;;;;AAUK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,KAAK,CAAE;AAAA,EACP,SAAS;AAAA,IACP,GAAGC,MAAAA;AAAAA,EACP;AACA,CAAC;AAEI,MAAC,UAAU;AAAA,EACd,MAAM,OAAOC,QAAO;AAClB,QAAI;AACF,YAAM,WAAW,MAAMC,cAAAA,QAAO,KAAK,sBAAsBD,MAAK;AAE9D,YAAM,IAAI,KAAK,SAAS,IAAI;AA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AAW,GAAG;AAAA,IAC5E;AAEI,WAAO;AAAA,EACX;AACA;AAEA,SAAS,IAAI,WAAW,UAAU;AAChC,QAAM,QAAQ,IAAI;AACpB;AAMAK,IAAAA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;;;;;"}
1
+ {"version":3,"file":"orders.cjs","sources":["../../../../../../src/modules/orders/store/orders.js"],"sourcesContent":["// Dependencies\nimport { reactive, ref, computed, toRefs, watch } from \"vue\";\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n// Init State\nimport orderInitState from \"@martyrs/src/modules/orders/store/models/order\"\n\n\nconst state = reactive({\n all: [], \n current: {\n ...orderInitState\n }\n});\n\nconst actions = {\n async create(order) {\n try {\n const response = await $axios.post('/api/orders/create', order);\n\n state.all.push(response.data);\n\n return response.data;\n } catch (error) {\n setError(error);\n }\n },\n\n async read( options = {}) {\n try {\n \n console.log('options is', options)\n const response = await $axios.get('/api/orders/read', { params: options });\n\n if (options._id) {\n set(response.data[0], 'current')\n } else {\n set(response.data, 'all')\n }\n\n return response.data; \n } catch (err) {\n setError(err)\n throw err;\n }\n },\n\n async update(order) {\n try {\n const response = await $axios.post(`/api/orders/update`, order);\n\n const index = state.all.findIndex(o => o._id === order._id);\n \n if (index !== -1) {\n state.all[index] = response.data;\n }\n\n return response.data; \n } catch (error) {\n setError(error);\n }\n },\n\n async delete(orderID) {\n try {\n await $axios.delete(`/api/orders/${orderID}`);\n state.all = state.all.filter(o => o._id !== orderID);\n } catch (error) {\n setError(error);\n }\n },\n\n async changePaymentStatus(orderID, status) {\n try {\n const response = await $axios.post(`/api/orders/payment/${orderID}`, { status });\n const index = state.all.findIndex(o => o._id === orderID);\n if (index !== -1) {\n state.all[index] = response.data;\n }\n } catch (error) {\n setError(error);\n }\n },\n}\n\nconst mutations = { \n updateRentDates({ positions, productId, dates }) {\n const product = positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n },\n\n\n addProductToCart(state, 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 price_currency: product.price_currency,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n },\n\n\n removeProduct(state, _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(state, _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 },\n\n\n incrementItemQuantity(state, _id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n }\n },\n\n\n resetCustomer(stateObject) { \n Object.assign(stateObject, customerInitState);\n }, \n resetOrder(stateObject) {\n state.current = { ...orderInitState }\n // Object.assign(stateObject, orderInitState);\n } \n}\n\nconst getters = {\n getTotal(positions) {\n return Number(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 getDeliveryPrice(type, distance = 0, config = {}) {\n if (type === 'pickup') return config.pickupCost || 0;\n if (type === 'post') return config.mailCost || 300;\n\n if (type === 'courier') {\n const base = config.courierBase || 100;\n const perKm = config.courierPerKm || 20;\n const discount = config.courierDiscountFactor || 7.5;\n\n return Math.trunc(base + perKm * distance - discount * (distance / 10));\n }\n\n return 0;\n }\n}\n\nfunction set(eventData, property) { \n state[property] = eventData\n}\n\nconst history = []\n\nhistory.push(state) \n\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\nexport {\n state,\n actions,\n mutations,\n getters\n}"],"names":["reactive","orderInitState","order","$axios","setError","state","watch"],"mappings":";;;;;;AAUK,MAAC,QAAQA,IAAAA,SAAS;AAAA,EACrB,KAAK,CAAE;AAAA,EACP,SAAS;AAAA,IACP,GAAGC,MAAAA;AAAAA,EACP;AACA,CAAC;AAEI,MAAC,UAAU;AAAA,EACd,MAAM,OAAOC,QAAO;AAClB,QAAI;AACF,YAAM,WAAW,MAAMC,cAAAA,QAAO,KAAK,sBAAsBD,MAAK;AAE9D,YAAM,IAAI,KAAK,SAAS,IAAI;AAE5B,aAAO,SAAS;AAAA,IACjB,SAAQ,OAAO;AACdE,cAAAA,SAAS,KAAK;AAAA,IACpB;AAAA,EACG;AAAA,EAEA,MAAM,KAAM,UAAU,IAAI;AACzB,QAAI;AAEF,cAAQ,IAAI,cAAc,OAAO;AACjC,YAAM,WAAW,MAAMD,sBAAO,IAAI,oBAAoB,EAAE,QAAQ,SAAS;AAEzE,UAAI,QAAQ,KAAK;AACf,YAAI,SAAS,KAAK,CAAC,GAAG,SAAS;AAAA,MACvC,OAAa;AACL,YAAI,SAAS,MAAM,KAAK;AAAA,MAChC;AAEM,aAAO,SAAS;AAAA,IACjB,SAAQ,KAAK;AACZC,cAAAA,SAAS,GAAG;AACZ,YAAM;AAAA,IACZ;AAAA,EACG;AAAA,EAED,MAAM,OAAOF,QAAO;AAClB,QAAI;AACF,YAAM,WAAW,MAAMC,cAAM,QAAC,KAAK,sBAAsBD,MAAK;AAE9D,YAAM,QAAQ,MAAM,IAAI,UAAU,OAAK,EAAE,QAAQA,OAAM,GAAG;AAE1D,UA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M,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,EACN;AAAA,EACD,iBAAiB,MAAM,WAAW,GAAG,SAAS,CAAA,GAAI;AAChD,QAAI,SAAS,SAAU,QAAO,OAAO,cAAc;AACnD,QAAI,SAAS,OAAQ,QAAO,OAAO,YAAY;AAE/C,QAAI,SAAS,WAAW;AACtB,YAAM,OAAO,OAAO,eAAe;AACnC,YAAM,QAAQ,OAAO,gBAAgB;AACrC,YAAM,WAAW,OAAO,yBAAyB;AAEjD,aAAO,KAAK,MAAM,OAAO,QAAQ,WAAW,YAAY,WAAW,GAAG;AAAA,IAC5E;AAEI,WAAO;AAAA,EACX;AACA;AAEA,SAAS,IAAI,WAAW,UAAU;AAChC,QAAM,QAAQ,IAAI;AACpB;AAMAK,IAAAA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;;;;;"}
@@ -145,7 +145,7 @@ const getters = {
145
145
  },
146
146
  getDeliveryPrice(type, distance = 0, config = {}) {
147
147
  if (type === "pickup") return config.pickupCost || 0;
148
- if (type === "mail") return config.mailCost || 300;
148
+ if (type === "post") return config.mailCost || 300;
149
149
  if (type === "courier") {
150
150
  const base = config.courierBase || 100;
151
151
  const perKm = config.courierPerKm || 20;
@@ -1 +1 @@
1
- {"version":3,"file":"orders.js","sources":["../../../../../../src/modules/orders/store/orders.js"],"sourcesContent":["// Dependencies\nimport { reactive, ref, computed, toRefs, watch } from \"vue\";\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n// Init State\nimport orderInitState from \"@martyrs/src/modules/orders/store/models/order\"\n\n\nconst state = reactive({\n all: [], \n current: {\n ...orderInitState\n }\n});\n\nconst actions = {\n async create(order) {\n try {\n const response = await $axios.post('/api/orders/create', order);\n\n state.all.push(response.data);\n\n return response.data;\n } catch (error) {\n setError(error);\n }\n },\n\n async read( options = {}) {\n try {\n \n console.log('options is', options)\n const response = await $axios.get('/api/orders/read', { params: options });\n\n if (options._id) {\n set(response.data[0], 'current')\n } else {\n set(response.data, 'all')\n }\n\n return response.data; \n } catch (err) {\n setError(err)\n throw err;\n }\n },\n\n async update(order) {\n try {\n const response = await $axios.post(`/api/orders/update`, order);\n\n const index = state.all.findIndex(o => o._id === order._id);\n \n if (index !== -1) {\n state.all[index] = response.data;\n }\n\n return response.data; \n } catch (error) {\n setError(error);\n }\n },\n\n async delete(orderID) {\n try {\n await $axios.delete(`/api/orders/${orderID}`);\n state.all = state.all.filter(o => o._id !== orderID);\n } catch (error) {\n setError(error);\n }\n },\n\n async changePaymentStatus(orderID, status) {\n try {\n const response = await $axios.post(`/api/orders/payment/${orderID}`, { status });\n const index = state.all.findIndex(o => o._id === orderID);\n if (index !== -1) {\n state.all[index] = response.data;\n }\n } catch (error) {\n setError(error);\n }\n },\n}\n\nconst mutations = { \n updateRentDates({ positions, productId, dates }) {\n const product = positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n },\n\n\n addProductToCart(state, 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 price_currency: product.price_currency,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n },\n\n\n removeProduct(state, _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(state, _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 },\n\n\n incrementItemQuantity(state, _id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n }\n },\n\n\n resetCustomer(stateObject) { \n Object.assign(stateObject, customerInitState);\n }, \n resetOrder(stateObject) {\n state.current = { ...orderInitState }\n // Object.assign(stateObject, orderInitState);\n } \n}\n\nconst getters = {\n getTotal(positions) {\n return Number(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 getDeliveryPrice(type, distance = 0, config = {}) {\n if (type === 'pickup') return config.pickupCost || 0;\n if (type === 'mail') return config.mailCost || 300;\n\n if (type === 'courier') {\n const base = config.courierBase || 100;\n const perKm = config.courierPerKm || 20;\n const discount = config.courierDiscountFactor || 7.5;\n\n return Math.trunc(base + perKm * distance - discount * (distance / 10));\n }\n\n return 0;\n }\n}\n\nfunction set(eventData, property) { \n state[property] = eventData\n}\n\nconst history = []\n\nhistory.push(state) \n\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\nexport {\n state,\n actions,\n mutations,\n getters\n}"],"names":["state"],"mappings":";;;;AAUK,MAAC,QAAQ,SAAS;AAAA,EACrB,KAAK,CAAE;AAAA,EACP,SAAS;AAAA,IACP,GAAG;AAAA,EACP;AACA,CAAC;AAEI,MAAC,UAAU;AAAA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EjD,aAAO,KAAK,MAAM,OAAO,QAAQ,WAAW,YAAY,WAAW,GAAG;AAAA,IAC5E;AAEI,WAAO;AAAA,EACX;AACA;AAEA,SAAS,IAAI,WAAW,UAAU;AAChC,QAAM,QAAQ,IAAI;AACpB;AAMA,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;"}
1
+ {"version":3,"file":"orders.js","sources":["../../../../../../src/modules/orders/store/orders.js"],"sourcesContent":["// Dependencies\nimport { reactive, ref, computed, toRefs, watch } from \"vue\";\n// Setup Axios\nimport $axios from '@martyrs/src/modules/globals/views/utils/axios-instance.js';\n// Globals\nimport { setError } from '@martyrs/src/modules/globals/views/store/globals'\n// Init State\nimport orderInitState from \"@martyrs/src/modules/orders/store/models/order\"\n\n\nconst state = reactive({\n all: [], \n current: {\n ...orderInitState\n }\n});\n\nconst actions = {\n async create(order) {\n try {\n const response = await $axios.post('/api/orders/create', order);\n\n state.all.push(response.data);\n\n return response.data;\n } catch (error) {\n setError(error);\n }\n },\n\n async read( options = {}) {\n try {\n \n console.log('options is', options)\n const response = await $axios.get('/api/orders/read', { params: options });\n\n if (options._id) {\n set(response.data[0], 'current')\n } else {\n set(response.data, 'all')\n }\n\n return response.data; \n } catch (err) {\n setError(err)\n throw err;\n }\n },\n\n async update(order) {\n try {\n const response = await $axios.post(`/api/orders/update`, order);\n\n const index = state.all.findIndex(o => o._id === order._id);\n \n if (index !== -1) {\n state.all[index] = response.data;\n }\n\n return response.data; \n } catch (error) {\n setError(error);\n }\n },\n\n async delete(orderID) {\n try {\n await $axios.delete(`/api/orders/${orderID}`);\n state.all = state.all.filter(o => o._id !== orderID);\n } catch (error) {\n setError(error);\n }\n },\n\n async changePaymentStatus(orderID, status) {\n try {\n const response = await $axios.post(`/api/orders/payment/${orderID}`, { status });\n const index = state.all.findIndex(o => o._id === orderID);\n if (index !== -1) {\n state.all[index] = response.data;\n }\n } catch (error) {\n setError(error);\n }\n },\n}\n\nconst mutations = { \n updateRentDates({ positions, productId, dates }) {\n const product = positions.find(p => p._id === productId)\n\n if (product) {\n product.date = dates // Предполагается, что dates — объект { start, end }\n }\n },\n\n\n addProductToCart(state, 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 price_currency: product.price_currency,\n quantity: 1,\n date: date, \n org_id: organization, // Добавляем _id организации к каждому продукту\n });\n }\n },\n\n\n removeProduct(state, _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(state, _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 },\n\n\n incrementItemQuantity(state, _id) {\n const cartItem = state.positions.find(\n (item) => item._id === _id\n );\n\n if (cartItem) {\n cartItem.quantity++;\n }\n },\n\n\n resetCustomer(stateObject) { \n Object.assign(stateObject, customerInitState);\n }, \n resetOrder(stateObject) {\n state.current = { ...orderInitState }\n // Object.assign(stateObject, orderInitState);\n } \n}\n\nconst getters = {\n getTotal(positions) {\n return Number(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 getDeliveryPrice(type, distance = 0, config = {}) {\n if (type === 'pickup') return config.pickupCost || 0;\n if (type === 'post') return config.mailCost || 300;\n\n if (type === 'courier') {\n const base = config.courierBase || 100;\n const perKm = config.courierPerKm || 20;\n const discount = config.courierDiscountFactor || 7.5;\n\n return Math.trunc(base + perKm * distance - discount * (distance / 10));\n }\n\n return 0;\n }\n}\n\nfunction set(eventData, property) { \n state[property] = eventData\n}\n\nconst history = []\n\nhistory.push(state) \n\nwatch(state, (newState, oldState) => {\n history.push(newState)\n})\n\nexport {\n state,\n actions,\n mutations,\n getters\n}"],"names":["state"],"mappings":";;;;AAUK,MAAC,QAAQ,SAAS;AAAA,EACrB,KAAK,CAAE;AAAA,EACP,SAAS;AAAA,IACP,GAAG;AAAA,EACP;AACA,CAAC;AAEI,MAAC,UAAU;AAAA,EACd,MAAM,OAAO,OAAO;AAClB,QAAI;AACF,YAAM,WAAW,MAAM,OAAO,KAAK,sBAAsB,KAAK;AAE9D,YAAM,IAAI,KAAK,SAAS,IAAI;AAE5B,aAAO,SAAS;AAAA,IACjB,SAAQ,OAAO;AACd,eAAS,KAAK;AAAA,IACpB;AAAA,EACG;AAAA,EAEA,MAAM,KAAM,UAAU,IAAI;AACzB,QAAI;AAEF,cAAQ,IAAI,cAAc,OAAO;AACjC,YAAM,WAAW,MAAM,OAAO,IAAI,oBAAoB,EAAE,QAAQ,SAAS;AAEzE,UAAI,QAAQ,KAAK;AACf,YAAI,SAAS,KAAK,CAAC,GAAG,SAAS;AAAA,MACvC,OAAa;AACL,YAAI,SAAS,MAAM,KAAK;AAAA,MAChC;AAEM,aAAO,SAAS;AAAA,IACjB,SAAQ,KAAK;AACZ,eAAS,GAAG;AACZ,YAAM;AAAA,IACZ;AAAA,EACG;AAAA,EAED,MAAM,OAAO,OAAO;AAClB,QAAI;AACF,YAAM,WAAW,MAAM,OAAO,KAAK,sBAAsB,KAAK;AAE9D,YAAM,QAAQ,MAAM,IAAI,UAAU,OAAK,EAAE,QAAQ,MAAM,GAAG;AAE1D,UAAI,UAAU,IAAI;AAChB,cAAM,IAAI,KAAK,IAAI,SAAS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Q,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,EACN;AAAA,EACD,iBAAiB,MAAM,WAAW,GAAG,SAAS,CAAA,GAAI;AAChD,QAAI,SAAS,SAAU,QAAO,OAAO,cAAc;AACnD,QAAI,SAAS,OAAQ,QAAO,OAAO,YAAY;AAE/C,QAAI,SAAS,WAAW;AACtB,YAAM,OAAO,OAAO,eAAe;AACnC,YAAM,QAAQ,OAAO,gBAAgB;AACrC,YAAM,WAAW,OAAO,yBAAyB;AAEjD,aAAO,KAAK,MAAM,OAAO,QAAQ,WAAW,YAAY,WAAW,GAAG;AAAA,IAC5E;AAEI,WAAO;AAAA,EACX;AACA;AAEA,SAAS,IAAI,WAAW,UAAU;AAChC,QAAM,QAAQ,IAAI;AACpB;AAMA,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.vue2.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.vue2.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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/martyrs",
3
- "version": "0.2.446",
3
+ "version": "0.2.447",
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",
@@ -23,11 +23,11 @@
23
23
  <div>
24
24
  <p>
25
25
  <span class="t-second mn-r-micro d-inline-block t-demi">
26
- {{ product.price_currency || returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}
26
+ {{ returnCurrency() }}{{ (product.listing === 'rent' ? (rentalDays || product.quantity || 0) : (product.quantity || 0)) * product.price }}
27
27
  </span>
28
28
 
29
29
  <span class="p-small t-transp">
30
- <template v-if="product.quantity">{{product.price_currency || returnCurrency() }}{{product.price}} </template>
30
+ <template v-if="product.quantity">{{returnCurrency() }}{{product.price}} </template>
31
31
  ×
32
32
  <template v-if="product.listing === 'rent' && rentDates.start && rentDates.end">
33
33
  {{ rentalDays }} days
@@ -82,6 +82,7 @@
82
82
  || errorAddress
83
83
  || errorDelivery
84
84
  || errorPayment
85
+ || isLocationLoading
85
86
  "
86
87
  @click="handleCreate()"
87
88
  class="bg-main mn-b-small pd-small radius-big w-100 button"
@@ -136,7 +137,8 @@ import * as orders from '@martyrs/src/modules/orders/store/orders';
136
137
  import * as users from '@martyrs/src/modules/auth/views/store/users';
137
138
  ///////////////////////////////////////////////////////////////////////////////////////////////////
138
139
  // Variables and computed
139
- ///////////////////////////////////////////////////////////////////////////////////////////////////
140
+ //////////////////////////////////////////////////////////////////////////////////////////////////
141
+ const isLocationLoading = ref(false)
140
142
  // Accessing router and store
141
143
  const route = useRoute()
142
144
  const router = useRouter()
@@ -145,6 +147,7 @@ const order = computed(() => orders.state.current)
145
147
  const user = computed(() => users.state.current)
146
148
 
147
149
  const cartTotalPrice = shopcart.getters.cartTotalPrice
150
+
148
151
  const deliveryCost = computed(() => {
149
152
  const type = orders.state.current.delivery.type
150
153
  const distance = orderOrganization.value[0]?.distance || 0
@@ -162,7 +165,7 @@ if (!globals.state.options.orders.allowUnauthenticatedOrders && !auth.state.user
162
165
  }
163
166
 
164
167
  onMounted(async()=> {
165
-
168
+ isLocationLoading.value = true
166
169
 
167
170
  if (auth.state.user._id) {
168
171
  let data = await users.actions.read({ _id:auth.state.user._id, user: auth.state.user._id });
@@ -178,8 +181,30 @@ onMounted(async()=> {
178
181
  location: globals.state.position?.location,
179
182
  lookup: ['spots']
180
183
  })
184
+
185
+ isLocationLoading.value = false
181
186
  })
182
187
 
188
+
189
+ watch(
190
+ () => orders.state.current.delivery,
191
+ async (newVal) => {
192
+ if (newVal?.location) {
193
+ isLocationLoading.value = true
194
+
195
+ orderOrganization.value = await organizations.actions.read({
196
+ _id: shopcart.state.organization,
197
+ location: newVal.location,
198
+ lookup: ['spots']
199
+ })
200
+
201
+ isLocationLoading.value = false
202
+ }
203
+ },
204
+ { deep: true }
205
+ )
206
+
207
+
183
208
  /////////////////////////////
184
209
  // Store Verification
185
210
  /////////////////////////////
@@ -241,10 +266,6 @@ async function handleCreate() {
241
266
 
242
267
  orders.state.current.positions = shopcart.state.positions
243
268
 
244
- watch(() => shopcart.state.positions, (newVal) => {
245
- if (newVal) orders.state.current.positions === newVal
246
- })
247
-
248
269
  const referralCode = localStorage.getItem('referalCode');
249
270
 
250
271
  if (referralCode) {
@@ -185,7 +185,7 @@ const getters = {
185
185
  },
186
186
  getDeliveryPrice(type, distance = 0, config = {}) {
187
187
  if (type === 'pickup') return config.pickupCost || 0;
188
- if (type === 'mail') return config.mailCost || 300;
188
+ if (type === 'post') return config.mailCost || 300;
189
189
 
190
190
  if (type === 'courier') {
191
191
  const base = config.courierBase || 100;
@@ -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;;;;;;;;;;;;;;;;;"}