@ozdao/prometheus-framework 0.1.30 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/dist/BackofficeGallery-02c9721b.mjs +304 -0
  2. package/dist/BackofficeGallery-1d117a40.js +1 -0
  3. package/dist/BackofficeReports-cb4b180d.mjs +44 -0
  4. package/dist/BackofficeReports-d021871f.js +1 -0
  5. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-505c3ca5.js +1 -0
  6. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-b1873cb7.mjs +1945 -0
  7. package/dist/Button-2ca405bd.js +1 -0
  8. package/dist/Button-c59d387c.mjs +283 -0
  9. package/dist/Button.vue_vue_type_style_index_0_lang-0ea8fbf8.js +1 -0
  10. package/dist/Button.vue_vue_type_style_index_0_lang-4ed993c7.mjs +1 -0
  11. package/dist/ButtonFollow.vue_vue_type_style_index_0_scoped_0634d4a1_lang-0ea8fbf8.js +1 -0
  12. package/dist/ButtonFollow.vue_vue_type_style_index_0_scoped_0634d4a1_lang-4ed993c7.mjs +1 -0
  13. package/dist/CardOrganization-18c1e3fa.mjs +297 -0
  14. package/dist/CardOrganization-7d679e75.js +1 -0
  15. package/dist/Chips-2ada5eda.mjs +200 -0
  16. package/dist/Chips-8d0a1d2c.js +1 -0
  17. package/dist/Dashboard-239fb7a6.mjs +52 -0
  18. package/dist/Dashboard-94267906.js +1 -0
  19. package/dist/EULA-8265b0cf.mjs +4218 -0
  20. package/dist/EULA-cbb27503.js +1 -0
  21. package/dist/Feed-66095e66.js +1 -0
  22. package/dist/Feed-76fc4475.mjs +383 -0
  23. package/dist/Feed-e55bc6fa.js +1 -0
  24. package/dist/Feed-ef6c6ca3.mjs +371 -0
  25. package/dist/IconEdit-c98d3d06.mjs +339 -0
  26. package/dist/IconEdit-e4d0cc6e.js +1 -0
  27. package/dist/Image-052a3cc2.mjs +480 -0
  28. package/dist/Image-c90ee624.js +9 -0
  29. package/dist/MenuItem-0b249b94.mjs +93 -0
  30. package/dist/MenuItem-8b70d2cf.js +1 -0
  31. package/dist/Product-4b58701f.js +7 -0
  32. package/dist/Product-a6251018.mjs +844 -0
  33. package/dist/ProductEdit-3ff2af92.js +1 -0
  34. package/dist/ProductEdit-f901314c.mjs +306 -0
  35. package/dist/ProfileBlogposts-57931834.mjs +70 -0
  36. package/dist/ProfileBlogposts-af88ce98.js +1 -0
  37. package/dist/ProfileEvents-588eadf9.js +1 -0
  38. package/dist/ProfileEvents-ed7f9603.mjs +62 -0
  39. package/dist/ProfileOrganizations-7911deec.mjs +219 -0
  40. package/dist/ProfileOrganizations-ae258581.js +1 -0
  41. package/dist/Publics-50c0ff6c.js +1 -0
  42. package/dist/Publics-f34131bf.mjs +45 -0
  43. package/dist/Select-11ddabf5.mjs +79 -0
  44. package/dist/Select-3ca5ab39.js +1 -0
  45. package/dist/Socials-3fe01af1.mjs +275 -0
  46. package/dist/Socials-b19d0cb1.js +1 -0
  47. package/dist/addMembersQuantity-ea216f92.mjs +85 -0
  48. package/dist/addMembersQuantity-f922d82b.js +84 -0
  49. package/dist/auth-98fe3efb.mjs +612 -0
  50. package/dist/auth-acbe3ae1.js +7 -0
  51. package/dist/auth.client.cjs +7 -8
  52. package/dist/auth.client.js +435 -439
  53. package/dist/auth.validation-495e9d6d.js +1 -0
  54. package/dist/auth.validation-e265b496.mjs +23 -0
  55. package/dist/backoffice.client.cjs +1 -1
  56. package/dist/backoffice.client.js +55 -28
  57. package/dist/click-outside-0b0727d1.js +2 -0
  58. package/dist/click-outside-6101836c.mjs +19 -0
  59. package/dist/community.client.cjs +1 -1
  60. package/dist/community.client.js +121 -121
  61. package/dist/community.server.js +35 -5
  62. package/dist/community.server.mjs +35 -5
  63. package/dist/components/Button/Button.vue.d.ts +3 -0
  64. package/dist/components/Button/Button.vue.d.ts.map +1 -1
  65. package/dist/components/CardHeader/CardHeader.vue.d.ts +3 -0
  66. package/dist/components/Dropdown/Dropdown.vue.d.ts +3 -0
  67. package/dist/components/Dropdown/Dropdown.vue.d.ts.map +1 -1
  68. package/dist/components/Field/Field.vue.d.ts +1 -1
  69. package/dist/components/FieldPhone/FieldPhone(script-setup).vue.d.ts +3 -3
  70. package/dist/components/Popup/Popup.vue.d.ts +2 -1
  71. package/dist/components/Popup/Popup.vue.d.ts.map +1 -1
  72. package/dist/components/Select/Select.vue.d.ts +1 -1
  73. package/dist/components/Select/Select.vue.d.ts.map +1 -1
  74. package/dist/components/Upload/Upload.vue.d.ts +1 -1
  75. package/dist/events.client.cjs +2 -2
  76. package/dist/events.client.js +219 -217
  77. package/dist/events.server.js +2 -9
  78. package/dist/events.server.mjs +2 -9
  79. package/dist/legal.client.cjs +1 -1
  80. package/dist/legal.client.js +2565 -2545
  81. package/dist/main.css +1 -1
  82. package/dist/main.d.ts +1 -1
  83. package/dist/modules/backoffice/components/pages/Dashboard.vue.d.ts +6 -0
  84. package/dist/modules/icons/navigation/IconCross.vue.d.ts +4 -0
  85. package/dist/modules/legal/components/pages/legal/EULA.vue.d.ts +2 -0
  86. package/dist/modules/organizations/components/elements/ButtonFollow.vue.d.ts +1 -1
  87. package/dist/modules/organizations/components/elements/ButtonToggleMembership.vue.d.ts +12 -0
  88. package/dist/modules/organizations/components/sections/DetailsTab.vue.d.ts +2 -58
  89. package/dist/modules/organizations/components/sections/Feed.vue.d.ts +1 -1
  90. package/dist/modules/reports/components/pages/BackofficeReports.vue.d.ts +2 -0
  91. package/dist/modules/reports/components/sections/FormReport.vue.d.ts +75 -0
  92. package/dist/modules/reports/store/reports.d.ts +41 -0
  93. package/dist/organizations-a241b21d.js +1 -0
  94. package/dist/organizations-ea9de495.mjs +122 -0
  95. package/dist/organizations.client-292e8444.js +3 -0
  96. package/dist/organizations.client-6fc91683.mjs +3072 -0
  97. package/dist/organizations.client.cjs +1 -1
  98. package/dist/organizations.client.js +51 -49
  99. package/dist/organizations.server.js +20 -28
  100. package/dist/organizations.server.mjs +20 -28
  101. package/dist/prometheus-framework.cjs.js +19 -19
  102. package/dist/prometheus-framework.es.js +1635 -1608
  103. package/dist/reports-270f69df.js +1 -0
  104. package/dist/reports-79cd9459.mjs +91 -0
  105. package/dist/reports.client.cjs +1 -0
  106. package/dist/reports.client.js +8 -0
  107. package/dist/reports.server.js +159 -0
  108. package/dist/reports.server.mjs +160 -0
  109. package/dist/states.validation-02ba0aee.js +1 -0
  110. package/dist/states.validation-e5f4fa3a.mjs +13 -0
  111. package/dist/style.css +1 -1
  112. package/dist/users.client.cjs +1 -1
  113. package/dist/users.client.js +286 -242
  114. package/dist/users.server.js +6 -18
  115. package/dist/users.server.mjs +6 -18
  116. package/package.json +9 -1
  117. package/src/components/Button/Button.vue +66 -60
  118. package/src/components/CardHeader/CardHeader.vue +51 -50
  119. package/src/components/Dropdown/Dropdown.vue +28 -12
  120. package/src/components/FieldPhone/click-outside.js +0 -48
  121. package/src/components/Popup/Popup.vue +74 -23
  122. package/src/components/Select/Select.vue +10 -6
  123. package/src/main.ts +1 -1
  124. package/src/modules/auth/components/pages/EnterPassword.vue +6 -0
  125. package/src/modules/auth/router/auth.js +1 -1
  126. package/src/modules/auth/store/auth.js +1 -1
  127. package/src/modules/backoffice/components/layouts/Backoffice.vue +3 -3
  128. package/src/modules/backoffice/components/pages/Dashboard.vue +62 -0
  129. package/src/modules/backoffice/router/backoffice.js +26 -0
  130. package/src/modules/community/components/blocks/CardBlogpost.vue +3 -0
  131. package/src/modules/community/components/layouts/Community.vue +4 -4
  132. package/src/modules/community/components/pages/CreateBlogPost.vue +27 -28
  133. package/src/modules/community/components/sections/Comments.vue +4 -2
  134. package/src/modules/community/components/sections/Feed.vue +1 -1
  135. package/src/modules/community/controllers/blog.controller.js +22 -3
  136. package/src/modules/community/controllers/comments.controller.js +23 -5
  137. package/src/modules/events/components/blocks/CardEvent.vue +4 -0
  138. package/src/modules/events/components/pages/EditEvent.vue +27 -28
  139. package/src/modules/events/components/sections/Feed.vue +1 -1
  140. package/src/modules/events/controllers/events.controller.js +3 -10
  141. package/src/modules/gallery/components/sections/BackofficeGallery.vue +7 -23
  142. package/src/modules/icons/navigation/IconCross.vue +22 -0
  143. package/src/modules/legal/components/pages/Legal.vue +3 -0
  144. package/src/modules/legal/components/pages/legal/EULA.vue +2148 -0
  145. package/src/modules/legal/router/legal.js +11 -4
  146. package/src/modules/middlewares/client/auth.validation.js +14 -0
  147. package/src/modules/mobile/components/Menu/Menu.vue +1 -1
  148. package/src/modules/organizations/components/blocks/CardOrganization.vue +1 -1
  149. package/src/modules/organizations/components/elements/ButtonFollow.vue +9 -7
  150. package/src/modules/organizations/components/elements/ButtonToggleMembership.vue +101 -0
  151. package/src/modules/organizations/components/pages/Organization.vue +1 -34
  152. package/src/modules/organizations/components/sections/DetailsTab.vue +86 -8
  153. package/src/modules/organizations/controllers/memberships.controller.js +10 -7
  154. package/src/modules/organizations/controllers/organizations.controller.js +9 -20
  155. package/src/modules/organizations/controllers/utils/addMembersQuantity.js +21 -0
  156. package/src/modules/organizations/controllers/utils/addUserStatusFields.js +65 -0
  157. package/src/modules/organizations/controllers/utils/excludeBlockedMembers.js +18 -0
  158. package/src/modules/organizations/models/membership.model.js +5 -5
  159. package/src/modules/organizations/store/memberships.js +6 -6
  160. package/src/modules/organizations/store/organizations.js +0 -1
  161. package/src/modules/products/products.server.js +5 -0
  162. package/src/modules/reports/components/pages/BackofficeReports.vue +67 -0
  163. package/src/modules/reports/components/sections/FormReport.vue +114 -0
  164. package/src/modules/reports/controllers/reports.controller.js +67 -0
  165. package/src/modules/reports/models/report.model.js +58 -0
  166. package/src/modules/reports/reports.client.js +17 -0
  167. package/src/modules/reports/reports.server.js +13 -0
  168. package/src/modules/reports/routes/reports.routes.js +43 -0
  169. package/src/modules/reports/store/reports.js +118 -0
  170. package/src/modules/users/components/pages/Profile.vue +57 -10
  171. package/src/modules/users/controllers/users.controller.js +6 -19
  172. package/src/styles/base/all.scss +2 -0
  173. package/src/styles/layout.scss +39 -63
  174. package/src/styles/theme.scss +0 -1
  175. package/src/styles/components/popup.scss +0 -55
