new features
This commit is contained in:
@@ -23,8 +23,6 @@ import { SHOP_STATUS_LABELS, SHOP_STATUS_COLORS } from '../types/shop.types';
|
||||
import type { ShopArtikel, ShopArtikelFormData, ShopAnfrageFormItem, ShopAnfrageDetailResponse, ShopAnfrageStatus } from '../types/shop.types';
|
||||
import type { Bestellung } from '../types/bestellung.types';
|
||||
|
||||
const priceFormat = new Intl.NumberFormat('de-AT', { style: 'currency', currency: 'EUR' });
|
||||
|
||||
// ─── Catalog Tab ────────────────────────────────────────────────────────────
|
||||
|
||||
interface DraftItem {
|
||||
@@ -116,7 +114,7 @@ function KatalogTab() {
|
||||
};
|
||||
const openEditArtikel = (a: ShopArtikel) => {
|
||||
setEditArtikel(a);
|
||||
setArtikelForm({ bezeichnung: a.bezeichnung, beschreibung: a.beschreibung, kategorie: a.kategorie, geschaetzter_preis: a.geschaetzter_preis });
|
||||
setArtikelForm({ bezeichnung: a.bezeichnung, beschreibung: a.beschreibung, kategorie: a.kategorie });
|
||||
setArtikelDialogOpen(true);
|
||||
};
|
||||
const saveArtikel = () => {
|
||||
@@ -173,12 +171,11 @@ function KatalogTab() {
|
||||
<CardContent sx={{ flexGrow: 1 }}>
|
||||
<Typography variant="subtitle1" fontWeight={600}>{item.bezeichnung}</Typography>
|
||||
{item.beschreibung && <Typography variant="body2" color="text.secondary" sx={{ mt: 0.5 }}>{item.beschreibung}</Typography>}
|
||||
<Box sx={{ display: 'flex', gap: 1, mt: 1, alignItems: 'center' }}>
|
||||
{item.kategorie && <Chip label={item.kategorie} size="small" />}
|
||||
{item.geschaetzter_preis != null && (
|
||||
<Typography variant="body2" color="text.secondary">ca. {priceFormat.format(item.geschaetzter_preis)}</Typography>
|
||||
)}
|
||||
</Box>
|
||||
{item.kategorie && (
|
||||
<Box sx={{ mt: 1 }}>
|
||||
<Chip label={item.kategorie} size="small" />
|
||||
</Box>
|
||||
)}
|
||||
</CardContent>
|
||||
<CardActions sx={{ justifyContent: 'space-between' }}>
|
||||
{canCreate && (
|
||||
@@ -197,10 +194,12 @@ function KatalogTab() {
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
{/* Custom item + draft summary */}
|
||||
{canCreate && draft.length > 0 && (
|
||||
{/* Free-text item + draft summary */}
|
||||
{canCreate && (
|
||||
<Paper variant="outlined" sx={{ mt: 3, p: 2 }}>
|
||||
<Typography variant="subtitle2" sx={{ mb: 1 }}>Anfrage-Entwurf</Typography>
|
||||
<Typography variant="subtitle2" sx={{ mb: 1 }}>
|
||||
{draft.length > 0 ? 'Anfrage-Entwurf' : 'Freitext-Position hinzufügen'}
|
||||
</Typography>
|
||||
{draft.map((d, idx) => (
|
||||
<Box key={idx} sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 0.5 }}>
|
||||
<Typography variant="body2" sx={{ flexGrow: 1 }}>{d.bezeichnung}</Typography>
|
||||
@@ -208,12 +207,14 @@ function KatalogTab() {
|
||||
<IconButton size="small" onClick={() => removeDraftItem(idx)}><DeleteIcon fontSize="small" /></IconButton>
|
||||
</Box>
|
||||
))}
|
||||
<Divider sx={{ my: 1 }} />
|
||||
{draft.length > 0 && <Divider sx={{ my: 1 }} />}
|
||||
<Box sx={{ display: 'flex', gap: 1 }}>
|
||||
<TextField size="small" placeholder="Eigener Artikel (Freitext)" value={customText} onChange={e => setCustomText(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') addCustomToDraft(); }} sx={{ flexGrow: 1 }} />
|
||||
<Button size="small" onClick={addCustomToDraft} disabled={!customText.trim()}>Hinzufügen</Button>
|
||||
</Box>
|
||||
<Button variant="contained" sx={{ mt: 1.5 }} startIcon={<ShoppingCart />} onClick={() => setSubmitOpen(true)}>Anfrage absenden</Button>
|
||||
{draft.length > 0 && (
|
||||
<Button variant="contained" sx={{ mt: 1.5 }} startIcon={<ShoppingCart />} onClick={() => setSubmitOpen(true)}>Anfrage absenden</Button>
|
||||
)}
|
||||
</Paper>
|
||||
)}
|
||||
|
||||
@@ -246,13 +247,6 @@ function KatalogTab() {
|
||||
onInputChange={(_, val) => setArtikelForm(f => ({ ...f, kategorie: val || undefined }))}
|
||||
renderInput={params => <TextField {...params} label="Kategorie" />}
|
||||
/>
|
||||
<TextField
|
||||
label="Geschätzter Preis (EUR)"
|
||||
type="number"
|
||||
value={artikelForm.geschaetzter_preis ?? ''}
|
||||
onChange={e => setArtikelForm(f => ({ ...f, geschaetzter_preis: e.target.value ? Number(e.target.value) : undefined }))}
|
||||
inputProps={{ min: 0, step: 0.01 }}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setArtikelDialogOpen(false)}>Abbrechen</Button>
|
||||
@@ -607,7 +601,7 @@ export default function Shop() {
|
||||
<Typography variant="h5" fontWeight={700} sx={{ mb: 2 }}>Shop</Typography>
|
||||
|
||||
<Box sx={{ borderBottom: 1, borderColor: 'divider', mb: 3 }}>
|
||||
<Tabs value={activeTab} onChange={handleTabChange}>
|
||||
<Tabs value={activeTab} onChange={handleTabChange} variant="scrollable" scrollButtons="auto">
|
||||
<Tab label="Katalog" />
|
||||
{canCreate && <Tab label="Meine Anfragen" />}
|
||||
{canApprove && <Tab label="Alle Anfragen" />}
|
||||
|
||||
Reference in New Issue
Block a user