create-cactus 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cactus",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Create a new Stock Management System (Cactus)",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,6 @@
1
1
  <mxfile host="65bd71144e">
2
2
  <diagram id="PQ5hsovL6DdM_u9k81B_" name="Page-1">
3
- <mxGraphModel dx="3416" dy="1156" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
3
+ <mxGraphModel dx="3244" dy="1040" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
4
4
  <root>
5
5
  <mxCell id="0"/>
6
6
  <mxCell id="1" parent="0"/>
@@ -65,12 +65,12 @@
65
65
  <mxGeometry x="-405" y="240" width="80" height="80" as="geometry"/>
66
66
  </mxCell>
67
67
  <mxCell id="31" value="records" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
68
- <mxGeometry x="-425" y="630" width="80" height="80" as="geometry"/>
68
+ <mxGeometry x="-425" y="625" width="80" height="80" as="geometry"/>
69
69
  </mxCell>
70
70
  <mxCell id="33" value="contains" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
71
71
  <mxGeometry x="-630" y="480" width="80" height="80" as="geometry"/>
72
72
  </mxCell>
73
- <mxCell id="36" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="31" target="5" edge="1">
73
+ <mxCell id="36" value="" style="endArrow=none;html=1;entryX=1.005;entryY=0.413;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryPerimeter=0;" parent="1" source="31" target="5" edge="1">
74
74
  <mxGeometry width="50" height="50" relative="1" as="geometry">
75
75
  <mxPoint x="-380" y="590" as="sourcePoint"/>
76
76
  <mxPoint x="-330" y="540" as="targetPoint"/>
@@ -82,10 +82,10 @@
82
82
  <mxPoint x="-570" y="330" as="targetPoint"/>
83
83
  </mxGeometry>
84
84
  </mxCell>
85
- <mxCell id="40" value="" style="endArrow=none;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" target="33" edge="1">
85
+ <mxCell id="40" value="" style="endArrow=none;html=1;exitX=0.412;exitY=0.012;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" target="33" edge="1" source="5">
86
86
  <mxGeometry width="50" height="50" relative="1" as="geometry">
87
87
  <mxPoint x="-590" y="640" as="sourcePoint"/>
88
- <mxPoint x="-590.36" y="620" as="targetPoint"/>
88
+ <mxPoint x="-590" y="570" as="targetPoint"/>
89
89
  </mxGeometry>
90
90
  </mxCell>
91
91
  <mxCell id="41" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="31" target="4" edge="1">
@@ -97,9 +97,9 @@
97
97
  </Array>
98
98
  </mxGeometry>
99
99
  </mxCell>
100
- <mxCell id="42" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="2" target="30" edge="1">
100
+ <mxCell id="42" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" target="30" edge="1">
101
101
  <mxGeometry width="50" height="50" relative="1" as="geometry">
102
- <mxPoint x="-380" y="210" as="sourcePoint"/>
102
+ <mxPoint x="-528" y="280" as="sourcePoint"/>
103
103
  <mxPoint x="-370" y="230" as="targetPoint"/>
104
104
  </mxGeometry>
105
105
  </mxCell>
@@ -205,55 +205,12 @@
205
205
  <mxPoint x="-640" y="790" as="targetPoint"/>
206
206
  </mxGeometry>
207
207
  </mxCell>
