@ozdao/prometheus-framework 0.2.62 → 0.2.63

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.2.62",
3
+ "version": "0.2.63",
4
4
  "description": "Web3 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",
@@ -157,7 +157,8 @@ watch(() => props.options, (newVal, oldVal) => {
157
157
  newVal.delivery !== oldVal.delivery ||
158
158
  newVal.search !== oldVal.search ||
159
159
  newVal.status !== oldVal.status ||
160
- newVal.hidden !== oldVal.hidden
160
+ newVal.hidden !== oldVal.hidden ||
161
+ newVal.type !== oldVal.type
161
162
  ) {
162
163
  fetchItems();
163
164
  }
@@ -1,90 +1,91 @@
1
1
  <template>
2
- <header class="mn-b-medium gap-small flex-v-center flex-nowrap flex">
3
- <h2 class="">{{route.params.leftover ? 'Edit ' : 'Add ' }} Inventory</h2>
4
-
5
- <Select
6
- v-model:select="leftovers.state.current.type"
7
- :options="[
8
- 'stock-in',
9
- 'stock-out',
10
- 'write-off'
11
- ]"
12
- :placeholder="'Select type'"
13
- class="bg-main t-black w-max pd-small t-semi p-big uppercase radius-small"
14
- />
15
- </header>
16
-
17
- <Block
18
- title="Add Position"
19
- class="mn-b-semi"
20
- >
21
- <CardPosition
22
- @add="(item) => globals.actions.add(
23
- leftovers.state.current.positions,
24
- item
25
- )"
26
- :products="Products"
27
- />
28
- </Block>
29
-
30
- <Block
31
- title="Invetory Sheet"
32
- placeholder="No positions added yet"
33
- class="mn-b-semi"
34
- >
35
- <CardPosition
36
- v-for="(product, index) in leftovers.state.current.positions"
37
- :key="product._id"
38
- :product="product"
39
- :array="leftovers.state.current.positions"
40
- :products="Products"
41
- @add="(item) => globals.actions.add(
42
- leftovers.state.current.positions,
43
- item
44
- )"
45
- @update="(item) => globals.actions.update(
46
- leftovers.state.current.positions,
47
- item,
48
- index
49
- )"
50
- @delete="(item) => globals.actions.delete(
51
- leftovers.state.current.positions,
52
- item,
53
- index
54
- )"
55
- />
56
- </Block>
57
-
58
- <Block class="">
59
- <section class="gap-thin flex-v-center flex-nojustify flex">
60
-
61
- <h3 class="mn-r-auto">
62
- In total: {{formatPrice(totalPrice)}}
63
- </h3>
64
-
65
- <a
66
- @click="onSubmit()"
67
- class="bg-main button"
68
- >
69
- Save
70
- </a>
71
-
72
- <a
73
- class="t-white bg-second button"
74
- @click="onReset()"
75
- >
76
- Reset
77
- </a>
78
-
79
- <a
80
- v-if="route.params.leftover"
81
- @click="onDelete()"
82
- class="t-white bg-red button"
83
- >
84
- Delete
85
- </a>
86
- </section>
87
- </Block>
2
+ <div class="pd-thin">
3
+ <header class="mn-b-medium gap-small flex-v-center flex-nowrap flex">
4
+ <h2 class="">{{route.params.leftover ? 'Edit ' : 'Add ' }} Inventory</h2>
5
+
6
+ <Select
7
+ v-model:select="leftovers.state.current.type"
8
+ :options="[
9
+ 'stock-in',
10
+ 'stock-out'
11
+ ]"
12
+ :placeholder="'Select type'"
13
+ class="bg-main t-black w-max pd-small t-semi p-big uppercase radius-small"
14
+ />
15
+ </header>
16
+
17
+ <Block
18
+ title="Add Position"
19
+ class="mn-b-semi"
20
+ >
21
+ <CardPosition
22
+ @add="(item) => globals.actions.add(
23
+ leftovers.state.current.positions,
24
+ item
25
+ )"
26
+ :products="Products"
27
+ />
28
+ </Block>
29
+
30
+ <Block
31
+ title="Invetory Sheet"
32
+ placeholder="No positions added yet"
33
+ class="mn-b-semi"
34
+ >
35
+ <CardPosition
36
+ v-for="(product, index) in leftovers.state.current.positions"
37
+ :key="product._id"
38
+ :product="product"
39
+ :array="leftovers.state.current.positions"
40
+ :products="Products"
41
+ @add="(item) => globals.actions.add(
42
+ leftovers.state.current.positions,
43
+ item
44
+ )"
45
+ @update="(item) => globals.actions.update(
46
+ leftovers.state.current.positions,
47
+ item,
48
+ index
49
+ )"
50
+ @delete="(item) => globals.actions.delete(
51
+ leftovers.state.current.positions,
52
+ item,
53
+ index
54
+ )"
55
+ />
56
+ </Block>
57
+
58
+ <Block class="">
59
+ <section class="gap-thin flex-v-center flex-nojustify flex">
60
+
61
+ <h3 class="mn-r-auto">
62
+ In total: {{formatPrice(totalPrice)}}
63
+ </h3>
64
+
65
+ <a
66
+ @click="onSubmit()"
67
+ class="bg-main button"
68
+ >
69
+ Save
70
+ </a>
71
+
72
+ <a
73
+ class="t-white bg-second button"
74
+ @click="onReset()"
75
+ >
76
+ Reset
77
+ </a>
78
+
79
+ <a
80
+ v-if="route.params.leftover"
81
+ @click="onDelete()"
82
+ class="t-white bg-red button"
83
+ >
84
+ Delete
85
+ </a>
86
+ </section>
87
+ </Block>
88
+ </div>
88
89
  </template>
