admin seeds

This commit is contained in:
Jake Kasper
2025-09-03 14:47:28 -04:00
parent 19314b301f
commit d201ab3d56

View File

@@ -270,6 +270,58 @@ const AdminProducts = () => {
const ProductForm = ({ onSubmit, submitText }) => (
<form onSubmit={onSubmit} className="space-y-4">
{/* Live Preview */}
<div className="border rounded-lg p-4 bg-white shadow-sm">
<div className="flex justify-between items-start mb-2">
<div>
<h3 className="font-semibold text-gray-900">{formData.name || 'Untitled Product'}</h3>
{formData.brand && <p className="text-sm text-gray-600">{formData.brand}</p>}
</div>
<span className={`px-2 py-1 text-xs font-medium rounded-full ${
formData.productType === 'liquid' ? 'bg-blue-100 text-blue-800' :
formData.productType === 'granular' ? 'bg-green-100 text-green-800' :
formData.productType === 'seed' ? 'bg-yellow-100 text-yellow-800' :
'bg-gray-100 text-gray-800'
}`}>
{formData.productType || '—'}
</span>
</div>
{formData.productType === 'seed' ? (
<div className="mt-2">
<p className="text-sm font-medium text-gray-900">Seed Blend:</p>
{(formData.seedBlend||[]).length === 0 ? (
<p className="text-sm text-gray-600">No blend details</p>
) : (
<div className="mt-1 flex flex-wrap gap-2">
{formData.seedBlend.map((b,idx)=> (
<span key={idx} className="px-2 py-1 bg-gray-100 rounded text-xs text-gray-800">{b.cultivar} {parseFloat(b.percent||0).toFixed(1)}%</span>
))}
</div>
)}
{/* Rates Preview */}
<div className="bg-gray-50 rounded mt-3 p-3">
<p className="text-sm font-medium text-gray-900 mb-1">Application Rates</p>
{(() => {
const newRate = (formData.rates||[]).find(r=> (r.applicationType||'').toLowerCase().includes('new'));
const overRate = (formData.rates||[]).find(r=> (r.applicationType||'').toLowerCase().includes('over'));
return (
<>
{newRate && <div className="text-sm text-gray-700">New Lawn: {newRate.rateAmount} {newRate.rateUnit}</div>}
{overRate && <div className="text-sm text-gray-700">Overseeding: {overRate.rateAmount} {overRate.rateUnit}</div>}
{!newRate && !overRate && (formData.rates||[]).slice(0,2).map((r,i)=> (
<div key={i} className="text-sm text-gray-700">{r.applicationType}: {r.rateAmount} {r.rateUnit}</div>
))}
</>
);
})()}
</div>
</div>
) : (
formData.activeIngredients && (
<p className="text-sm text-gray-700 mt-2"><strong>Active Ingredients:</strong> {formData.activeIngredients}</p>
)
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
@@ -330,17 +382,17 @@ const AdminProducts = () => {
</div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Active Ingredients
</label>
<textarea
value={formData.activeIngredients}
onChange={(e) => setFormData({ ...formData, activeIngredients: e.target.value })}
rows="3"
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
{formData.productType !== 'seed' && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Active Ingredients</label>
<textarea
value={formData.activeIngredients}
onChange={(e) => setFormData({ ...formData, activeIngredients: e.target.value })}
rows="3"
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
)}
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">