From fe1878ff3e8cf250315cd0cdb6ee43ec7dc99ed5 Mon Sep 17 00:00:00 2001 From: anibilag Date: Sat, 13 Sep 2025 19:28:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=87=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=200.3.1=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=81=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B7=D1=80=D0=B5=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20=D0=B4=D0=BD=D1=8F=D1=85=20=D0=B3=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0.=20=D0=9F=D1=80=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=20=D1=83=D1=80=D0=BE=D0=B6=D0=B0=D1=8F=20=D0=B5=D1=81?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BE=D0=BD=20=D0=B2=20=D1=88=D1=82=D1=83=D0=BA?= =?UTF-8?q?=D0=B0=D1=85,=20=D1=82=D0=BE=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=82=D1=8C=20=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=B2=D0=B5=D1=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/database/gardentrack.db | Bin 57344 -> 57344 bytes backend/server.js | 36 +++++-- package.json | 2 +- src/components/HarvestForm.tsx | 48 ++++++++- src/components/PlantForm.tsx | 69 ++++++++++++- src/components/PlantRegistry.tsx | 29 +++++- src/components/PlantStatistics.tsx | 154 +++++++++++++++++++++++++++-- src/types/index.ts | 5 + 8 files changed, 324 insertions(+), 19 deletions(-) diff --git a/backend/database/gardentrack.db b/backend/database/gardentrack.db index 6318f49b6cbdeb4d9567f4e33a2c47b2324bb1d9..d8a255fc557d1a527ebee523c3a36e87d0c86f49 100644 GIT binary patch delta 2097 zcmcgtZD?Cn7(VwVO_sFj_s7y~<#bvU`r-ZPP1k@r!7zqmSuIoXNA22>g|W6KakGqi zdsDl)51N&r?8ny54MCVly1T4t(`Nglzs~_-$UqPjoc{6W!2R$&C&^73`o}*OdUMZv z&&TsV&-1=#;gN0Ok?oqVX$c`z5C5gVrjs`Uw-6kNk7*thQk$UF)R>x$GwS_Z8?Y)vmuUjii|_&ivcZ?bf-TaV zhZR@hh0lgf$!2QpKxgZ4zbs=#3MgtolZ{uK8&KN^DbngSpEdpM5Nm%o|J?tNX!j)1 zujW(VdP}>j#bN6ePEAD5hGOyYXlQaKIu+|O)31!-Mu&S2)j#$8T=!euzFMz)&g{k^ zw{9GC)ghs~=X}3_dQ`PRkrb_88t#|;tl?1)QlwqHDXmS8^{9HLEK8#n%I=w`)WD^4q;0dtC;DCmSzD3M|iZekn z$sdrVJwivC3obn!Hd+r9F~6j$VnZ3T;;6>l#|SS_nFk%fdUP3Za~mEJc^UIp&3 zDq&*6q%_$k+ZGlD%W6Ow1V`-=vb`2Qcd(XIIkOv;T0*r-9)iTo{&cZOs-6X}b9ca# zl|cozOqm#!sVW@~XoJ?t<&bSOY?qs|F6Cp>0%tayf3J#P@%k9 zou>s==0quSK(&gbBBXyBKHcf!I44xqf+-D&#SOm#RdTEw6vb$ZfM|EkKegQ^X zBwN_8?NV2fjF-K|>H!FPMfphn{|`hdZJilg9ty}-NlAVyBwh|1hxQkZeRP-Ll2*kR z^RWUA#j0AUYjz!Mv-U|$c0Yh%T*@>}vbMm>JGjO8YvaD&r?$Bth z##FRB3(bek_OpL^U7jUWV|O6C!*pMJZgVe<2+j_#SGYW9CU4G)@AYB0S|VpA;-RVW zXk<1t9hnY~$Kn&wI6n5ySnz0Ybk7-~>8bK}Yu)rrJQTxY!S~0^$ByqEc7(+9=B1nS zV*PdGd5*5TZ#bj&AH>gAjL+SRlTK$xZ?AA+-hBPLGeQ?W7m9>W#qntHjko)XgYi$M cBXPc8>d4(=DdKRM*<16q=1+FJcsniq3*%;hm;e9( delta 254 zcmZoTz}#?vd4jZHAp-*g9}vR;&qN(##=?yWOZnLuZ!qxQ<9<4sM<8tDgm6Z+#u!0< z22uY^MovXh#zY23W8;#d)JAs^eg^SiQ%3eiTOpuy { 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 декабря

+
+ +
+ + +

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

+
+
+ +
+ +