89
90
 
90
91
 
@@ -101,6 +102,7 @@
101
102
  import { useRoute, useRouter } from 'vue-router';
102
103
 
103
104
  import * as globals from '@pf/src/modules/globals/store/globals';
105
+ import * as auth from '@pf/src/modules/auth/store/auth';
104
106
  import * as leftovers from '@pf/src/modules/products/store/leftovers';
105
107
  import * as products from '@pf/src/modules/products/store/products';
106
108
 
@@ -155,6 +157,16 @@
155
157
  (error) => console.error('error')
156
158
  );
157
159
  } else {
160
+ leftovers.state.current.creator = {
161
+ type: 'user',
162
+ target: auth.state.user._id
163
+ }
164
+ leftovers.state.current.owner = {
165
+ type: 'organization',
166
+ target: route.params._id
167
+ }
168
+
169
+ console.log('leftover state is', leftovers.state.current)
158
170
  leftovers.actions.create(leftovers.state.current).then(
159
171
  () => router.push({ name: 'Leftovers', params: {_id: route.params._id} }),
160
172
  (error) => console.error('error')
@@ -41,8 +41,7 @@
41
41
  :tabs="[
42
42
  { name: 'All', value: 'all' },
43
43
  { name: 'Stock-In', value: 'stock-in' },
44
- { name: 'Stock-Out', value: 'stock-out' },
45
- { name: 'Write-Off', value: 'write-off' },
44
+ { name: 'Stock-Out', value: 'stock-out' }
46
45
  ]"
47
46
  class="mn-b-small o-hidden h5 radius-big bg-grey"
48
47
  />
@@ -59,7 +58,8 @@
59
58
  }"
60
59
  :options="{
61
60
  limit: 15,
62
- organization: route.params._id
61
+ organization: route.params._id,
62
+ ...(tab !== 'all' && { type: tab })
63
63
  // user: user
64
64
  }"
65
65
  v-slot="{
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <div class="flex flex-column w-100 o-hidden gap-thin pd-thin">
3
3
  <!-- <Breadcrumbs class="bg-grey radius-big pd-small"/> -->
4
- {{product.quantity}}
4
+ <!-- {{product.quantity}}
5
5
  <div v-if="product.ingredients">
6
6
  {{product?.ingredients[0]?._id}}
7
7
  {{product?.ingredients[0]?.quantity}}
8
8
  {{product?.ingredients[1]?.quantity}}
9
- </div>
9
+ </div> -->
10
10
  <SectionProduct v-if="product" :product="product" :user="auth.state.user" class="pos-relative"/>
11
11
 
12
12
  <PopularProducts />
@@ -1,4 +1,5 @@
1
1
  <template>
2
+ <div class="pd-thin">
2
3
  <header
3
4
  v-if="route.name !== 'Organization'"
4
5
  class="mn-b-medium flex-v-center flex-nowrap flex"
@@ -6,16 +7,16 @@
6
7
  <h2 class="mn-r-medium">Products</h2>