@@ -7,7 +7,6 @@ const legal = [
7
7
  en: 'Legal',
8
8
  ru: 'Юридическая информация'
9
9
  },
10
- authorize: []
11
10
  },
12
11
  component: () => import(/* webpackChunkName: 'Legal' */ '../components/pages/Legal.vue'),
13
12
  },
@@ -19,7 +18,6 @@ const legal = [
19
18
  en: 'Privacy Policy',
20
19
  ru: 'Политика конфиденциальности'
21
20
  },
22
- authorize: []
23
21
  },
24
22
  component: () => import(/* webpackChunkName: 'Privacy' */ '../components/pages/legal/Privacy.vue'),
25
23
  },
@@ -31,7 +29,6 @@ const legal = [
31
29
  en: 'Terms of Use',
32
30
  ru: 'Условия использования'
33
31
  },
34
- authorize: []
35
32
  },
36
33
  component: () => import(/* webpackChunkName: 'Terms' */ '../components/pages/legal/Terms.vue'),
37
34
  },
@@ -43,9 +40,19 @@ const legal = [
43
40
  en: 'Cookie Policy',
44
41
  ru: 'Политика Сookies'
45
42
  },
46
- authorize: []
47
43
  },
48
44
  component: () => import(/* webpackChunkName: 'Cookies' */ '../components/pages/legal/Cookies.vue'),