208
- <mxCell id="69" value="" style="endArrow=none;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;" parent="1" target="4" edge="1">
209
- <mxGeometry width="50" height="50" relative="1" as="geometry">
210
- <mxPoint x="-150" y="665" as="sourcePoint"/>
211
- <mxPoint x="-340" y="515" as="targetPoint"/>
212
- </mxGeometry>
213
- </mxCell>
214
- <mxCell id="70" value="" style="endArrow=none;html=1;exitX=0.62;exitY=1.048;exitDx=0;exitDy=0;exitPerimeter=0;" parent="1" source="2" edge="1">
215
- <mxGeometry width="50" height="50" relative="1" as="geometry">
216
- <mxPoint x="-480" y="180" as="sourcePoint"/>
217
- <mxPoint x="-590" y="350" as="targetPoint"/>
218
- </mxGeometry>
219
- </mxCell>
220
- <mxCell id="71" value="" style="endArrow=none;html=1;" parent="1" edge="1">
221
- <mxGeometry width="50" height="50" relative="1" as="geometry">
222
- <mxPoint x="-600" y="310" as="sourcePoint"/>
223
- <mxPoint x="-590" y="350" as="targetPoint"/>
224
- </mxGeometry>
225
- </mxCell>
226
- <mxCell id="72" value="" style="endArrow=none;html=1;entryX=0;entryY=0.75;entryDx=0;entryDy=0;" parent="1" target="4" edge="1">
227
- <mxGeometry width="50" height="50" relative="1" as="geometry">
228
- <mxPoint x="-150" y="665" as="sourcePoint"/>
229
- <mxPoint x="-340" y="515" as="targetPoint"/>
230
- </mxGeometry>
231
- </mxCell>
232
208
  <mxCell id="73" value="" style="endArrow=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="30" edge="1">
233
209
  <mxGeometry width="50" height="50" relative="1" as="geometry">
234
210
  <mxPoint x="-520" y="290" as="sourcePoint"/>
235
211
  <mxPoint x="-130" y="280" as="targetPoint"/>
236
212
  </mxGeometry>
237
213
  </mxCell>
238
- <mxCell id="74" value="" style="endArrow=none;html=1;" parent="1" edge="1">
239
- <mxGeometry width="50" height="50" relative="1" as="geometry">
240
- <mxPoint x="-80" y="630" as="sourcePoint"/>
241
- <mxPoint x="-60" y="615" as="targetPoint"/>
242
- </mxGeometry>
243
- </mxCell>
244
- <mxCell id="75" value="" style="endArrow=none;html=1;" parent="1" edge="1">
245
- <mxGeometry width="50" height="50" relative="1" as="geometry">
246
- <mxPoint x="-60" y="615" as="sourcePoint"/>
247
- <mxPoint x="-50" y="630" as="targetPoint"/>
248
- </mxGeometry>
249
- </mxCell>
250
- <mxCell id="76" value="" style="endArrow=none;html=1;" parent="1" edge="1">
251
- <mxGeometry width="50" height="50" relative="1" as="geometry">
252
- <mxPoint x="-150" y="270" as="sourcePoint"/>
253
- <mxPoint x="-150" y="290" as="targetPoint"/>
254
- <Array as="points"/>
255
- </mxGeometry>
256
- </mxCell>
257
214
  <mxCell id="80" value="USER" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" parent="1" vertex="1">
258
215
  <mxGeometry x="-130" y="248" width="120" height="60" as="geometry"/>
259
216
  </mxCell>
@@ -269,7 +226,7 @@
269
226
  <mxCell id="84" value="&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;u&gt;UserId&lt;/u&gt;&lt;/span&gt;" style="ellipse;whiteSpace=wrap;html=1;fontStyle=1" parent="1" vertex="1">
270
227
  <mxGeometry x="-220" y="208" width="120" height="20" as="geometry"/>
271
228
  </mxCell>
272
- <mxCell id="85" value="" style="endArrow=none;html=1;entryX=0.383;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="80" target="83" edge="1">
229
+ <mxCell id="85" value="" style="endArrow=none;html=1;entryX=0.383;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.556;exitY=-0.002;exitDx=0;exitDy=0;exitPerimeter=0;" parent="1" source="80" target="83" edge="1">
273
230
  <mxGeometry width="50" height="50" relative="1" as="geometry">
274
231
  <mxPoint x="70" y="468" as="sourcePoint"/>
275
232
  <mxPoint x="120" y="418" as="targetPoint"/>
@@ -293,41 +250,17 @@
293
250
  <mxPoint x="120" y="418" as="targetPoint"/>
294
251
  </mxGeometry>
295
252
  </mxCell>
