watering tweak
This commit is contained in:
@@ -175,7 +175,7 @@ const Watering = () => {
|
||||
if (plan) return plan;
|
||||
if (!selectedProperty) { toast.error('Select a property first'); return null; }
|
||||
try {
|
||||
const r = await wateringAPI.createPlan({ propertyId: selectedProperty.id, name: `${selectedProperty.name} - Sprinklers` });
|
||||
const r = await wateringAPI.createPlan({ propertyId: selectedProperty.id, name: `Sprinklers` });
|
||||
const newPlan = r.data?.data?.plan;
|
||||
setPlan(newPlan);
|
||||
// refresh list and clear points
|
||||
@@ -358,6 +358,13 @@ const Watering = () => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="card">
|
||||
<label className="block text-sm font-medium mb-1">Property</label>
|
||||
<select className="input" value={selectedProperty?.id||''} onChange={(e)=> loadProperty(parseInt(e.target.value))}>
|
||||
<option value="">Select property</option>
|
||||
{properties.map(p=> (<option key={p.id} value={p.id}>{p.name}</option>))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="card space-y-2">
|
||||
<div className="font-medium">Plan</div>
|
||||
<div className="flex gap-2 items-center">
|
||||
@@ -366,7 +373,7 @@ const Watering = () => {
|
||||
{plans.map(pl => (<option key={pl.id} value={pl.id}>{pl.name}</option>))}
|
||||
</select>
|
||||
<button className="btn-secondary" disabled={!selectedProperty} onClick={async ()=>{
|
||||
const name = `${selectedProperty?.name || 'Property'} - Sprinklers ${new Date().toLocaleDateString()}`;
|
||||
const name = `Sprinklers ${new Date().toLocaleDateString()}`;
|
||||
const r = await wateringAPI.createPlan({ propertyId: selectedProperty.id, name });
|
||||
const np = r.data?.data?.plan; setPlan(np);
|
||||
const pl = await wateringAPI.getPlans({ property_id: selectedProperty.id });
|
||||
@@ -413,13 +420,6 @@ const Watering = () => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="card">
|
||||
<label className="block text-sm font-medium mb-1">Property</label>
|
||||
<select className="input" value={selectedProperty?.id||''} onChange={(e)=> loadProperty(parseInt(e.target.value))}>
|
||||
<option value="">Select property</option>
|
||||
{properties.map(p=> (<option key={p.id} value={p.id}>{p.name}</option>))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="card space-y-2">
|
||||
<div className="font-medium">Sprinkler Settings</div>
|
||||
<div className="text-sm">Choose Saved Sprinkler</div>
|
||||
|
||||
Reference in New Issue
Block a user