45
+ },
46
+ {
47
+ path: 'legal/eula',
48
+ name: 'EULA',
49
+ meta: {
50
+ title: {
51
+ en: 'EULA',
52
+ ru: 'EULA'
53
+ },
54
+ },
55
+ component: () => import(/* webpackChunkName: 'Cookies' */ '../components/pages/legal/EULA.vue'),
49
56
  }
50
57
  ];
51
58
 
@@ -15,6 +15,19 @@ function requiresAuth(to, from, next) {
15
15
  next();
16
16
  }
17
17
 
18
+ function requiresAdmin(to, from, next) {
19
+
20
+ const isAdmin = auth.state.access.roles.includes('ROLE_ADMIN');
21
+
22
+ if (isAdmin !== true) {
23
+ return next('/404');
24
+ }
25
+
26
+ next();
27
+ }
28
+
29
+
30
+
18
31
  function requiresNoAuth(to, from, next) {
19
32
  const isLogin = auth.state.access.status;
20
33
  // to.meta.requiresNoAuth
@@ -26,6 +39,7 @@ function requiresNoAuth(to, from, next) {
26
39
  }
27
40
 
28
41
  export {
42
+ requiresAdmin,
29
43
  requiresAuth,
30
44
  requiresNoAuth
31
45
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <section class="mobile-menu-section mn-semi pd-r-zero pd-t-thin pd-b-thin pd-medium radius-medium">
2
+ <section class="mobile-menu-section pd-r-zero pd-t-thin pd-b-thin pd-medium radius-medium">
3
3
  <slot></slot>
4
4
  </section>
5
5
  </template>
@@ -36,7 +36,7 @@
36
36
  </div>
37
37
 
38
38
  <div>
39
- <p class="mn-thin ">{{organization.numberOfMemberships}} followers</p>
39
+ <p class="mn-thin ">{{organization.numberOfSubscribers}} followers</p>
40
40
 
41
41
  <ButtonFollow
42
42
  v-if="user._id"
@@ -3,7 +3,7 @@
3
3
  :submit="toggleFollow"
4
4
  class="bg-main button-small button"
5
5
  >
6
- {{ isMember ? 'Unfollow' : 'Follow' }}
6
+ {{ status ? 'Unfollow' : 'Follow' }}
7
7
  </Button>
8
8
  </template>
9
9
 
@@ -25,7 +25,7 @@
25
25
  type: String,
26
26
  required: true
27
27
  },
28
- isMember: {
28
+ status: {
29
29
  type: Boolean,
30
30
  required: true
31
31
  },
@@ -36,7 +36,7 @@
36
36
  });
