change icon & edit plant

This commit is contained in:
Romulus21 committed 2022-01-14 16:52:43 +01:00
1 parent e9a4550070
commit 05f1d7cbca
12 files changed
+114 -12

No files matched your search

+1 -1
View File
@@ -1 +1 @@
[{"timestamp":1641758728691,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11058,"size":11059,"diff":1},{"filename":"sw.js","previous":11053,"size":11054,"diff":1},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":906,"size":907,"diff":1},{"filename":"bundle.cf62b.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.dfe9a.js","previous":10877,"size":0,"diff":-10877},{"filename":"bundle.08aea.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.ec582.js","previous":0,"size":10878,"diff":10878}]},{"timestamp":1641758670087,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":11058,"diff":10057},{"filename":"sw.js","previous":996,"size":11053,"diff":10057},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":907,"size":906,"diff":-1},{"filename":"bundle.ae28f.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.573ad.js","previous":10878,"size":0,"diff":-10878},{"filename":"bundle.cf62b.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.dfe9a.js","previous":0,"size":10877,"diff":10877}]},{"timestamp":1641758343936,"files":[{"filename":"bundle.*****.esm.js","previous":10283,"size":10239,"diff":-44},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":1001,"diff":0},{"filename":"sw.js","previous":996,"size":996,"diff":0},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1752,"size":1750,"diff":-2},{"filename":"200.html","previous":909,"size":907,"diff":-2},{"filename":"bundle.c150a.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.d96b4.js","previous":10914,"size":0,"diff":-10914},{"filename":"bundle.ae28f.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.573ad.js","previous":0,"size":10878,"diff":10878}]},{"timestamp":1641757866099,"files":[{"filename":"bundle.*****.esm.js","previous":10283,"size":10283,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11014,"size":1001,"diff":-10013},{"filename":"sw.js","previous":11008,"size":996,"diff":-10012},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1753,"size":1752,"diff":-1},{"filename":"200.html","previous":909,"size":909,"diff":0},{"filename":"bundle.5f895.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.624b3.js","previous":10914,"size":0,"diff":-10914},{"filename":"bundle.c150a.css","previous":0,"siLine truncated [{"timestamp":1642168128591,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10203,"diff":-36},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5202,"diff":-10},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5849,"diff":-17},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11059,"size":9742,"diff":-1317},{"filename":"sw.js","previous":11054,"size":9739,"diff":-1315},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":0,"diff":-5725},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":0,"diff":-6400},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1751,"diff":1},{"filename":"200.html","previous":907,"size":908,"diff":1},{"filename":"bundle.08aea.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.ec582.js","previous":10878,"size":0,"diff":-10878},{"filename":"bundle.12687.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.e5e6e.js","previous":0,"size":10842,"diff":10842},{"filename":"route-Home.chunk.53c2c.js","previous":0,"size":5716,"diff":5716},{"filename":"route-Plant.chunk.bf480.js","previous":0,"size":6382,"diff":6382}]},{"timestamp":1641758728691,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11058,"size":11059,"diff":1},{"filename":"sw.js","previous":11053,"size":11054,"diff":1},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":906,"size":907,"diff":1},{"filename":"bundle.cf62b.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.dfe9a.js","previous":10877,"size":0,"diff":-10877},{"filename":"bundle.08aea.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.ec582.js","previous":0,"size":10878,"diff":10878}]},{"timestamp":1641758670087,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":11058,"diff":10057},{"filename":"sw.js","previous":996,"size":11053,"diff":10057},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":907,"size":906,"diff":-1},{"filename":"bundle.ae28f.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.573ad.js","previous":10878,"size":0,"diff":-10878},{"filename":"bundle.cf62b.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.dfe9a.js","previous":0,"size":10877,"diff":10877}]},{"timestamp":1641758343936,"files":[{"filename":"bundle.*****.esm.js","previous":10283,"size":10239,"diff":-44},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":1001,"diff":0},{"filename":"sw.js","previous":996,"size":996,"diff":0},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1752,"size":1750,"diff":-2},{"filename":"200.html","previous":909,"size":907,"diff":-2},{"filename":"bundle.c150aLine truncated
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

+2 -2
View File
@@ -1,7 +1,6 @@
import {classNames} from "../utilities/classNames"; import {classNames} from "../utilities/classNames";
export const InputField = ({children, name, value = "", type = "text", ...props}) => {
export const InputField = ({children, name, type = "text", ...props}) => {
const id = props.id ?? name const id = props.id ?? name
const classStyle = props.className ?? '' const classStyle = props.className ?? ''
@@ -17,6 +16,7 @@ export const InputField = ({children, name, type = "text", ...props}) => {
<input id={id} <input id={id}
name={name} name={name}
type={type} type={type}
value={value}
className="focus:ring-indigo-500 focus:border-indigo-500 block w-full px-2 py-1 mt-1 sm:text-sm border border-gray-300 rounded-md dark:bg-gray-500" className="focus:ring-indigo-500 focus:border-indigo-500 block w-full px-2 py-1 mt-1 sm:text-sm border border-gray-300 rounded-md dark:bg-gray-500"
{...props}/> {...props}/>
</fieldset> </fieldset>
+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="icon.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
units="px"
inkscape:zoom="11.313709"
inkscape:cx="14.363106"
inkscape:cy="36.769553"
inkscape:window-width="2560"
inkscape:window-height="1403"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#000000;stroke-width:0.021906"
d="M 4.5377718,12.05761 C 4.1994548,11.977511 3.7979842,11.796451 3.5561386,11.614901 3.1840467,11.335577 2.8224522,10.773529 2.5265027,10.014477 2.0810926,8.8720867 2.0050802,8.5977957 1.9995488,8.1129597 c -0.00519,-0.454835 0.070428,-0.506841 0.3076026,-0.211559 0.1874978,0.233432 0.3938129,0.432462 0.6533878,0.630312 0.4131031,0.31487 0.8192714,0.562933 1.1600561,0.708491 0.3064949,0.130912 0.4553781,0.172384 0.6262268,0.174439 0.2332332,0.0028 0.3209911,-0.08682 0.2985938,-0.30496 C 5.0301754,8.9612257 4.9165382,8.6915157 4.832857,8.6051787 4.7450247,8.5145577 4.4279614,8.3503937 4.0120276,8.1801807 3.457158,7.9531127 3.3624242,7.9120117 3.135787,7.8000177 2.5423595,7.5067737 2.3747958,7.3102247 2.3149871,6.8372387 c -0.026127,-0.206636 -0.00465,-0.399669 0.098068,-0.882022 0.091869,-0.431339 0.1199369,-0.60435 0.1201508,-0.740621 9.05e-5,-0.05794 0.00895,-0.09992 0.019679,-0.09329 0.010732,0.0066 0.046431,0.0639 0.079328,0.127252 0.1759542,0.338855 0.4525164,0.688153 0.7697606,0.972204 0.1694411,0.151713 0.8471077,0.716211 1.1097391,0.924416 0.2913464,0.230968 0.647747,0.284372 0.8234172,0.123381 0.072622,-0.06655 0.078129,-0.08068 0.07782,-0.199598 -2.601e-4,-0.09911 -0.01445,-0.153737 -0.062947,-0.242227 C 5.2220848,6.5933247 4.5517686,6.0749577 4.4446724,5.9868917 4.3031575,5.8705227 4.1135989,5.7396547 4.0064932,5.6550587 3.6925515,5.4070947 3.2241173,5.1298297 2.9138425,4.8282537 2.7939107,4.7074767 2.7767518,4.6789097 2.7536717,4.5615967 c -0.014216,-0.07226 -0.026267,-0.232274 -0.026772,-0.355579 -7.998e-4,-0.192839 0.00834,-0.251855 0.065356,-0.422024 0.094918,-0.28331 0.2034415,-0.468575 0.5196945,-0.8323 0.065301,-0.0751 0.1854873,-0.214945 0.2097246,-0.241613 0.01634,-0.01798 0.010087,-0.02085 0.095295,-0.0949 0.026722,-0.02218 0.03478,-0.02172 0.041833,0.0024 0.01492,0.05095 0.049965,0.529834 0.062138,0.619417 0.1046194,0.401061 0.3608987,0.74424 0.5135563,1.086243 0.1993188,0.446539 0.3068308,0.624889 0.5638609,0.924908 0.319498,0.372934 0.6512504,0.510917 0.8319382,0.392063 0.1213654,-0.07983 0.095613,-0.106675 0.1251223,-0.155953 0.012431,-0.02076 0.028557,-0.09033 0.031001,-0.189527 0.0015,-0.06049 -0.05976,-0.165852 -0.096426,-0.243524 -0.037989,-0.0811 -0.1081818,-0.180641 -0.1322387,-0.234851 -0.086343,-0.194566 -0.2636691,-0.383509 -0.3448994,-0.508848 -0.021609,-0.03334 -0.050778,-0.06411 -0.058534,-0.07492 -0.014096,-0.01965 -0.068775,-0.100289 -0.086007,-0.125096 C 5.0368619,4.0622137 4.9786172,3.9932237 4.9445858,3.9490307 4.900339,3.8915707 4.7144987,3.6753437 4.6351163,3.5729557 4.5899248,3.5146647 4.5280112,3.4322207 4.5012811,3.3985377 4.3813398,3.2473977 4.3276392,3.1302207 4.2501973,2.9102987 c -0.053326,-0.153825 -0.056459,-0.54779 4.903e-4,-0.714366 0.1483969,-0.329221 0.3406003,-0.419593 0.4948784,-0.501248 0.043322,-0.02293 0.1357776,-0.07444 0.1760327,-0.09899 0.1034662,-0.06308 0.5294131,-0.325994 0.6348057,-0.4068729 0.161734,-0.124115 0.2185001,-0.17753 0.339923,-0.31985604 0.042662,-0.067776 0.096972,-0.1041355 0.1306182,-0.1600499 0.036704,-0.061001 0.043442,-0.10431 0.057588,-0.1047239 0.051534,0.045701 0.1688432,0.1772628 0.2064802,0.2309609 0.01822,0.026002 0.188378,0.17558094 0.256187,0.28041594 0.06722,0.1064849 0.188285,0.1874599 0.317217,0.2859049 0.09988,0.07626 0.234648,0.141781 0.300794,0.185655 0.134957,0.08952 0.303532,0.122576 0.399149,0.256937 0.10437,0.154873 0.114784,0.396788 0.03906,0.907269 -0.03357,0.160176 -0.02242,0.134442 -0.05383,0.261689 -0.05565,0.225423 -0.171176,0.551783 -0.231084,0.7173 -0.06025,0.166448 -0.101942,0.25034 -0.171672,0.444676 -0.0198,0.0582 -0.03373,0.150478 -0.05014,0.208442 -0.257821,0.90339 -0.2756,0.979413 -0.274512,1.173792 0.0017,0.307581 0.06711,0.364078 0.28698,0.262729 0.129084,-0.0595 0.159493,-0.107353 0.186398,-0.134164 0.03011,-0.03 0.08118,-0.07301 0.108724,-0.108527 0.03809,-0.04912 0.115554,-0.202253 0.179741,-0.345041 0.06634,-0.149085 0.189181,-0.575751 0.206388,-0.627383 0.05127,-0.15384 0.265699,-1.255871 0.404436,-1.760271 0.04343,-0.156628 0.08867,-0.320725 0.100539,-0.364659 0.04365,-0.161613 0.139564,-0.123879 0.345588,0.154577 0.151099,0.204222 0.320683,0.465967 0.463632,0.681689 0.08802,0.132825 0.212762,0.295317 0.277383,0.360979 0.118124,0.120027 0.140644,0.143956 0.118928,0.306526 -0.02671,0.199985 -0.113477,0.338288 -0.158081,0.396351 -0.02744,0.03571 -0.142803,0.158663 -0.17936,0.197589 -0.118153,0.125809 -0.197102,0.19847 -0.359964,0.343554 -0.256774,0.228743 -0.422777,0.471247 -0.634231,0.706812 -0.131832,0.146864 -0.532008,0.586887 -0.783567,1.135324 -0.09071,0.197753 -0.07788,0.386058 -0.01314,0.508532 0.249015,0.471128 0.483972,0.114265 0.690762,-0.159529 0.276104,-0.365275 0.489589,-0.595091 0.787319,-0.916129 0.129205,-0.139321 0.401463,-0.55509 0.556665,-0.814076 0.175409,-0.290543 0.290461,-0.525355 0.377204,-0.769849 0.04815,-0.135703 0.07847,-0.194286 0.09071,-0.175248 0.08163,0.126905 0.2142762,0.579787 0.2810672,0.959604 0.143313,0.814975 0.14304,1.257841 -9.5e-4,1.564Line truncated
id="path854"
sodipodi:nodetypes="cssssssssssssscssssscssscssssscscssssscsssssssccssscscscssccssccsssscscssssssssssscscscsssscssssssssssssssssccsssssccsssssssssssssssssssssssscssssssssssss" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.5 KiB

+8
View File
@@ -1,6 +1,10 @@
import App from './components/App'; import App from './components/App';
import './style'; import './style';
Number.prototype.pad = function(n) {
return (new Array(n).join('0') + this).slice(-n)
}
Date.prototype.addDays = function (days) { Date.prototype.addDays = function (days) {
let date = new Date(this.valueOf()); let date = new Date(this.valueOf());
date.setDate(date.getDate() + days); date.setDate(date.getDate() + days);
@@ -12,4 +16,8 @@ Date.prototype.toFrDate = function() {
return `${this.getDate()}/${month}/${this.getFullYear()}` return `${this.getDate()}/${month}/${this.getFullYear()}`
} }
Date.prototype.toSQLDate = function() {
return `${this.getFullYear()}-${Number(this.getMonth() + 1).pad(2)}-${Number(this.getDate()).pad(2)}`
}
export default App; export default App;
+55 -9
View File
@@ -4,7 +4,7 @@ import {Button, SmallButton} from "../components/Button"
import {Modal, ModalTitle} from "../components/Modals" import {Modal, ModalTitle} from "../components/Modals"
import { PageLayout } from "../components/PageLayout" import { PageLayout } from "../components/PageLayout"
import { PlantsContext } from "../Contexts" import { PlantsContext } from "../Contexts"
import {InputField, SelectField} from "../components/Form" import {InputField, SelectField, TextAreaField} from "../components/Form"
import {getPicture, storePicture} from "../utilities/pictures" import {getPicture, storePicture} from "../utilities/pictures"
import {EditSVG, PlusSVG} from "../components/SVG"; import {EditSVG, PlusSVG} from "../components/SVG";
import {classNames} from "../utilities/classNames"; import {classNames} from "../utilities/classNames";
@@ -12,7 +12,9 @@ import {classNames} from "../utilities/classNames";
const Plant = ({id}) => { const Plant = ({id}) => {
const [addModal, setAddModal] = useState(false) const [addModal, setAddModal] = useState(false)
const {plants, removePlant, addAction, doneTask, history} = useContext(PlantsContext) const [editModal, setEditModal] = useState(false)
const [plantForm, setPlantForm] = useState({})
const {plants, editPlant, removePlant, addAction, doneTask, history} = useContext(PlantsContext)
const [plant, setPlant] = useState({}) const [plant, setPlant] = useState({})
const [actionForm, setActionForm] = useState({}) const [actionForm, setActionForm] = useState({})
const [image, setImage] = useState(localStorage.getItem("image" + id) ?? '') const [image, setImage] = useState(localStorage.getItem("image" + id) ?? '')
@@ -21,7 +23,6 @@ const Plant = ({id}) => {
const action_types = ['watering', 'spraying', 'bathing'] const action_types = ['watering', 'spraying', 'bathing']
useEffect(() => { useEffect(() => {
const plantFind = plants.find(plant => plant.id === Number(id)) const plantFind = plants.find(plant => plant.id === Number(id))
setPlant(plantFind) setPlant(plantFind)
@@ -41,22 +42,45 @@ const Plant = ({id}) => {
setAddModal(false) setAddModal(false)
} }
const handleEditSubmit = (e) => {
e.preventDefault()
e.stopPropagation()
editPlant(plantForm)
setEditModal(false)
setPlant(plantForm)
}
const isCloseModal = e => e.target.classList.contains("overlay") || e.target.classList.contains("close-button")
const handleCloseAddModal = (e) => { const handleCloseAddModal = (e) => {
if (e.target.classList.contains("overlay") || e.target.classList.contains("close-button")) { if (isCloseModal(e)) {
setAddModal(false) setAddModal(false)
} }
} }
const handleOpenEditModal = () => {
setEditModal(true)
console.log(plant)
setPlantForm(plant)
}
const handleCloseEditModal = (e) => {
if (isCloseModal(e)) {
setEditModal(false)
}
}
const addPicture = e => storePicture(e, id) const addPicture = e => storePicture(e, id)
return <PageLayout> return <PageLayout>
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<h1>{ plant.name }</h1> <h1 className="my-2 flex-1 text-center">{ plant.name }</h1>
<div> <div>
<Button className="bg-red-500" onClick={() => removePlant(plant)}>Delete</Button> <Button className="bg-blue-500" onClick={() => handleOpenEditModal()}>Edit</Button>
{/*<Button className="bg-red-500" onClick={() => removePlant(plant)}>Delete</Button>*/}
</div> </div>
</div> </div>
<p>{ plant.description }</p> <div className="flex justify-around flex-wrap gap-5">
<div className="relative"> <div className="relative">
<img id="picture" ref={picture} src={getPicture(id)} alt=""/> <img id="picture" ref={picture} src={getPicture(id)} alt=""/>
<SmallButton className="absolute top-2 left-2 cursor-pointer bg-blue-500 hover:bg-blue-700 max-w-[300px]"> <SmallButton className="absolute top-2 left-2 cursor-pointer bg-blue-500 hover:bg-blue-700 max-w-[300px]">
@@ -66,6 +90,8 @@ const Plant = ({id}) => {
</label> </label>
</SmallButton> </SmallButton>
</div> </div>
<p className="flex-1">{ plant.description }</p>
</div>
<div> <div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<h2>Actions</h2> <h2>Actions</h2>
@@ -78,10 +104,12 @@ const Plant = ({id}) => {
let lastTask = false let lastTask = false
if (history()[action.id]) { if (history()[action.id]) {
lastTask = new Date(history()[action.id]) lastTask = new Date(history()[action.id])
isDone = lastTask.addDays(Number(action.frequency)) < (new Date()) isDone = lastTask.addDays(Number(action.frequency)).toSQLDate() >= (new Date()).toSQLDate()
} }
return <div key={action.action_type} className="flex items-center gap-2 my-2"> return <div key={action.action_type} className="flex items-center gap-2 my-2">
<span><Button className={classNames(isDone ? "bg-green-500 hover:bg-green-700" : "bg-blue-500 hover:bg-blue-700")} onClick={() => doneTask(action.id)}>Done</Button></span> <span>
<Button className={classNames(isDone ? "bg-green-500 hover:bg-green-700" : "bg-blue-500 hover:bg-blue-700")} onClick={() => doneTask(action.id)}>Done</Button>
</span>
<span className="capitalize">{action.action_type}</span> <span className="capitalize">{action.action_type}</span>
<span>every {action.frequency} days</span> <span>every {action.frequency} days</span>
<span className="text-gray-500">last task {lastTask ? lastTask.toFrDate() : 'never'}</span> <span className="text-gray-500">last task {lastTask ? lastTask.toFrDate() : 'never'}</span>
@@ -104,6 +132,24 @@ const Plant = ({id}) => {
</Modal>, </Modal>,
app app
)} )}
{createPortal(
<Modal isOpen={editModal} onChange={handleCloseEditModal}>
<ModalTitle>
Edit Plant
</ModalTitle>
<form onSubmit={handleEditSubmit}>
<InputField name="name" className="mb-2 mt-5" value={plantForm.name} onChange={(e) => setPlantForm({ ...plantForm, name: e.target.value }) }>Name</InputField>
<TextAreaField name="description" className="mb-5" value={plantForm.description} onChange={(e) => setPlantForm({ ...plantForm, description: e.target.value })}>Description</TextAreaField>
<Button type="submit" className="block w-full mt-5 mb-2 bg-green-800 hover:bg-green-900 text-white mx-auto px-2 py-1 shadow">
Edit
</Button>
</form>
</Modal>,
app
)}
</PageLayout> </PageLayout>
} }