7
8
  <button
8
9
  @click="$router.push({
9
- name: 'AddProduct'
10
+ name: 'ProductAdd'
10
11
  })"
11
12
  class="radius-100 i-big hover-scale-1 cursor-pointer t-white bg-second">
12
13
  +
13
14
  </button>
14
15
  </header>
15
- <!--
16
+
16
17
  <Tab
17
18
  v-if="route.name !== 'Organization'"
18
- v-model:selected="tab"
19
+ v-model:selected="tabProducts"
19
20
  :tabs="[
20
21
  { name: 'All', value: 'all' },
21
22
  { name: 'Published', value: 'published' },
@@ -24,7 +25,7 @@
24
25
  ]"
25
26
  class="mn-b-small o-hidden h5 radius-big bg-grey"
26
27
  />
27
- -->
28
+
28
29
  <div class="cols-2-1_3 bg-grey pd-thin radius-big gap-thin">
29
30
 
30
31
  <FilterProducts
@@ -37,7 +38,6 @@
37
38
  placeholder="Enter product name"
38
39
  class="bg-white mn-b-thin"
39
40
  />
40
- {{tab}}
41
41
  <Feed
42
42
  :states="{
43
43
  empty: {
@@ -56,7 +56,7 @@
56
56
  prices: route.query.prices,
57
57
  delivery: route.query.delivery,
58
58
  search: route.query.search,
59
- status: tab === 'all' ? '' : tab ? tab : ''
59
+ ...(tabProducts !== 'all' && { status: tabProducts })
60
60
  // user: user
61
61
  }"
62
62
  v-slot="{
@@ -80,6 +80,7 @@
80
80
  </Feed>
81
81
  </div>
82
82
  </div>
83
+ </div>
83
84
  </template>
84
85
 
85
86
 
@@ -104,13 +105,13 @@
104
105
  const router = useRouter()
105
106
 
106
107
  // Tab logic
107
- // const tab = ref(route.query.tab ? route.query.tab : 'all')
108
+ const tabProducts = ref(route.query.tabProducts ? route.query.tabProducts : 'all')
108
109
 
109
- // route.query.tab = tab.value
110
+ route.query.tabProducts = tabProducts.value
110
111
 
111
- // watch(tab, (newValue) => {
112
- // router.replace({ query: { ...route.query, tab: newValue } });
113
- // });
112
+ watch(tabProducts, (newValue) => {
113
+ router.replace({ query: { ...route.query, tabProducts: newValue } });
114
+ });
114
115
 
115
116
  function updateSearch(search) {
116
117
  let query = { ...route.query}
@@ -12,6 +12,10 @@ const controllerFactory = (db) => {
12
12
  query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
13
13
  }
14
14
 
15
+ if (req.query.type) {
16
+ query.type = req.query.type;
17
+ }
18
+
15
19
  console.log(query);
16
20
 
17
21
  const leftoveres = await Leftover.find(query, null, options)
@@ -31,17 +35,22 @@ const controllerFactory = (db) => {
31
35
 
32
36
  const create = async (req, res) => {
33
37
  try {
38
+
39
+ console.log(req.body)
34
40
  const leftover = await Leftover.create({
35
41
  organization: req.body.organization,
36
42
  type: req.body.type,
37
43
  order: req.body.order,
38
- positions: req.body.positions
44
+ positions: req.body.positions,
45
+ creator: req.body.creator,
46
+ owner: req.body.owner
39
47
  });
40
48
  if (!leftover) {
41
49
  return res.status(404).send({ message: "ERROR_CREATING_LEFTOVER" });
42
50
  }
43
51
  res.status(200).send(leftover);
44
52
  } catch (err) {
53
+ console.log(err)
45
54
  res.status(500).send({ message: "ERROR_CREATE_LEFTOVER" });
46
55
  }
47
56
  };
@@ -41,9 +41,9 @@ const actions = {
41
41
  }
42
42
  },
43
43
 
44
- async create({ organization, type, order, positions }) {
44
+ async create({ organization, type, order, positions, creator, owner }) {
45
45
  try {
46
- const response = await $axios.post('/leftovers', { organization, type, order, positions });
46
+ const response = await $axios.post('/leftovers', { organization, type, order, positions, creator, owner });
47
47
  state.all.push(response.data);
48
48
  return response.data;
49
49
  } catch (error) {