296
- <mxCell id="89" value="" style="endArrow=none;html=1;" parent="1" edge="1">
297
- <mxGeometry width="50" height="50" relative="1" as="geometry">
298
- <mxPoint x="-80" y="330" as="sourcePoint"/>
299
- <mxPoint x="-40" y="330" as="targetPoint"/>
300
- </mxGeometry>
301
- </mxCell>
302
253
  <mxCell id="90" value="" style="endArrow=none;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" target="98" edge="1">
303
254
  <mxGeometry width="50" height="50" relative="1" as="geometry">
304
255
  <mxPoint x="-60" y="630" as="sourcePoint"/>
305
256
  <mxPoint x="-49.15506858075878" y="448.28493141924184" as="targetPoint"/>
306
257
  </mxGeometry>
307
258
  </mxCell>
308
- <mxCell id="91" value="" style="endArrow=none;html=1;" parent="1" edge="1">
309
- <mxGeometry width="50" height="50" relative="1" as="geometry">
310
- <mxPoint x="-600" y="620" as="sourcePoint"/>
311
- <mxPoint x="-580" y="620" as="targetPoint"/>
312
- </mxGeometry>
313
- </mxCell>
314
- <mxCell id="92" value="" style="endArrow=none;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;" parent="1" target="2" edge="1">
315
- <mxGeometry width="50" height="50" relative="1" as="geometry">
316
- <mxPoint x="-500" y="280" as="sourcePoint"/>
317
- <mxPoint x="-330" y="350" as="targetPoint"/>
318
- </mxGeometry>
319
- </mxCell>
320
- <mxCell id="93" value="" style="endArrow=none;html=1;entryX=1;entryY=0.75;entryDx=0;entryDy=0;" parent="1" target="2" edge="1">
321
- <mxGeometry width="50" height="50" relative="1" as="geometry">
322
- <mxPoint x="-500" y="280" as="sourcePoint"/>
323
- <mxPoint x="-330" y="350" as="targetPoint"/>
324
- </mxGeometry>
325
- </mxCell>
326
259
  <mxCell id="98" value="performs" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
327
260
  <mxGeometry x="-100" y="400" width="80" height="80" as="geometry"/>
328
261
  </mxCell>
329
262
  <mxCell id="100" value="involvedIn" style="rhombus;whiteSpace=wrap;html=1;rotation=45;" parent="1" vertex="1">
330
- <mxGeometry x="-360" y="460" width="80" height="80" as="geometry"/>
263
+ <mxGeometry x="-360" y="440" width="80" height="80" as="geometry"/>
331
264
  </mxCell>
332
265
  <mxCell id="101" value="" style="endArrow=none;html=1;entryX=1;entryY=1;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="100" target="2" edge="1">
333
266
  <mxGeometry width="50" height="50" relative="1" as="geometry">
@@ -341,12 +274,6 @@
341
274
  <mxPoint x="-390" y="490" as="targetPoint"/>
342
275
  </mxGeometry>
343
276
  </mxCell>
344
- <mxCell id="103" value="" style="endArrow=none;html=1;" parent="1" edge="1">
345
- <mxGeometry width="50" height="50" relative="1" as="geometry">
346
- <mxPoint x="-500" y="690" as="sourcePoint"/>
347
- <mxPoint x="-500" y="650" as="targetPoint"/>
348
- </mxGeometry>
349
- </mxCell>
350
277
  <mxCell id="105" value="UserId(FK)" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
351
278
  <mxGeometry x="150" y="650" width="120" height="30" as="geometry"/>
352
279
  </mxCell>
@@ -356,24 +283,6 @@
356
283
  <mxPoint x="70" y="590" as="targetPoint"/>
357
284
  </mxGeometry>
358
285
  </mxCell>
