create-cactus 1.0.3 → 1.0.5

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.3",
3
+ "version": "1.0.5",
4
4
  "description": "Create a new Stock Management System (Cactus)",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -29,8 +29,8 @@ export default function Login() {
29
29
  <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-olive-50 to-olive-100">
30
30
  <div className="bg-white rounded-2xl shadow-lg p-8 w-full max-w-sm">
31
31
  <div className="text-center mb-8">
32
- <h1 className="text-2xl font-bold text-gray-800 hover:text-olive-600 cursor-pointer">Welcome Back</h1>
33
- <p className="text-gray-500 text-sm mt-1">Sign in to your account</p>
32
+ <h1 className="text-2xl font-bold text-gray-800 hover:text-olive-600 cursor-pointer">Login</h1>
33
+ <p className="text-gray-500 text-sm mt-1">Fill the form</p>
34
34
  </div>
35
35
 
36
36
  <form onSubmit={handleSubmit} className="space-y-5">
@@ -32,16 +32,16 @@ export default function Signup() {
32
32
  <div className="text-center mb-8">
33
33
 
34
34
  <h1 className="text-2xl font-bold text-gray-800 hover:text-olive-600 cursor-pointer">Create Account</h1>
35
- <p className="text-gray-500 text-sm mt-1">Join stock management</p>
35
+ <p className="text-gray-500 text-sm mt-1">Fill the form</p>
36
36
  </div>
37
37
 
38
38
  <form onSubmit={handleSubmit} className="space-y-4">
39
39
  <div>
40
- <label className="block text-sm font-medium text-gray-700 mb-1">User ID</label>
40
+ <label className="block text-sm font-medium text-gray-700 mb-1">UserID</label>
41
41
  <input type="text" name="UserId" required placeholder="Enter your Id" className="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-olive-500 focus:border-olive-500 outline-none transition" />
42
42
  </div>
43
43
  <div>
44
- <label className="block text-sm font-medium text-gray-700 mb-1">Username</label>
44
+ <label className="block text-sm font-medium text-gray-700 mb-1">UserBame</label>
45
45
  <input type="text" name="username" required placeholder="Enter Your names" className="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-olive-500 focus:border-olive-500 outline-none transition" />
46
46
  </div>
47
47
  <div>
@@ -59,7 +59,7 @@ export default function Signup() {
59
59
 
60
60
  <p className="text-sm text-center mt-6 text-gray-500">
61
61
  Already have an account?
62
- <Link to="/" className="text-olive-600 font-medium hover:underline">Sign in</Link>
62
+ <Link to="/" className="text-olive-600 font-medium hover:underline">Login</Link>
63
63
  </p>
64
64
  </div>
65
65
  </div>
@@ -1,35 +1,29 @@
1
- import React, { useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import { getReports } from "../api/api";
3
3
 
4
+ const periods = [
5
+ { label: "Daily", i: "dailyStockIn", o: "dailyStockOut" },
6
+ { label: "Weekly", i: "weeklyStockIn", o: "weeklyStockOut" },
7
+ { label: "Monthly", i: "monthlyStockIn", o: "monthlyStockOut" },
8
+ ];
9
+
4
10
  export default function Reports() {
5
- const [reports, setReports] = useState({});
11
+ const [r, setR] = useState({});
6
12
 
7
- useEffect(() => {
8
- getReports()
9
- .then((res) => setReports(res.data))
10
- .catch((err) => console.log(err));
11
- }, []);
13
+ useEffect(() => { getReports().then(d => setR(d.data)).catch(console.error) }, []);
12
14
 
13
15
  return (
14
16
  <div>
15
17
  <h1 className="text-xl font-bold text-gray-800 mb-4 hover:text-olive-600 cursor-pointer">Reports</h1>
16
18
 
17
19
  <div className="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6">
18
- <div className="bg-white border border-gray-200 rounded-lg p-4">
19
- <h2 className="text-sm font-semibold text-gray-600 mb-2 hover:text-olive-600 cursor-pointer">Daily</h2>
20
- <p className="text-sm">Stock In: <span className="font-bold">{reports.dailyStockIn?.length || 0}</span></p>
21
- <p className="text-sm">Stock Out: <span className="font-bold">{reports.dailyStockOut?.length || 0}</span></p>
22
- </div>
23
- <div className="bg-white border border-gray-200 rounded-lg p-4">
24
- <h2 className="text-sm font-semibold text-gray-600 mb-2 hover:text-olive-600 cursor-pointer">Weekly</h2>
25
- <p className="text-sm">Stock In: <span className="font-bold">{reports.weeklyStockIn?.length || 0}</span></p>
26
- <p className="text-sm">Stock Out: <span className="font-bold">{reports.weeklyStockOut?.length || 0}</span></p>
27
- </div>
28
- <div className="bg-white border border-gray-200 rounded-lg p-4">
29
- <h2 className="text-sm font-semibold text-gray-600 mb-2 hover:text-olive-600 cursor-pointer">Monthly</h2>
30
- <p className="text-sm">Stock In: <span className="font-bold">{reports.monthlyStockIn?.length || 0}</span></p>
31
- <p className="text-sm">Stock Out: <span className="font-bold">{reports.monthlyStockOut?.length || 0}</span></p>
32
- </div>
20
+ {periods.map(p => (
21
+ <div key={p.label} className="bg-white border border-gray-200 rounded-lg p-4">
22
+ <h2 className="text-sm font-semibold text-gray-600 mb-2 hover:text-olive-600 cursor-pointer">{p.label}</h2>
23
+ <p className="text-sm">Stock In: <span className="font-bold">{(r[p.i]?.length || 0)}</span></p>
24
+ <p className="text-sm">Stock Out: <span className="font-bold">{(r[p.o]?.length || 0)}</span></p>
25
+ </div>
26
+ ))}
33
27
  </div>
34
28
 
35
29
  <div className="bg-white border border-gray-200 rounded-lg p-4">
@@ -37,14 +31,13 @@ export default function Reports() {
37
31
  <table className="w-full text-sm">
38
32
  <thead>
39
33
  <tr className="border-b border-gray-200">
40
- <th className="text-left py-2 pr-4 font-medium text-gray-500">Product</th>
41
- <th className="text-left py-2 pr-4 font-medium text-gray-500">Category</th>
42
- <th className="text-left py-2 pr-4 font-medium text-gray-500">Quantity</th>
43
- <th className="text-left py-2 font-medium text-gray-500">Price</th>
34
+ {["Product", "Category", "Quantity", "Price"].map(h => (
35
+ <th key={h} className="text-left py-2 pr-4 font-medium text-gray-500">{h}</th>
36
+ ))}
44
37
  </tr>
45
38
  </thead>
46
39
  <tbody>
47
- {reports.availableStock?.map((p) => (
40
+ {(r.availableStock || []).map(p => (
48
41
  <tr key={p._id} className="border-b border-gray-100">
49
42
  <td className="py-2 pr-4">{p.ProductName}</td>
50
43
  <td className="py-2 pr-4 text-gray-600">{p.Category}</td>
@@ -208,7 +208,7 @@ export default function Stocks() {
208
208
  <td className="px-3 py-2">{t.UserId}</td>
209
209
  <td className="px-3 py-2 flex gap-1.5">
210
210
  <button onClick={() => openEdit(t)} className="text-blue-600 hover:underline">Edit</button>
211
- <button onClick={() => handleDelete(t._id)} className="text-red-600 hover:underline">Del</button>
211
+ <button onClick={() => handleDelete(t._id)} className="text-red-600 hover:underline">Delete</button>
212
212
  </td>
213
213
  </tr>
214
214
  ))}