update seed blend
This commit is contained in:
@@ -45,6 +45,7 @@ const AdminProducts = () => {
|
||||
productType: 'granular',
|
||||
activeIngredients: '',
|
||||
description: '',
|
||||
seedBlend: [],
|
||||
rates: [{ applicationType: 'granular', rateAmount: '', rateUnit: 'lbs/1000 sq ft', notes: '' }]
|
||||
});
|
||||
|
||||
@@ -201,6 +202,7 @@ const AdminProducts = () => {
|
||||
productType: 'granular',
|
||||
activeIngredients: '',
|
||||
description: '',
|
||||
seedBlend: [],
|
||||
rates: [{ applicationType: 'granular', rateAmount: '', rateUnit: 'lbs/1000 sq ft', notes: '' }]
|
||||
});
|
||||
setSelectedProduct(null);
|
||||
@@ -215,6 +217,7 @@ const AdminProducts = () => {
|
||||
productType: product.productType || product.customProductType || 'granular',
|
||||
activeIngredients: product.activeIngredients || product.customActiveIngredients || '',
|
||||
description: product.description || product.customDescription || '',
|
||||
seedBlend: product.seedBlend || [],
|
||||
rates: product.rates && product.rates.length > 0 ? product.rates : [{
|
||||
applicationType: product.productType || 'granular',
|
||||
rateAmount: product.customRateAmount || '',
|
||||
@@ -340,6 +343,67 @@ const AdminProducts = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Seed blend editor */}
|
||||
{formData.productType === 'seed' && (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<label className="block text-sm font-medium text-gray-700">Seed Blend (Cultivars + %)</label>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFormData({ ...formData, seedBlend: [...(formData.seedBlend||[]), { cultivar: '', percent: '' }] })}
|
||||
className="text-sm text-blue-600 hover:text-blue-800"
|
||||
>
|
||||
+ Add Cultivar
|
||||
</button>
|
||||
</div>
|
||||
{(formData.seedBlend && formData.seedBlend.length > 0) ? (
|
||||
<div className="space-y-2">
|
||||
{formData.seedBlend.map((row, idx) => (
|
||||
<div key={idx} className="grid grid-cols-6 gap-2 items-center">
|
||||
<input
|
||||
className="col-span-4 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="Cultivar name"
|
||||
value={row.cultivar}
|
||||
onChange={(e)=> {
|
||||
const next = [...formData.seedBlend];
|
||||
next[idx] = { ...next[idx], cultivar: e.target.value };
|
||||
setFormData({ ...formData, seedBlend: next });
|
||||
}}
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
step="0.1"
|
||||
className="col-span-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="%"
|
||||
value={row.percent}
|
||||
onChange={(e)=> {
|
||||
const next = [...formData.seedBlend];
|
||||
next[idx] = { ...next[idx], percent: e.target.value };
|
||||
setFormData({ ...formData, seedBlend: next });
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="text-red-600"
|
||||
onClick={()=> {
|
||||
const next = (formData.seedBlend||[]).filter((_,i)=> i!==idx);
|
||||
setFormData({ ...formData, seedBlend: next });
|
||||
}}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<div className="text-xs text-gray-600">
|
||||
Total: {((formData.seedBlend||[]).reduce((s,r)=> s + (parseFloat(r.percent)||0), 0)).toFixed(1)}%
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm text-gray-500">No cultivars added yet.</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Application Rates */}
|
||||
<div>
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
@@ -912,4 +976,4 @@ const AdminProducts = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminProducts;
|
||||
export default AdminProducts;
|
||||
|
||||
Reference in New Issue
Block a user