359
- <mxCell id="107" value="" style="endArrow=none;html=1;" parent="1" edge="1">
360
- <mxGeometry width="50" height="50" relative="1" as="geometry">
361
- <mxPoint x="-530" y="330" as="sourcePoint"/>
362
- <mxPoint x="-500" y="310" as="targetPoint"/>
363
- </mxGeometry>
364
- </mxCell>
365
- <mxCell id="108" value="" style="endArrow=none;html=1;entryX=0.094;entryY=-0.05;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" target="4" edge="1">
366
- <mxGeometry width="50" height="50" relative="1" as="geometry">
367
- <mxPoint x="-150" y="620" as="sourcePoint"/>
368
- <mxPoint x="-430" y="580" as="targetPoint"/>
369
- </mxGeometry>
370
- </mxCell>
371
- <mxCell id="109" value="" style="endArrow=none;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;" parent="1" target="4" edge="1">
372
- <mxGeometry width="50" height="50" relative="1" as="geometry">
373
- <mxPoint x="-160" y="620" as="sourcePoint"/>
374
- <mxPoint x="-430" y="580" as="targetPoint"/>
375
- </mxGeometry>
376
- </mxCell>
377
286
  <mxCell id="110" value="TransactionId(FK)" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
378
287
  <mxGeometry x="-465" y="720" width="120" height="30" as="geometry"/>
379
288
  </mxCell>
@@ -383,9 +292,39 @@
383
292
  <mxPoint x="-430" y="580" as="targetPoint"/>
384
293
  </mxGeometry>
385
294
  </mxCell>
386
- <mxCell id="112" value="&lt;b&gt;LEGEND&lt;/b&gt;&lt;div&gt;&lt;b&gt;.Rectangle&lt;/b&gt;:Entity&amp;nbsp;&lt;br&gt;&lt;b&gt;.Ellipse&lt;/b&gt;:Attribute&amp;nbsp;&lt;br&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.Diamond:&lt;/b&gt;Relationship&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(63, 63, 63); background-color: transparent; scrollbar-color: rgb(226, 226, 226) rgb(251, 251, 251);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;u style=&quot;color: rgb(63, 63, 63); background-color: transparent; scrollbar-color: rgb(226, 226, 226) rgb(251, 251, 251);&quot;&gt;Underlined:&lt;/u&gt;&lt;span style=&quot;color: rgb(63, 63, 63); background-color: transparent;&quot;&gt;Primary Key (PK):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-ProductCode&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -TransactionId&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - WarehouseCode&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- UserId&lt;br&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;.(FK):&lt;/b&gt;Foreign Key:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-ProductCode&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-WarehouseCode&amp;nbsp;&lt;br&gt;&amp;nbsp;-UserId&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -TransactionId&lt;br&gt;&lt;b&gt;Line:&lt;/b&gt;&amp;nbsp;Connector&lt;/div&gt;" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
295
+ <mxCell id="200" value="1" style="text;html=1;" vertex="1" parent="1">
296
+ <mxGeometry x="-580" y="610" width="20" height="20" as="geometry"/>
297
+ </mxCell>
298
+ <mxCell id="201" value="M" style="text;html=1;fontStyle=1" vertex="1" parent="1">
299
+ <mxGeometry x="-580" y="310" width="20" height="20" as="geometry"/>
300
+ </mxCell>
301
+ <mxCell id="202" value="1" style="text;html=1;" vertex="1" parent="1">
302
+ <mxGeometry x="-510" y="645" width="20" height="20" as="geometry"/>
303
+ </mxCell>
304
+ <mxCell id="203" value="M" style="text;html=1;" vertex="1" parent="1">
305
+ <mxGeometry x="-160" y="645" width="20" height="20" as="geometry"/>
306
+ </mxCell>
307
+ <mxCell id="204" value="1" style="text;html=1;" vertex="1" parent="1">
308
+ <mxGeometry x="-505" y="340" width="20" height="20" as="geometry"/>
309
+ </mxCell>
310
+ <mxCell id="205" value="M" style="text;html=1;" vertex="1" parent="1">
311
+ <mxGeometry x="-160" y="620" width="20" height="20" as="geometry"/>
312
+ </mxCell>
313
+ <mxCell id="206" value="&lt;b&gt;LEGEND&lt;/b&gt;&lt;hr&gt;&lt;b&gt;.Rectangle:&lt;/b&gt;Entity&lt;br&gt;&lt;b&gt;.Ellipse:&lt;/b&gt;Attribute&lt;br&gt;&lt;b&gt;.Diamond:&lt;/b&gt;Relationship&lt;br&gt;&lt;u&gt;.Underlined&lt;/u&gt;:Primary Key (PK):&lt;br&gt;&amp;nbsp; -ProductCode&amp;nbsp;&lt;div&gt;&amp;nbsp;-TransactionId&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -WarehouseCode&lt;/div&gt;&lt;div&gt;&lt;b&gt;.(FK):&lt;/b&gt;Foreign Key:&lt;br&gt;&amp;nbsp; -ProductCode&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-WarehouseCode&lt;br&gt;&amp;nbsp; &amp;nbsp; -TransactionId&lt;br&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .1 / M:&lt;/b&gt;Cardinality (one / many)&lt;/div&gt;" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
387
314
  <mxGeometry x="-1340" y="800" width="550" height="230" as="geometry"/>
