diff --git a/backend/database/gardentrack.db b/backend/database/gardentrack.db index 6318f49..d8a255f 100644 Binary files a/backend/database/gardentrack.db and b/backend/database/gardentrack.db differ diff --git a/backend/server.js b/backend/server.js index 58f5c3f..8fa1582 100644 --- a/backend/server.js +++ b/backend/server.js @@ -93,6 +93,9 @@ function initializeDatabase() { current_height REAL, photo_url TEXT, current_photo_url TEXT, + estimated_ripening_start INTEGER, + estimated_ripening_end INTEGER, + ripening_notes TEXT, notes TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP @@ -219,6 +222,8 @@ function initializeDatabase() { date DATE NOT NULL, quantity REAL NOT NULL, unit TEXT NOT NULL, + weight REAL, + weight_unit TEXT, notes TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, @@ -500,6 +505,9 @@ app.get('/api/plants', (req, res) => { currentHeight: row.current_height, photoUrl: row.photo_url, currentPhotoUrl: row.current_photo_url, + estimatedRipeningStart: row.estimated_ripening_start, + estimatedRipeningEnd: row.estimated_ripening_end, + ripeningNotes: row.ripening_notes, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -536,6 +544,9 @@ app.post('/api/plants', (req, res) => { currentHeight: row.current_height, photoUrl: row.photo_url, currentPhotoUrl: row.current_photo_url, + estimatedRipeningStart: row.estimated_ripening_start, + estimatedRipeningEnd: row.estimated_ripening_end, + ripeningNotes: row.ripening_notes, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -573,6 +584,9 @@ app.put('/api/plants/:id', (req, res) => { currentHeight: row.current_height, photoUrl: row.photo_url, currentPhotoUrl: row.current_photo_url, + estimatedRipeningStart: row.estimated_ripening_start, + estimatedRipeningEnd: row.estimated_ripening_end, + ripeningNotes: row.ripening_notes, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -801,6 +815,8 @@ app.get('/api/harvests', (req, res) => { date: row.date, quantity: row.quantity, unit: row.unit, + weight: row.weight, + weightUnit: row.weight_unit, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -812,14 +828,14 @@ app.get('/api/harvests', (req, res) => { app.post('/api/harvests', (req, res) => { try { - const { plantId, date, quantity, unit, notes } = req.body; - + const { plantId, date, quantity, unit, weight, weightUnit, notes } = req.body; + const stmt = db.prepare(` - INSERT INTO harvest_records (plant_id, date, quantity, unit, notes) - VALUES (?, ?, ?, ?, ?) + INSERT INTO harvest_records (plant_id, date, quantity, unit, weight, weight_unit, notes) + VALUES (?, ?, ?, ?, ?, ?, ?) `); - - const result = stmt.run(plantId, date, quantity, unit, notes); + + const result = stmt.run(plantId, date, quantity, unit, weight || null, weightUnit || null, notes); const getStmt = db.prepare('SELECT * FROM harvest_records WHERE id = ? ORDER BY date DESC'); const row = getStmt.get(result.lastInsertRowid); @@ -830,6 +846,8 @@ app.post('/api/harvests', (req, res) => { date: row.date, quantity: row.quantity, unit: row.unit, + weight: row.weight, + weightUnit: row.weight_unit, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -1134,6 +1152,9 @@ app.get('/api/plants/:id', (req, res) => { currentHeight: row.current_height, photoUrl: row.photo_url, currentPhotoUrl: row.current_photo_url, + estimatedRipeningStart: row.estimated_ripening_start, + estimatedRipeningEnd: row.estimated_ripening_end, + ripeningNotes: row.ripening_notes, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at @@ -1170,6 +1191,9 @@ app.get('/api/plants/search', (req, res) => { currentHeight: row.current_height, photoUrl: row.photo_url, currentPhotoUrl: row.current_photo_url, + estimatedRipeningStart: row.estimated_ripening_start, + estimatedRipeningEnd: row.estimated_ripening_end, + ripeningNotes: row.ripening_notes, notes: row.notes, createdAt: row.created_at, updatedAt: row.updated_at diff --git a/package.json b/package.json index 7117958..149c359 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vite-react-typescript-starter", "private": true, - "version": "0.3.0", + "version": "0.3.1", "type": "module", "scripts": { "dev": "vite --mode development", diff --git a/src/components/HarvestForm.tsx b/src/components/HarvestForm.tsx index d0157e5..29f5a03 100644 --- a/src/components/HarvestForm.tsx +++ b/src/components/HarvestForm.tsx @@ -14,6 +14,8 @@ const HarvestForm: React.FC = ({ plant, onSave, onCancel }) => date: new Date().toISOString().split('T')[0], quantity: '', unit: 'lbs', + weight: '', + weightUnit: 'lbs', notes: '' }); @@ -21,7 +23,9 @@ const HarvestForm: React.FC = ({ plant, onSave, onCancel }) => e.preventDefault(); onSave({ ...formData, - quantity: parseFloat(formData.quantity) + quantity: parseFloat(formData.quantity), + weight: formData.weight ? parseFloat(formData.weight) : undefined, + weightUnit: formData.weight ? formData.weightUnit : undefined }); }; @@ -30,6 +34,10 @@ const HarvestForm: React.FC = ({ plant, onSave, onCancel }) => setFormData(prev => ({ ...prev, [name]: value })); }; + // Check if current unit is countable (requires weight field) + const countableUnits = ['pieces', 'bunches']; + const isCountableUnit = countableUnits.includes(formData.unit); + return (
@@ -99,6 +107,44 @@ const HarvestForm: React.FC = ({ plant, onSave, onCancel }) =>
+ {/* Weight fields - only show for countable units */} + {isCountableUnit && ( +
+
+ + +
+ +
+ + +
+
+ )} +
+
+

Информация о созревании

+
+
+ + +

День 1 = 1 января, День 365 = 31 декабря

+
+ +
+ + +

Должен быть больше, чем день начала созревания

+
+
+ +
+ +