Web: "Entfernen" nur zeigen, wenn ein Artikelbild vorliegt
Der Entfernen-Knopf stand auch ohne Bild da. ProduktBild meldet jetzt via onLoaded, ob ein Bild geladen wurde; das Produktformular blendet "Entfernen" entsprechend ein oder aus. "Foto machen" und "Galerie" bleiben immer sichtbar. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,8 @@ export default function ProductForm() {
|
||||
const [offDaten, setOffDaten] = useState(null);
|
||||
const [offBusy, setOffBusy] = useState(false);
|
||||
const [bildVersion, setBildVersion] = useState(0);
|
||||
// Ob gerade ein Bild vorliegt – steuert, ob „Entfernen" angeboten wird.
|
||||
const [hatBild, setHatBild] = useState(false);
|
||||
|
||||
const selectedUnit = units.find((u) => String(u.id) === String(form.unit_id)) || null;
|
||||
const unitFactor = selectedUnit ? selectedUnit.factor : 1;
|
||||
@@ -561,7 +563,7 @@ export default function ProductForm() {
|
||||
</div>
|
||||
{!isNew && (
|
||||
<div className="produkt-foto">
|
||||
<ProduktBild productId={id} alt={form.name} version={bildVersion} />
|
||||
<ProduktBild productId={id} alt={form.name} version={bildVersion} onLoaded={setHatBild} />
|
||||
{isAdmin && (
|
||||
<div className="foto-knoepfe">
|
||||
<label className="btn sm" title="Mit der Kamera aufnehmen">
|
||||
@@ -572,7 +574,9 @@ export default function ProductForm() {
|
||||
Galerie
|
||||
<input hidden type="file" accept="image/*" onChange={onPickPhoto} />
|
||||
</label>
|
||||
<button type="button" className="btn sm ghost" onClick={removePhoto}>Entfernen</button>
|
||||
{hatBild && (
|
||||
<button type="button" className="btn sm ghost" onClick={removePhoto}>Entfernen</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user