388
315
  </mxCell>
316
+ <mxCell id="212" value="M" style="text;html=1;" vertex="1" parent="1">
317
+ <mxGeometry x="-80" y="605" width="20" height="20" as="geometry"/>
318
+ </mxCell>
319
+ <mxCell id="213" value="1" style="text;html=1;" vertex="1" parent="1">
320
+ <mxGeometry x="-150" y="275" width="20" height="20" as="geometry"/>
321
+ </mxCell>
322
+ <mxCell id="215" value="1" style="text;html=1;" vertex="1" parent="1">
323
+ <mxGeometry x="-80" y="310" width="20" height="20" as="geometry"/>
324
+ </mxCell>
325
+ <mxCell id="218" value="M" style="text;html=1;fontStyle=1" vertex="1" parent="1">
326
+ <mxGeometry x="-520" y="275" width="20" height="20" as="geometry"/>
327
+ </mxCell>
389
328
  </root>
390
329
  </mxGraphModel>
391
330
  </diagram>
@@ -13,12 +13,3 @@ export const addProduct = async (req, res) => {
13
13
  res.status(500).json({ message: 'internal server error', error: error.message });
14
14
  }
15
15
  };
16
-
17
- export const getAllProducts = async (req, res) => {
18
- try {
19
- const result = await products.find();
20
- res.status(200).json(result);
21
- } catch (error) {
22
- res.status(500).json({ message: 'internal server error', error: error.message });
23
- }
24
- };
@@ -1,5 +1,6 @@
1
1
  import stocktransaction from "../models/stocktransaction.js";
2
2
  import products from "../models/products.js";
3
+ import warehouse from "../models/warehouse.js";
3
4
 
