From c26de5aefc3cf3126d24f65dc06f0641bdc5165e Mon Sep 17 00:00:00 2001 From: MinhNN Date: Mon, 10 Nov 2025 16:11:02 +0700 Subject: [PATCH] update netListTable, CreateOrUpdateHaulModal --- components/tripInfo/NetListTable.tsx | 14 +- .../modal/CreateOrUpdateHaulModal.tsx | 223 +++++++++++------- 2 files changed, 149 insertions(+), 88 deletions(-) diff --git a/components/tripInfo/NetListTable.tsx b/components/tripInfo/NetListTable.tsx index 949d931..952c3a6 100644 --- a/components/tripInfo/NetListTable.tsx +++ b/components/tripInfo/NetListTable.tsx @@ -96,7 +96,12 @@ const NetListTable: React.FC = () => { {/* Cột Trạng thái */} - + handleStatusPress(item.fishing_log_id)} > @@ -125,7 +130,12 @@ const NetListTable: React.FC = () => { {/* Cột Trạng thái */} - + handleStatusPress(item.fishing_log_id)} > diff --git a/components/tripInfo/modal/CreateOrUpdateHaulModal.tsx b/components/tripInfo/modal/CreateOrUpdateHaulModal.tsx index 60d41ed..77c063d 100644 --- a/components/tripInfo/modal/CreateOrUpdateHaulModal.tsx +++ b/components/tripInfo/modal/CreateOrUpdateHaulModal.tsx @@ -36,6 +36,14 @@ const UNITS_OPTIONS = UNITS.map((unit) => ({ value: unit.toString(), })); +const SIZE_UNITS = ["cm", "m"] as const; +type SizeUnit = (typeof SIZE_UNITS)[number]; + +const SIZE_UNITS_OPTIONS = SIZE_UNITS.map((unit) => ({ + label: unit, + value: unit, +})); + // Zod schema cho 1 dòng cá const fishItemSchema = z.object({ id: z.number().min(1, "Chọn loài cá"), @@ -47,6 +55,7 @@ const fishItemSchema = z.object({ .number({ invalid_type_error: "Kích thước phải là số" }) .positive("Kích thước > 0") .optional(), + sizeUnit: z.enum(SIZE_UNITS), }); // Schema tổng: mảng các item @@ -60,6 +69,7 @@ const defaultItem = (): FormValues["fish"][number] => ({ quantity: 1, unit: "con", size: undefined, + sizeUnit: "cm", }); const CreateOrUpdateHaulModal: React.FC = ({ @@ -210,6 +220,7 @@ const CreateOrUpdateHaulModal: React.FC = ({ quantity: (h.catch_number as number) ?? 1, unit: (h.catch_unit as Unit) ?? (defaultItem().unit as Unit), size: (h.fish_size as number) ?? undefined, + sizeUnit: "cm" as SizeUnit, })); reset({ fish: mapped as any }); setIsCreateMode(false); @@ -225,9 +236,11 @@ const CreateOrUpdateHaulModal: React.FC = ({ }, [isVisible, fishingLog?.info, reset]); const renderRow = (item: any, index: number) => { const isExpanded = expandedFishIndices.includes(index); + // Give expanded card highest zIndex, others get decreasing zIndex based on position + const cardZIndex = isExpanded ? 1000 : 100 - index; return ( - + {/* Delete + Chevron buttons - top right corner */} = ({ {/* Form - visible when expanded */} {isExpanded && ( - + {/* Species dropdown */} ( - + Tên cá ({ + label: unit.label, + value: unit.value, + }))} + value={value} + onChange={onChange} + placeholder="Chọn đơn vị" + disabled={!isEditing} + listStyle={{ maxHeight: 100 }} + /> + {errors.fish?.[index]?.unit && ( + + {errors.fish[index]?.unit?.message as string} + + )} + + )} + /> + + - {/* Unit dropdown */} - ( - - Đơn vị - + )} - - )} - /> + /> + + )} @@ -447,15 +493,20 @@ const CreateOrUpdateHaulModal: React.FC = ({ {isEditing ? ( <> - { - setIsEditing(false); - reset(); // reset to previous values - }} - style={[styles.saveButton, { backgroundColor: "#6c757d" }]} - > - Hủy - + {!isCreateMode && ( + { + setIsEditing(false); + reset(); // reset to previous values + }} + style={[ + styles.saveButton, + { backgroundColor: "#6c757d" }, + ]} + > + Hủy + + )}