diff --git a/src/admin/pages/OfferDetail.tsx b/src/admin/pages/OfferDetail.tsx
index 1e7b910..16b9472 100644
--- a/src/admin/pages/OfferDetail.tsx
+++ b/src/admin/pages/OfferDetail.tsx
@@ -21,6 +21,8 @@ import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import Checkbox from "@mui/material/Checkbox";
+import useMediaQuery from "@mui/material/useMediaQuery";
+import { useTheme } from "@mui/material/styles";
import {
offerDetailOptions,
offerCustomersOptions,
@@ -229,6 +231,8 @@ function SortableItemRow({
transition,
isDragging,
} = useSortable({ id: item._key, disabled: readOnly });
+ const theme = useTheme();
+ const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const style = {
transform: CSS.Transform.toString(transform),
transition,
@@ -239,6 +243,146 @@ function SortableItemRow({
};
const lineTotal =
(Number(item.quantity) || 0) * (Number(item.unit_price) || 0);
+
+ if (isMobile) {
+ return (
+
+
+ {!readOnly && (
+
+ {DragIcon}
+
+ )}
+
+ Položka {index + 1}
+
+
+ {!readOnly && (
+
+ {RemoveIcon}
+
+ )}
+
+ onUpdate("description", e.target.value)}
+ placeholder="Název položky"
+ InputProps={{ readOnly }}
+ />
+ onUpdate("item_description", e.target.value)}
+ placeholder="Volitelný"
+ InputProps={{ readOnly }}
+ />
+
+ onUpdate("quantity", parseInt(e.target.value, 10))}
+ slotProps={{ htmlInput: { step: "1" } }}
+ InputProps={{ readOnly }}
+ />
+ onUpdate("unit", e.target.value)}
+ InputProps={{ readOnly }}
+ />
+ onUpdate("unit_price", parseFloat(e.target.value))}
+ slotProps={{ htmlInput: { step: "0.01" } }}
+ InputProps={{ readOnly }}
+ />
+
+
+
+
+ onUpdate("is_included_in_total", e.target.checked)
+ }
+ disabled={readOnly}
+ />
+ V ceně
+
+
+
+ Celkem
+
+
+ {formatCurrency(lineTotal, currency)}
+
+
+
+
+ );
+ }
+
return (
{!readOnly && (
@@ -352,6 +496,8 @@ export default function OfferDetail() {
const alert = useAlert();
const { hasPermission } = useAuth();
const navigate = useNavigate();
+ const theme = useTheme();
+ const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const dndSensors = useSensors(
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
useSensor(TouchSensor, {
@@ -1392,76 +1538,95 @@ export default function OfferDetail() {
)}
-
- {
- const { active, over } = event;
- if (!over || active.id === over.id) return;
- setItems((prev) => {
- const oldIndex = prev.findIndex(
- (i) => i._key === String(active.id),
- );
- const newIndex = prev.findIndex(
- (i) => i._key === String(over.id),
- );
- if (oldIndex === -1 || newIndex === -1) return prev;
- return arrayMove(prev, oldIndex, newIndex);
- });
- }}
+ {
+ const { active, over } = event;
+ if (!over || active.id === over.id) return;
+ setItems((prev) => {
+ const oldIndex = prev.findIndex(
+ (i) => i._key === String(active.id),
+ );
+ const newIndex = prev.findIndex(
+ (i) => i._key === String(over.id),
+ );
+ if (oldIndex === -1 || newIndex === -1) return prev;
+ return arrayMove(prev, oldIndex, newIndex);
+ });
+ }}
+ >
+ i._key)}
+ strategy={verticalListSortingStrategy}
>
- i._key)}
- strategy={verticalListSortingStrategy}
- >
-
-
-
- {!readOnly && }
-
- #
-
- Popis
- Množství
- Jednotka
- Cena/ks
-
- V ceně
-
-
- Celkem
-
- {!readOnly && }
-
-
-
- {items.map((item, index) => (
- 1}
- onUpdate={(field, value) =>
- updateItem(index, field as keyof OfferItem, value)
- }
- onRemove={() => removeItem(index)}
- />
- ))}
-
-
-
-
-
+ {isMobile ? (
+
+ {items.map((item, index) => (
+ 1}
+ onUpdate={(field, value) =>
+ updateItem(index, field as keyof OfferItem, value)
+ }
+ onRemove={() => removeItem(index)}
+ />
+ ))}
+
+ ) : (
+
+
+
+
+ {!readOnly && }
+
+ #
+
+ Popis
+ Množství
+ Jednotka
+ Cena/ks
+
+ V ceně
+
+
+ Celkem
+
+ {!readOnly && }
+
+
+
+ {items.map((item, index) => (
+ 1}
+ onUpdate={(field, value) =>
+ updateItem(index, field as keyof OfferItem, value)
+ }
+ onRemove={() => removeItem(index)}
+ />
+ ))}
+
+
+
+ )}
+
+
{/* Totals */}