37
37
 
38
38
  const toggleFollow = async () => {
39
- if (props.isMember) {
39
+ if (props.status) {
40
40
  await unfollowPublic(props.targetId);
41
41
  } else {
42
42
  await followPublic(props.targetId);
@@ -48,11 +48,12 @@
48
48
  const membershipData = {
49
49
  type: props.type,
50
50
  target: targetId,
51
- user: props.userId
51
+ user: props.userId,
52
+ role: 'subscriber'
52
53
  };
53
54
 
54
55
  const response = await memberships.actions.create(membershipData);
55
- emits('updateMembership', { membership: response, isMember: true, targetId: props.targetId });
56
+ emits('updateMembership', { membership: response, status: true, targetId: props.targetId });
56
57
  } catch (error) {
57
58
  console.log(error)
58
59
  throw error;
@@ -63,12 +64,13 @@
63
64
  const membershipData = {
64
65
  type: props.type,
65
66
  target: targetId,
66
- user: props.userId
67
+ user: props.userId,
68
+ role: 'subscriber'
67
69
  };
68
70
 
69
71
  try {
70
72
  const response = await memberships.actions.delete(membershipData);
71
- emits('updateMembership', { membership: response, isMember: false, targetId: props.targetId });
73
+ emits('updateMembership', { membership: response, status: false, targetId: props.targetId });
72
74
  } catch (error) {
73
75
  console.log(error)
74
76
  throw error;
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <Button
3
+ :submit="toggleMembership"
4
+ :showSucces="false"
5
+ class="button-small button"
6
+ >
7
+ {{ !status ? props.text.create : props.text.remove }}
8
+ </Button>
9
+ </template>
10
+
11
+ <script setup>
12
+ import Button from "@pf/src/components/Button/Button.vue";
13
+
14
+ import { ref } from 'vue'
15
+ import * as auth from '@pf/src/modules/auth/store/auth'
16
+ import * as memberships from '@pf/src/modules/organizations/store/memberships'
17
+
18
+ const emits = defineEmits(['updateMembership'])
19
+
20
+ const props = defineProps({
21
+ user: {
22
+ type: String,
23
+ required: true
24
+ },
25
+ type: {
26
+ type: String,
27
+ required: true
28
+ },
29
+ role: {
30
+ type: String,
31
+ required: false
32
+ },
33
+ target: {
34
+ type: String,
35
+ required: true
36
+ },
37
+ text: {
38
+ type: Object,
39
+ default: {
40
+ create: 'join',
41
+ remove: 'leave'
42
+ }
43
+ },
44
+ status: {
45
+ type: Boolean,
46
+ required: true
47
+ }
48
+ });
49
+
50
+ const toggleMembership = async () => {
51
+ if (!props.status) {
52
+ await createMembership();
53
+ } else {
54
+ await removeMembership();
55
+ }
56
+ }
57
+
58
+ async function createMembership() {
59
+ try {
60
+ const membershipData = {
61
+ user: props.user,
62
+ type: props.type,
63
+ role: props.role,
64
+ target: props.target
65
+ };
66
+
67
+ const response = await memberships.actions.create(membershipData);
68
+
69
+ emits('updateMembership', {
70
+ membership: response,
71
+ target: props.target,
72
+ status: true,
73
+ });
74
+ } catch (error) {
75
+ console.log(error)
76
+ throw error;
77
+ }
78
+ }
79
+
80
+ async function removeMembership(targetId) {
81
+ const membershipData = {
82
+ user: props.user,
83
+ type: props.type,
84
+ role: props.role,
85
+ target: props.target
86
+ };
87
+
88
+ try {
89
+ const response = await memberships.actions.delete(membershipData);
90
+
91
+ emits('updateMembership', {
92
+ membership: response,
93
+ target: props.target,
94
+ status: false,
95
+ });
96
+ } catch (error) {
97
+ console.log(error)
98
+ throw error;
99
+ }
100
+ }
101
+ </script>
@@ -11,31 +11,7 @@
11
11
  :organization="organization.state.current"
12
12
  :user="auth.state.user"
13
13
  class="mn-semi"
14
- >
15
-
16
- <p
17
- class="t-semi mn-small"
18
- >
19
- <!-- 👍 3 212 likes · -->
20
- <!-- 💬 342 comments · -->
21
- 👨‍👨‍👧‍👧 {{organization.state.current.numberOfMemberships}} followers
22
- </p>
23
-
24
- <ButtonFollow
25
- v-if="
26
- auth.state.user._id
27
- && route.params._id
28
- && route.params._id !== auth.state.user._id
29
- && organization.state.current.owner !== auth.state.user._id
30
- "
31
- :type="'organization'"
32
- :isMember="organization.state.current.isMember"
33
- :targetId="organization.state.current._id"
34
- :userId="auth.state.user._id"
35
- class="w-min mn-auto"
36
- @updateMembership="handleMembershipUpdate"
37
- />
38
- </DetailsTab>
14
+ />
39
15
 
40
16
  <!-- { name: 'Spots', value: 'spots' }, -->
41
17
  <!-- { name: 'Products', value: 'products' }, -->
@@ -48,8 +24,6 @@
48
24
  ]"
49
25
  class="mn-small o-hidden h5 radius-big bg-grey"
50
26
  />
51
-
52
-
53
27
 
54
28
  <transition name="slide-fade">
55
29
  <Feed
@@ -132,13 +106,6 @@
132
106
  watch(tabOrganization, (newValue) => {
133
107
  router.replace({ query: { ...route.query, tab: newValue } });
134
108
  });
135
- // Get organization _id from cookie
136
- // Async requests
137
-
138
-
139
- const handleMembershipUpdate = ({ membership, isMember, targetId }) => {
140
- memberships.mutations.handleMembershipUpdate(organization.state.current, membership, isMember, targetId)
141
- };
142
109
  </script>
143
110
 
144
111
  <style lang="scss">
@@ -2,6 +2,43 @@
2
2
  <transition name="slide-fade">
3
3
  <section class="t-center flex-center flex-column flex pd-medium radius-big bg-grey">
4
4
 
5
+ <Dropdown
6
+ v-if="user._id !== organization.owner"
7
+ :label="'...'"
8
+ :align="'right'"
9
+ class="cursor-pointer pos-absolute pos-r-0 pos-t-0 pd-thin radius-extra "
10
+ >
11
+ <section
12
+ class="bg-black pd-thin radius-small"
13
+ >
14
+ <FormReport
15
+ :user="user._id"
16
+ :type="'organization'"
17
+ :target="organization._id"
18
+ :text="'Report'"
19
+ class="w-100"
20
+ >
21
+ <button
22
+ class="w-100 bg-black br-solid br-1px br-white-transp-20 t-white button-small button"
23
+ >
24
+ Report
25
+ </button>
26
+ </FormReport>
27
+
28
+ <ButtonToggleMembership
29
+ v-if="user._id && user._id !== organization.owner"
30
+ :user="user._id"
31
+ :type="'organization'"
32
+ :role="'blocked'"
33
+ :target="organization._id"
34
+ :status="organization.isBlocked"
35
+ :text="{create: 'Block', remove: 'Unblock'}"
36
+ @updateMembership="event => handleMembershipUpdate(event, 'isBlocked')"
37
+ class="t-white mn-t-thin bg-red"
38
+ />
39
+ </section>
40
+ </Dropdown>
41
+
5
42
  <IconEdit
6
43
  v-if="user._id === organization.owner"
7
44
  @click="$router.push({
@@ -42,7 +79,30 @@
42
79
  </span>
43
80
  </div>
44
81
 
45
- <slot></slot>
82
+ <p
83
+ class="t-semi mn-small"
84
+ >
85
+ <!-- 👍 3 212 likes · -->
86
+ <!-- 💬 342 comments · -->
87
+ 👨‍👨‍👧‍👧 {{organization.numberOfSubscribers}} followers
88
+ </p>
89
+
90
+ <ButtonToggleMembership
91
+ v-if="
92
+ user._id
93
+ && route.params._id
94
+ && route.params._id !== user._id
95
+ && organization.owner !== user._id
96
+ "
97
+ :user="user._id"
98
+ :type="'organization'"
99
+ :role="'subscriber'"
100
+ :target="organization._id"
101
+ :status="organization.isSubscriber"
102
+ :text="{create: 'Follow', remove: 'Unfollow'}"
103
+ @updateMembership="event => handleMembershipUpdate(event, 'isSubscriber', 'numberOfSubscribers')"
104
+ class="w-min mn-medium mn-r-auto mn-l-auto"
105
+ />
46
106
 
47
107
  <h4
48
108
  v-if="Object.values(organization.socials).some(value => value)"
@@ -81,18 +141,36 @@
81
141
 
82
142
  <script setup>
83
143
  import { ref, computed } from 'vue'
84
-
85
- import Contacts from '@pf/src/modules/organizations/components/blocks/Contacts.vue'
86
- import Rating from '@pf/src/modules/organizations/components/blocks/Rating.vue'
87
- import Socials from '@pf/src/modules/organizations/components/blocks/Socials.vue'
88
-
144
+ import { useRoute, useRouter } from 'vue-router'
145
+ // Import components
146
+ import Dropdown from "@pf/src/components/Dropdown/Dropdown.vue";
89
147
  import Text from '@pf/src/components/Text/Text.vue'
90
-
148
+ // Icons
91
149
  import IconEdit from '@pf/src/modules/icons/navigation/IconEdit.vue'
92
150
  import PlaceholderUserpic from '@pf/src/modules/icons/placeholders/PlaceholderUserpic.vue'
93
-
151
+ // Org Module
152
+ import ButtonToggleMembership from '@pf/src/modules/organizations/components/elements/ButtonToggleMembership.vue'
153
+ import Contacts from '@pf/src/modules/organizations/components/blocks/Contacts.vue'
154
+ import Rating from '@pf/src/modules/organizations/components/blocks/Rating.vue'
155
+ import Socials from '@pf/src/modules/organizations/components/blocks/Socials.vue'
156
+ // Report Module
157
+ import FormReport from '@pf/src/modules/reports/components/sections/FormReport.vue'
158
+ // Store
159
+ import * as organizations from '@pf/src/modules/organizations/store/organizations'
160
+ import * as memberships from '@pf/src/modules/organizations/store/memberships'
161
+ // ///////////////////////////////////////
162
+ // Components Props
163
+ // ///////////////////////////////////////
94
164
  const props = defineProps({
95
165
  organization: Object,
96
166
  user: Object
97
167
  })
168
+ // Store
169
+ const route = useRoute()
170
+
171
+ // Methods
172
+ const handleMembershipUpdate = ({ membership, status, target }, statusName, statusNumber) => {
173
+ memberships.mutations.handleMembershipUpdate(organizations.state.current, membership, status, target, statusName, statusNumber)
174
+ };
175
+
98
176
  </script>
@@ -34,6 +34,8 @@ const controllerFactory = (db) => {
34
34
  };
35
35
 
36
36
  const create = async (req, res) => {
37
+
38
+ console.log(req.body)
37
39
  const newMembership = new Membership({
38
40
  user: req.body.user,
39
41
  type: req.body.type,
@@ -62,19 +64,20 @@ const controllerFactory = (db) => {
62
64
  };
63
65
 
64
66
  const deleteMembership = async (req, res) => {
65
- const { type, target, user } = req.body;
67
+ const { type, target, user, role } = req.body;
68
+
69
+
70
+ console.log(req.body)
66
71
 
67
72
  try {
68
- const membership = await Membership.findOne({ type, target, user });
73
+ const membership = await Membership.findOne({ type, target, user, role });
69
74
 
70
75
  if (!membership) {
71
76
  return res.status(404).send({ errorCode: 'MEMBERSHIP_NOT_FOUND' });
77
+ } else {
78
+ await Membership.deleteOne({ _id: membership._id });
79
+ res.status(200).send(membership);
72
80
  }
73
-
74
- console.log(membership)
75
- await membership.remove();
76
-
77
- res.status(200).send(membership);
78
81
  } catch (error) {
79
82
  console.log(error)
80
83
  res.status(500).send({ errorCode: 'SERVER_ERROR' });
@@ -5,6 +5,10 @@ const { uuid } = require('uuidv4');
5
5
  const ObjectId = require('mongoose').Types.ObjectId;
6
6
  const { Client } = require('@googlemaps/google-maps-services-js');
7
7
  const client = new Client({});
8
+
9
+ const addUserStatusFields = require('@pf/src/modules/organizations/controllers/utils/addUserStatusFields');
10
+ const addMembersQuantity = require('@pf/src/modules/organizations/controllers/utils/addMembersQuantity');
11
+
8
12
  const parseCookie = require('@pf/src/modules/globals/utils/parseCookie'); // Assuming this is your utility function for parsing cookies
9
13
 
10
14
  const controllerFactory = (db) => {
@@ -158,25 +162,8 @@ const controllerFactory = (db) => {
158
162
  as: "memberships"
159
163
  }
160
164
  },
161
- {
162
- $addFields: {
163
- numberOfMemberships: { $size: '$memberships' }
164
- }
165
- },
166
- {
167
- $addFields: {
168
- isMember: {
169
- $cond: {
170
- if: req.query.user,
171
- then: {
172
- $in: [ new ObjectId(req.query.user), "$memberships.user" ]
173
- },
174
- else: "$$REMOVE"
175
- }
176
- }
177
- }
178
- },
179
-
165
+ addMembersQuantity(),
166
+ addUserStatusFields(req.query.user),
180
167
  {
181
168
  $addFields: {
182
169
  numberOfProducts: { $size: '$products' }
@@ -193,9 +180,11 @@ const controllerFactory = (db) => {
193
180
  rating: 1,
194
181
  socials: 1,
195
182
  numberOfProducts: 1,
196
- numberOfMemberships: 1,
183
+ numberOfSubscribers: 1,
197
184
  memberships: 1,
198
185
  isMember: 1,
186
+ isSubscriber: 1,
187
+ isBlocked: 1,
199
188
  departments: 1
200
189
  }
201
190
  },
@@ -0,0 +1,21 @@
1
+ // userStatus.js
2
+
3
+ const { ObjectId } = require('mongodb'); // Make sure to import ObjectId correctly from your MongoDB driver
4
+
5
+ const addMembersQuantity= (user) => {
6
+ return {
7
+ $addFields: {
8
+ numberOfSubscribers: {
9
+ $size: {
10
+ $filter: {
11
+ input: '$memberships',
12
+ as: 'membership',
13
+ cond: { $eq: ['$$membership.role', 'subscriber'] } // здесь мы проверяем, что роль должна быть "subscriber"
14
+ }
15
+ }
16
+ }
17
+ }
18
+ };
19
+ }
20
+
21
+ module.exports = addMembersQuantity;
@@ -0,0 +1,65 @@
1
+ const { ObjectId } = require('mongodb');
2
+
3
+ const addUserStatusFields = (user) => {
4
+ return {
5
+ $addFields: {
6
+ isSubscriber: {
7
+ $cond: {
8
+ if: {
9
+ $and: [
10
+ user,
11
+ {
12
+ $in: [new ObjectId(user), "$memberships.user"],
13
+ },
14
+ {
15
+ $in: ["subscriber", "$memberships.role"],
16
+ },
17
+ ],
18
+ },
19
+ then: true,
20
+ else: false,
21
+ },
22
+ },
23
+ isMember: {
24
+ $cond: {
25
+ if: {
26
+ $and: [
27
+ user,
28
+ {
29
+ $in: [new ObjectId(user), "$memberships.user"],
30
+ },
31
+ {
32
+ $not: [
33
+ {
34
+ $in: ["$memberships.role", ["subscriber", "blocked"]],
35
+ },
36
+ ],
37
+ },
38
+ ],
39
+ },
40
+ then: true,
41
+ else: false,
42
+ },
43
+ },
44
+ isBlocked: {
45
+ $cond: {
46
+ if: {
47
+ $and: [
48
+ user,
49
+ {
50
+ $in: [new ObjectId(user), "$memberships.user"],
51
+ },
52
+ {
53
+ $in: ["blocked", "$memberships.role"],
54
+ },
55
+ ],
56
+ },
57
+ then: true,
58
+ else: false,
59
+ },
60
+ },
61
+ },
62
+ };
63
+ }
64
+
65
+ module.exports = addUserStatusFields;
@@ -0,0 +1,18 @@
1
+ async function getBlockedMembers(Membership, userId) {
2
+ const memberships = await Membership.find({ user: userId });
3
+ return memberships
4
+ .filter(membership => membership.role === 'blocked')
5
+ .map(membership => membership.target);
6
+ }
7
+
8
+ function addConditionsForBlocked(matchStage, field, blockedMembers) {
9
+ const conditionsForBlocked = { "$nin": blockedMembers };
10
+
11
+ if (matchStage[field]) {
12
+ matchStage[field] = { "$eq": matchStage[field], ...conditionsForBlocked };
13
+ } else {
14
+ matchStage[field] = conditionsForBlocked;
15
+ }
16
+ }
17
+
18
+ module.exports = { getBlockedMembers, addConditionsForBlocked };
@@ -11,6 +11,10 @@ module.exports = (mongoose) => {
11
11
  default: 'organization',
12
12
  required: true,
13
13
  },
14
+ role: {
15
+ type: String,
16
+ default: 'subscriber'
17
+ },
14
18
  target: { // заменяем 'organization' на 'target', так как это может быть или User, или Organization
15
19
  type: mongoose.Schema.Types.ObjectId,
16
20
  ref: function (value) {
@@ -18,11 +22,7 @@ module.exports = (mongoose) => {
18
22
  if (this.type === 'organization') return 'Organization';
19
23
  },
20
24
  required: true,
21
- },
22
- role: {
23
- type: String,
24
- default: 'subscriber'
25
- },
25
+ }
26
26
  });
27
27
 
28
28
  const Membership = mongoose.model('Membership', MembershipSchema);
@@ -65,7 +65,7 @@ const actions = {
65
65
  };
66
66
 
67
67
  const mutations = {
68
- handleMembershipUpdate(data, membership, isMember) {
68
+ handleMembershipUpdate(data, membership, status, target, statusName, statusNumber) {
69
69
  let entity;
70
70
 
71
71
  if (Array.isArray(data)) {
@@ -77,23 +77,23 @@ const mutations = {
77
77
  }
78
78
 
79
79
  if (entity) {
80
- entity.isMember = isMember;
80
+ entity[statusName] = status;
81
81
 
82
- if (isMember) {
82
+ if (status) {
83
83
  entity.memberships.push(membership);
84
- entity.numberOfMemberships += 1;
84
+ entity[statusNumber] += 1;
85
85
  } else {
86
86
  const index = entity.memberships.findIndex(m => m._id === membership._id);
87
+
87
88
  if (index !== -1) {
88
89
  entity.memberships.splice(index, 1);
89
- entity.numberOfMemberships -= 1;
90
+ entity[statusNumber] -= 1;
90
91
  }
91
92
  }
92
93
  }
93
94
  }
94
95
  }
95
96
 
96
-
97
97
  // History
98
98
  const history = [];
99
99
  history.push(state);
@@ -140,7 +140,6 @@ const actions = {
140
140
 
141
141
  // Check if we are fetching a single organization or all organizations
142
142
  if (options._id) {
143
- console.log(response.data)
144
143
  Object.assign(state.current || {}, response.data[0])
145
144
  console.log(state.current) // Assuming that the response.data is the organization object
146
145
  } else {