4
5
  export const getReports = async (req, res) => {
5
6
  try {
@@ -34,8 +35,12 @@ export const getReports = async (req, res) => {
34
35
  TransactionType: "OUT",
35
36
  TransactionDate: { $gte: monthly }
36
37
  });
38
+ const totalProducts = await products.countDocuments();
39
+ const totalWarehouses = await warehouse.countDocuments();
37
40
  const availableStock = await products.find();
38
41
  res.status(200).json({
42
+ totalProducts,
43
+ totalWarehouses,
39
44
  dailyStockIn,
40
45
  dailyStockOut,
41
46
 
@@ -13,12 +13,3 @@ export const addWareHouse = async (req, res) => {
13
13
  res.status(500).json({ message: 'internal server error', error: error.message });
14
14
  }
15
15
  };
16
-
17
- export const getAllWarehouses = async (req, res) => {
18
- try {
19
- const result = await warehouse.find();
20
- res.status(200).json(result);
21
- } catch (error) {
22
- res.status(500).json({ message: 'internal server error', error: error.message });
23
- }
24
- };
@@ -1,10 +1,9 @@
1
1
  import express from 'express';
2
- import { addProduct, getAllProducts } from '../controllers/productsController.js';
2
+ import { addProduct } from '../controllers/productsController.js';
3
3
  import { verifyToken } from '../middleware/authMiddleware.js';
4
4
 
5
5
  const router = express.Router();
6
6
 
7
7
  router.post('/insertProduct', verifyToken, addProduct);
8
- router.get('/', verifyToken, getAllProducts);
9
8
 
10
9
  export default router;
@@ -1,10 +1,9 @@
1
1
  import express from 'express';
2
- import { addWareHouse, getAllWarehouses } from '../controllers/warehouseController.js';
2
+ import { addWareHouse } from '../controllers/warehouseController.js';
3
3
  import { verifyToken } from '../middleware/authMiddleware.js';
4
4
 
5
5
  const router = express.Router();
6
6
 
7
7
  router.post('/insertWarehouse', verifyToken, addWareHouse);
8
- router.get('/', verifyToken, getAllWarehouses);
9
8
 
10
9
  export default router;
@@ -15,9 +15,7 @@ api.interceptors.request.use((config) => {
15
15
  export const signupUser = (data) => api.post('/api/user/register', data)
16
16
  export const loginUser = (data) => api.post('/api/user/login', data)
17
17
  export const addProduct = (data) => api.post('/api/products/insertProduct', data)
18
- export const getAllProducts = () => api.get('/api/products')
19
18
  export const addWarehouse = (data) => api.post('/api/warehouses/insertWarehouse', data)
20
- export const getAllWarehouses = () => api.get('/api/warehouses')
21
19
  export const addStock = (data) => api.post('/api/stocktransactions/insertStock', data)
22
20
  export const getAllStocks = () => api.get('/api/stocktransactions/getStocks')
23
21
  export const getStock = (id) => api.get(`/api/stocktransactions/getStock/${id}`)
@@ -1,30 +1,14 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { getAllProducts, getAllWarehouses, getAllStocks } from "../api/api";
2
+ import { getReports } from "../api/api";
3
3
 
4
4
  export default function Dashboard() {
5
- const [products, setProducts] = useState([]);
6
- const [warehouses, setWarehouses] = useState([]);
7
- const [transactions, setTransactions] = useState([]);
5
+ const [data, setData] = useState(null);
8
6
  useEffect(() => {
9
- async function fetchData() {
10
- try {
11
- const [productRes, warehouseRes, transactionRes] = await Promise.all([
12
- getAllProducts(),
13
- getAllWarehouses(),
14
- getAllStocks(),
15
- ]);
16
- setProducts(productRes.data);
17
- setWarehouses(warehouseRes.data);
18
- setTransactions(transactionRes.data);
19
- } catch (error) {
20
- console.error(error.response?.data || error.message);
21
- }
22
- }
23
- fetchData();
7
+ getReports().then((res) => setData(res.data)).catch(console.error);
24
8
  }, []);
25
9
 
26
- const stockIn = transactions.filter((t) => t.TransactionType === 'IN').length;
27
- const stockOut = transactions.filter((t) => t.TransactionType === 'OUT').length;
10
+ const stockIn = data?.dailyStockIn?.length ?? 0;
11
+ const stockOut = data?.dailyStockOut?.length ?? 0;
28
12
 
29
13
  return (
30
14
  <div>
@@ -32,11 +16,11 @@ export default function Dashboard() {
32
16
  <div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
33
17
  <div className="bg-white border border-gray-200 rounded-lg p-4">
34
18
  <p className="text-sm text-gray-500">Total Products</p>
35
- <p className="text-2xl font-bold text-gray-800">{products.length}</p>
19
+ <p className="text-2xl font-bold text-gray-800">{data?.totalProducts ?? 0}</p>
36
20
  </div>
37
21
  <div className="bg-white border border-gray-200 rounded-lg p-4">
38
22
  <p className="text-sm text-gray-500">Warehouses</p>
39
- <p className="text-2xl font-bold text-gray-800">{warehouses.length}</p>
23
+ <p className="text-2xl font-bold text-gray-800">{data?.totalWarehouses ?? 0}</p>
40
24
  </div>
41
25
  <div className="bg-white border border-gray-200 rounded-lg p-4">
42
26
  <p className="text-sm text-gray-500">Stock In</p>
@@ -1,10 +1,8 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { addStock, getAllProducts, getAllWarehouses, getAllProfiles, getAllStocks, updateStock, deleteStock } from "../api/api";
2
+ import { addStock, getAllProfiles, getAllStocks, updateStock, deleteStock } from "../api/api";
3
3
 
4
4
  export default function Stocks() {
5
5
  const [loading, setLoading] = useState(false);
6
- const [products, setProducts] = useState([]);
7
- const [warehouses, setWarehouses] = useState([]);
8
6
  const [users, setUsers] = useState([]);
9
7
  const [transactions, setTransactions] = useState([]);
10
8
  const [editing, setEditing] = useState(null);
@@ -12,14 +10,10 @@ export default function Stocks() {
12
10
  useEffect(() => {
13
11
  async function fetchData() {
14
12
  try {
15
- const [pRes, wRes, uRes, tRes] = await Promise.all([
16
- getAllProducts(),
17
- getAllWarehouses(),
13
+ const [uRes, tRes] = await Promise.all([
18
14
  getAllProfiles(),
19
15
  getAllStocks(),
20
16
  ]);
21
- setProducts(pRes.data);
22
- setWarehouses(wRes.data);
23
17
  setUsers(uRes.data);
24
18
  setTransactions(tRes.data);
25
19
  } catch (error) {
@@ -142,22 +136,12 @@ export default function Stocks() {
142
136
  </div>
143
137
  <div className="grid grid-cols-2 gap-2">
144
138
  <div>
145
- <label className="block text-xs font-medium text-gray-700 mb-0.5">Warehouse</label>
146
- <select name="WarehouseCode" required defaultValue={editTx?.WarehouseCode || ''} disabled={!!editing} className="w-full border border-gray-300 rounded px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-olive-500 bg-white disabled:bg-gray-100">
147
- <option value="">Select</option>
148
- {warehouses.map((w) => (
149
- <option key={w._id} value={w.WarehouseCode}>{w.WarehouseCode}</option>
150
- ))}
151
- </select>
139
+ <label className="block text-xs font-medium text-gray-700 mb-0.5">Warehouse Code</label>
140
+ <input type="text" name="WarehouseCode" required defaultValue={editTx?.WarehouseCode || ''} disabled={!!editing} placeholder="Enter w-Code" className="w-full border border-gray-300 rounded px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-olive-500 disabled:bg-gray-100" />
152
141
  </div>
153
142
  <div>
154
- <label className="block text-xs font-medium text-gray-700 mb-0.5">Product</label>
155
- <select name="ProductCode" required defaultValue={editTx?.ProductCode || ''} disabled={!!editing} className="w-full border border-gray-300 rounded px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-olive-500 bg-white disabled:bg-gray-100">
156
- <option value="">Select</option>
157
- {products.map((p) => (
158
- <option key={p._id} value={p.ProductCode}>{p.ProductCode}</option>
159
- ))}
160
- </select>
143
+ <label className="block text-xs font-medium text-gray-700 mb-0.5">Product Code</label>
144
+ <input type="text" name="ProductCode" required defaultValue={editTx?.ProductCode || ''} disabled={!!editing} placeholder="Enter p-Code" className="w-full border border-gray-300 rounded px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-olive-500 disabled:bg-gray-100" />
161
145
  </div>
162
146
  </div>
163
147
  <div className="flex gap-2 pt-1">
@@ -182,7 +166,7 @@ export default function Stocks() {
182
166
  <th className="px-3 py-2">T-ID</th>
183
167
  <th className="px-3 py-2">Date</th>
184
168
  <th className="px-3 py-2">Type</th>
185
- <th className="px-3 py-2">Quantityty</th>
169
+ <th className="px-3 py-2">Quantity</th>
186
170
  <th className="px-3 py-2">Product</th>
187
171
  <th className="px-3 py-2">Warehouse</th>
188
172
  <th className="px-3 py-2">User</th>