Compare commits

...

2 Commits

Author SHA1 Message Date
Tran Anh Tuan
4d821646cf cập nhật modal add/edit fishingLog và sửa lỗi event ở map 2025-11-07 18:54:44 +07:00
c02b61163d Update from master 2025-11-07 17:56:13 +07:00
10 changed files with 261 additions and 510 deletions

View File

@@ -1,12 +1,32 @@
import { Tabs } from "expo-router";
import { Tabs, useSegments } from "expo-router";
import { HapticTab } from "@/components/haptic-tab";
import { IconSymbol } from "@/components/ui/icon-symbol";
import { Colors } from "@/constants/theme";
import { useColorScheme } from "@/hooks/use-color-scheme";
import { startEvents, stopEvents } from "@/services/device_events";
import { useEffect, useRef } from "react";
export default function TabLayout() {
const colorScheme = useColorScheme();
const segments = useSegments();
const prev = useRef<string | null>(null);
const currentSegment = segments[1] ?? segments[segments.length - 1] ?? null; // tuỳ cấu trúc của bạn
useEffect(() => {
if (prev.current !== currentSegment) {
// console.log("Tab changed ->", { from: prev.current, to: currentSegment });
// TODO: xử lý khi chuyển tab ở đây
if (prev.current === "(tabs)" && currentSegment !== "(tabs)") {
stopEvents();
// console.log("Stop events");
} else if (prev.current !== "(tabs)" && currentSegment === "(tabs)") {
// we came back into the tabs group — restart polling
startEvents();
// console.log("start events");
}
prev.current = currentSegment;
}
}, [currentSegment]);
return (
<Tabs

View File

@@ -9,7 +9,7 @@ export default function Warning() {
<SafeAreaView style={{ flex: 1 }}>
<View style={styles.container}>
<CreateOrUpdateHaulModal
haulData={fishingInfoDatas}
fishingLog={fishingLogData}
isVisible={isShowModal}
onClose={function (): void {
setIsShowModal(false);
@@ -54,105 +54,118 @@ const styles = StyleSheet.create({
},
});
const fishingInfoDatas: Model.FishingLogInfo[] = [
{
fish_species_id: 10,
fish_name: "Cá quỷ biển (Barracuda)",
catch_number: 820,
catch_unit: "kg",
fish_size: 29,
fish_rarity: 1,
fish_condition: "Bị thương",
gear_usage: "",
},
{
fish_species_id: 1,
fish_name: "Cá thu",
catch_number: 1293,
catch_unit: "kg",
fish_size: 37,
fish_rarity: 1,
fish_condition: "Bị thương",
gear_usage: "",
},
{
fish_species_id: 13,
fish_name: "Cá song đỏ",
catch_number: 1738,
catch_unit: "kg",
fish_size: 28,
fish_rarity: 2,
fish_condition: "Còn sống",
gear_usage: "",
},
{
fish_species_id: 17,
fish_name: "Cá nược",
catch_number: 690,
catch_unit: "kg",
fish_size: 63,
fish_rarity: 1,
fish_condition: "Chết",
gear_usage: "",
},
{
fish_species_id: 19,
fish_name: "Cá hổ Thái Lan",
catch_number: 825,
catch_unit: "kg",
fish_size: 55,
fish_rarity: 4,
fish_condition: "Chết",
gear_usage: "Câu tay",
},
{
fish_species_id: 8,
fish_name: "Cá hồng phớn",
catch_number: 1409,
catch_unit: "kg",
fish_size: 172,
fish_rarity: 3,
fish_condition: "Chết",
gear_usage: "Bẫy lưới",
},
{
fish_species_id: 16,
fish_name: "Cá rồng biển",
catch_number: 1426,
catch_unit: "kg",
fish_size: 105,
fish_rarity: 3,
fish_condition: "Chết",
gear_usage: "Lưới rê",
},
{
fish_species_id: 3,
fish_name: "Cá chim trắng",
catch_number: 176,
catch_unit: "kg",
fish_size: 83,
fish_rarity: 2,
fish_condition: "Chết",
gear_usage: "",
},
{
fish_species_id: 14,
fish_name: "Cá mú cườm",
catch_number: 724,
catch_unit: "kg",
fish_size: 36,
fish_rarity: 2,
fish_condition: "Chết",
gear_usage: "",
},
{
fish_species_id: 18,
fish_name: "Cá đuối quạt",
catch_number: 1712,
catch_unit: "kg",
fish_size: 105,
fish_rarity: 4,
fish_condition: "Còn sống",
gear_usage: "Câu vàng",
},
];
const fishingLogData:Model.FishingLog = {
fishing_log_id: "124b2701-a5d6-4eb0-ba3b-6789473c14a9",
trip_id: "d84caab6-ebb0-4cf7-abf9-31e5617d23b9",
start_at: "2025-11-07T10:50:01.693193764Z",
end_at: "2025-11-07T10:50:31.693027729Z",
start_lat: 11.59141,
start_lon: 109.0489,
haul_lat: 11.590274,
haul_lon: 109.049284,
status: 1,
weather_description: "Stormy",
info: [
{
fish_species_id: 8,
fish_name: "Cá hồng phớn",
catch_number: 1309,
catch_unit: "kg",
fish_size: 173,
fish_rarity: 3,
fish_condition: "Còn sống",
gear_usage: "Câu vàng",
},
{
fish_species_id: 18,
fish_name: "Cá đuối quạt",
catch_number: 731,
catch_unit: "kg",
fish_size: 16,
fish_rarity: 4,
fish_condition: "Chết",
gear_usage: "Bẫy lưới",
},
{
fish_species_id: 7,
fish_name: "Cá bơn vàng",
catch_number: 1224,
catch_unit: "kg",
fish_size: 12,
fish_rarity: 1,
fish_condition: "Chết",
gear_usage: "",
},
{
fish_species_id: 16,
fish_name: "Cá rồng biển",
catch_number: 838,
catch_unit: "kg",
fish_size: 164,
fish_rarity: 3,
fish_condition: "Chết",
gear_usage: "Lưới rê",
},
{
fish_species_id: 9,
fish_name: "Cá hổ Napoleon",
catch_number: 1410,
catch_unit: "kg",
fish_size: 104,
fish_rarity: 4,
fish_condition: "Bị thương",
gear_usage: "Câu vàng",
},
{
fish_species_id: 3,
fish_name: "Cá chim trắng",
catch_number: 1184,
catch_unit: "kg",
fish_size: 104,
fish_rarity: 2,
fish_condition: "Còn sống",
gear_usage: "",
},
{
fish_species_id: 5,
fish_name: "Cá mú đỏ",
catch_number: 987,
catch_unit: "kg",
fish_size: 171,
fish_rarity: 2,
fish_condition: "Bị thương",
gear_usage: "",
},
{
fish_species_id: 13,
fish_name: "Cá song đỏ",
catch_number: 1676,
catch_unit: "kg",
fish_size: 99,
fish_rarity: 2,
fish_condition: "Bị thương",
gear_usage: "",
},
{
fish_species_id: 11,
fish_name: "Cá ngừ đại dương",
catch_number: 462,
catch_unit: "kg",
fish_size: 11,
fish_rarity: 1,
fish_condition: "Bị thương",
gear_usage: "",
},
{
fish_species_id: 2,
fish_name: "Cá nục",
catch_number: 496,
catch_unit: "kg",
fish_size: 125,
fish_rarity: 1,
fish_condition: "Còn sống",
gear_usage: "",
},
],
sync: true,
};

View File

@@ -56,11 +56,6 @@ export default function HomeScreen() {
const scale = useRef(new Animated.Value(0)).current;
const opacity = useRef(new Animated.Value(1)).current;
// console.log("Platform: ", platform);
// console.log("Theme: ", theme);
// const [number, setNumber] = useState(0);
useEffect(() => {
getGpsEventBus();
getAlarmEventBus();
@@ -124,6 +119,7 @@ export default function HomeScreen() {
// console.log("Unsubscribed EVENT_TRACK_POINTS_DATA");
};
}, []);
useEffect(() => {
setPolylineCoordinates(null);
setPolygonCoordinates([]);
@@ -178,7 +174,7 @@ export default function HomeScreen() {
// foundPolygon = true;
const coordinates = convertWKTtoLatLngString(geom_poly || "");
if (coordinates.length > 0) {
console.log("Polygon Coordinate: ", coordinates);
// console.log("Polygon Coordinate: ", coordinates);
setPolygonCoordinates(
coordinates.map((polygon) => ({
coordinates: polygon.map((coord) => ({

View File

@@ -94,7 +94,7 @@ const ButtonCreateNewHaulOrTrip: React.FC<StartButtonProps> = ({
});
if (resp.status === 200) {
showSuccessToast("Bắt đầu chuyến đi thành công!");
getTrip();
await getTrip();
}
} catch (error) {
console.error("Error stating trip :", error);
@@ -125,7 +125,7 @@ const ButtonCreateNewHaulOrTrip: React.FC<StartButtonProps> = ({
const resp = await queryStartNewHaul(body);
if (resp.status === 200) {
showSuccessToast("Bắt đầu mẻ lưới mới thành công!");
getTrip();
await getTrip();
} else {
showErrorToast("Tạo mẻ lưới mới thất bại!");
}
@@ -173,6 +173,8 @@ const ButtonCreateNewHaulOrTrip: React.FC<StartButtonProps> = ({
</IconButton>
)}
<CreateOrUpdateHaulModal
fishingLog={trip?.fishing_logs?.find((f) => f.status === 0)!}
fishingLogIndex={trip?.fishing_logs?.length!}
isVisible={isFinishHaulModalOpen}
onClose={function (): void {
setIsFinishHaulModalOpen(false);

View File

@@ -3,7 +3,7 @@ import { useFishes } from "@/state/use-fish";
import { useTrip } from "@/state/use-trip";
import React, { useEffect, useRef, useState } from "react";
import { Animated, Text, TouchableOpacity, View } from "react-native";
import NetDetailModal from "./modal/NetDetailModal/NetDetailModal";
import CreateOrUpdateHaulModal from "./modal/CreateOrUpdateHaulModal";
import styles from "./style/NetListTable.styles";
const NetListTable: React.FC = () => {
@@ -17,8 +17,11 @@ const NetListTable: React.FC = () => {
useEffect(() => {
getFishSpecies();
}, []);
const data: Model.FishingLog[] = trip?.fishing_logs ?? [];
const tongSoMe = data.length;
// useEffect(() => {
// console.log("Trip thay đổi: ", trip?.fishing_logs?.length);
// }, [trip]);
// const data: Model.FishingLog[] = trip?.fishing_logs ?? [];
const handleToggle = () => {
const toValue = collapsed ? contentHeight : 0;
@@ -31,7 +34,7 @@ const NetListTable: React.FC = () => {
};
const handleStatusPress = (id: string) => {
const net = data.find((item) => item.fishing_log_id === id);
const net = trip?.fishing_logs?.find((item) => item.fishing_log_id === id);
if (net) {
setSelectedNet(net);
setModalVisible(true);
@@ -47,7 +50,11 @@ const NetListTable: React.FC = () => {
style={styles.headerRow}
>
<Text style={styles.title}>Danh sách mẻ lưới</Text>
{collapsed && <Text style={styles.totalCollapsed}>{tongSoMe}</Text>}
{collapsed && (
<Text style={styles.totalCollapsed}>
{trip?.fishing_logs?.length}
</Text>
)}
<IconSymbol
name={collapsed ? "chevron.down" : "chevron.up"}
size={16}
@@ -60,8 +67,18 @@ const NetListTable: React.FC = () => {
style={{ position: "absolute", opacity: 0, zIndex: -1000 }}
onLayout={(event) => {
const height = event.nativeEvent.layout.height;
if (height > 0 && contentHeight === 0) {
// Update measured content height whenever it actually changes.
if (height > 0 && height !== contentHeight) {
setContentHeight(height);
// If the panel is currently expanded, animate to the new height so
// newly added/removed rows become visible immediately.
if (!collapsed) {
Animated.timing(animatedHeight, {
toValue: height,
duration: 200,
useNativeDriver: false,
}).start();
}
}
}}
>
@@ -72,7 +89,7 @@ const NetListTable: React.FC = () => {
</View>
{/* Body */}
{data.map((item, index) => (
{trip?.fishing_logs?.map((item, index) => (
<View key={item.fishing_log_id} style={styles.row}>
{/* Cột STT */}
<Text style={styles.sttCell}>Mẻ {index + 1}</Text>
@@ -101,7 +118,7 @@ const NetListTable: React.FC = () => {
</View>
{/* Body */}
{data.map((item, index) => (
{trip?.fishing_logs?.map((item, index) => (
<View key={item.fishing_log_id} style={styles.row}>
{/* Cột STT */}
<Text style={styles.sttCell}>Mẻ {index + 1}</Text>
@@ -120,9 +137,23 @@ const NetListTable: React.FC = () => {
</View>
))}
</Animated.View>
<CreateOrUpdateHaulModal
isVisible={modalVisible}
onClose={() => {
console.log("OnCLose");
setModalVisible(false);
}}
fishingLog={selectedNet}
fishingLogIndex={
selectedNet
? trip!.fishing_logs!.findIndex(
(item) => item.fishing_log_id === selectedNet.fishing_log_id
) + 1
: undefined
}
/>
{/* Modal chi tiết */}
<NetDetailModal
{/* <NetDetailModal
visible={modalVisible}
onClose={() => {
console.log("OnCLose");
@@ -136,7 +167,7 @@ const NetListTable: React.FC = () => {
) + 1
: undefined
}
/>
/> */}
</View>
);
};

View File

@@ -1,20 +1,22 @@
import Select from "@/components/Select";
import { useFishes } from "@/state/use-fish";
import { zodResolver } from "@hookform/resolvers/zod";
import React from "react";
import { Controller, useFieldArray, useForm } from "react-hook-form";
import { Button, FlatList, Modal, Text, TextInput, View } from "react-native";
import { z } from "zod";
import { InfoSection } from "./NetDetailModal/components";
interface CreateOrUpdateHaulModalProps {
isVisible: boolean;
onClose: () => void;
haulData?: Model.FishingLogInfo[] | null;
fishingLog?: Model.FishingLog | null;
fishingLogIndex?: number;
}
const UNITS = ["con", "kg", "tấn"] as const;
type Unit = (typeof UNITS)[number];
const UNITS_OPTIONS = UNITS.map((unit) => ({
label: unit,
value: unit.toString(),
@@ -49,9 +51,10 @@ const defaultItem = (): FormValues["fish"][number] => ({
const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
isVisible,
onClose,
haulData,
fishingLog,
fishingLogIndex
}) => {
const [isCreateMode, setIsCreateMode] = React.useState(!haulData);
const [isCreateMode, setIsCreateMode] = React.useState(!fishingLog?.info);
const { control, handleSubmit, formState, watch, reset } =
useForm<FormValues>({
resolver: zodResolver(formSchema),
@@ -60,9 +63,11 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
},
mode: "onSubmit",
});
const { fishSpecies, getFishSpecies } = useFishes();
const { errors } = formState;
if (!fishSpecies) {
getFishSpecies();
}
const { fields, append, remove } = useFieldArray({
control,
name: "fish",
@@ -70,7 +75,25 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
});
const onSubmit = (values: FormValues) => {
console.log("SUBMIT: ", JSON.stringify(values, null, 2));
// Map form values to the FishingLogInfo-like shape the user requested
const mapped = values.fish.map((f) => {
const meta = fishSpecies!.find((x) => x.id === f.id);
return {
fish_species_id: f.id,
fish_name: meta?.name,
catch_number: f.quantity,
catch_unit: f.unit,
fish_size: f.size,
fish_rarity: meta?.rarity_level,
fish_condition: "",
gear_usage: "",
} as unknown; // inferred shape — keep as unknown to avoid relying on global types here
});
console.log("SUBMIT (FishingLogInfo[]): ", JSON.stringify(mapped, null, 2));
// close modal after submit (you can change this to pass the payload to a parent via prop)
onClose();
};
// Initialize / reset form when modal visibility or haulData changes
@@ -82,14 +105,14 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
return;
}
// when modal opened, populate based on haulData
if (haulData === null) {
// when modal opened, populate based on fishingLog
if (fishingLog?.info === null) {
// explicit null -> start with a single default item
reset({ fish: [defaultItem()] });
setIsCreateMode(true);
} else if (Array.isArray(haulData) && haulData.length > 0) {
} else if (Array.isArray(fishingLog?.info) && fishingLog?.info.length > 0) {
// map FishingLogInfo -> form rows
const mapped = haulData.map((h) => ({
const mapped = fishingLog.info.map((h) => ({
id: h.fish_species_id ?? -1,
quantity: (h.catch_number as number) ?? 1,
unit: (h.catch_unit as Unit) ?? (defaultItem().unit as Unit),
@@ -102,7 +125,7 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
reset({ fish: [defaultItem()] });
setIsCreateMode(true);
}
}, [isVisible, haulData, reset]);
}, [isVisible, fishingLog?.info, reset]);
const renderRow = ({ item, index }: { item: any; index: number }) => {
return (
<View
@@ -125,7 +148,7 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
<View style={{ marginBottom: 8 }}>
<Text style={{ marginBottom: 4 }}>Tên </Text>
<Select
options={fishesExampleData.map((fish) => ({
options={fishSpecies!.map((fish) => ({
label: fish.name,
value: fish.id,
}))}
@@ -226,6 +249,7 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
</View>
);
};
return (
<Modal
visible={isVisible}
@@ -234,6 +258,7 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
onRequestClose={onClose}
>
<Text>{isCreateMode ? "Create Haul" : "Update Haul"}</Text>
<InfoSection fishingLog={fishingLog!} stt={fishingLogIndex} />
<FlatList
data={fields}
keyExtractor={(it) => it._id}
@@ -262,331 +287,3 @@ const CreateOrUpdateHaulModal: React.FC<CreateOrUpdateHaulModalProps> = ({
};
export default CreateOrUpdateHaulModal;
const fishesExampleData = [
{
id: 1,
name: "Cá thu",
scientific_name: "Scomberomorus spp.",
group_name: "Cá nổi",
species_code: "TUNA01",
note: "Loài phổ biến ở biển ven bờ và xa bờ",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 2,
name: "Cá nục",
scientific_name: "Decapterus spp.",
group_name: "Cá nổi",
species_code: "MACK01",
note: "Loài cá thương mại nhỏ",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 3,
name: "Cá chim trắng",
scientific_name: "Pampus argenteus",
group_name: "Cá nổi",
species_code: "POMF01",
note: "Thịt ngon, giá trị kinh tế cao",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 4,
name: "Cá bống tượng",
scientific_name: "Oxyeleotris marmorata",
group_name: "Cá đáy",
species_code: "GOBY01",
note: "Cá đáy nước ngọt và lợ",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 5,
name: "Cá mú đỏ",
scientific_name: "Epinephelus malabaricus",
group_name: "Nhóm mú",
species_code: "GROUP01",
note: "Cá mú đỏ phổ biến tại các rạn san hô",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 6,
name: "Cá mú trắng",
scientific_name: "Epinephelus fuscoguttatus",
group_name: "Nhóm mú",
species_code: "GROUP02",
note: "Cá mú trắng rạn san hô",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 8,
name: "Cá hồng phớn",
scientific_name: "Nemipterus virgatus",
group_name: "Cá đáy",
species_code: "BREAM01",
note: "Golden threadfin bream, rất phổ biến",
default_unit: "kg",
rarity_level: 3,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 9,
name: "Cá hổ Napoleon",
scientific_name: "Cheilinus undulatus",
group_name: "Rạn san hô",
species_code: "WRASSE01",
note: "Humphead wrasse, loài nguy cấp được bảo vệ",
default_unit: "kg",
rarity_level: 4,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 10,
name: "Cá quỷ biển (Barracuda)",
scientific_name: "Sphyraena barracuda",
group_name: "Cá săn mồi",
species_code: "BARRA01",
note: "Loài cá săn mồi nhanh",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 11,
name: "Cá ngừ đại dương",
scientific_name: "Thunnus albacares",
group_name: "Cá nổi xa bờ",
species_code: "TUNA02",
note: "Tuna phổ biến vùng biển xa",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 12,
name: "Cá nục vằn",
scientific_name: "Scomberomorus commerson",
group_name: "Cá nổi",
species_code: "MACK02",
note: "Mackerel phổ biến ở biển miền Trung",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 13,
name: "Cá song đỏ",
scientific_name: "Lutjanus argentimaculatus",
group_name: "Cá đáy",
species_code: "SNAPPER01",
note: "Mangrove red snapper, giá trị kinh tế cao",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 14,
name: "Cá mú cườm",
scientific_name: "Epinephelus coioides",
group_name: "Nhóm mú",
species_code: "GROUP03",
note: "Brown-spotted grouper, phổ biến ở vùng biển",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 15,
name: "Cá hồng",
scientific_name: "Lutjanus malabaricus",
group_name: "Cá đáy",
species_code: "SNAPPER02",
note: "Malabar red snapper",
default_unit: "kg",
rarity_level: 2,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 16,
name: "Cá rồng biển",
scientific_name: "Choerodon schoenleinii",
group_name: "Rạn san hô",
species_code: "DRAGON01",
note: "Cá rồng biển, cá cảnh hiếm",
default_unit: "kg",
rarity_level: 3,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 17,
name: "Cá nược",
scientific_name: "Pomatomus saltatrix",
group_name: "Cá nổi",
species_code: "QUEEN01",
note: "Bluefish phổ biến",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 18,
name: "Cá đuối quạt",
scientific_name: "Platyrhina sinensis",
group_name: "Cá mó",
species_code: "RAY01",
note: "Fanray, loài đe dọa",
default_unit: "kg",
rarity_level: 4,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 19,
name: "Cá hổ Thái Lan",
scientific_name: "Datnioides pulcher",
group_name: "Cá nước lợ",
species_code: "TIGER01",
note: "Siamese tigerfish, nguy cấp",
default_unit: "kg",
rarity_level: 4,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 20,
name: "Cá bớp vây vàng",
scientific_name: "Taractes rubescens",
group_name: "Cá nổi xa bờ",
species_code: "POMF02",
note: "Loài cá biển sâu ít gặp",
default_unit: "kg",
rarity_level: 3,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-08-29T06:34:38.785313Z",
is_deleted: false,
},
{
id: 43,
name: "Cá Min Mon",
scientific_name: "Minhmon",
group_name: "Cá béo",
species_code: "Caminhmon",
note: "Cá béo nước cạn",
default_unit: "tạ",
rarity_level: 1,
created_at: "2025-10-01T03:09:59.642716Z",
updated_at: "2025-10-01T03:10:30.977697Z",
is_deleted: true,
},
{
id: 7,
name: "Cá bơn vàng",
scientific_name: "Cynoglossus robustus",
group_name: "Cá đáy",
species_code: "SOLE01",
note: "Cá bơn đáy cát",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-08-29T06:34:38.785313Z",
updated_at: "2025-10-01T03:10:39.927546Z",
is_deleted: false,
},
{
id: 22,
name: "Cá mập",
scientific_name: "Carcharodon",
group_name: "Cá đáy",
species_code: "Carcharodon",
note: "Cá trắng",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-09-25T11:02:20.705804Z",
updated_at: "2025-10-01T03:11:13.631101Z",
is_deleted: true,
},
{
id: 28,
name: "cá cơm",
scientific_name: "cá cơm",
group_name: "cá cơm",
species_code: "cacom",
note: "no cmt",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-09-30T07:35:04.623573Z",
updated_at: "2025-09-30T08:06:18.651249Z",
is_deleted: true,
},
{
id: 29,
name: "cá minh mon",
scientific_name: "cá min mon",
group_name: "1",
species_code: "cá min mon",
note: "no",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-09-30T07:36:04.908601Z",
updated_at: "2025-09-30T08:09:34.361879Z",
is_deleted: true,
},
{
id: 42,
name: "cá mập",
scientific_name: "camap",
group_name: "cá đáy",
species_code: "camap",
note: "no",
default_unit: "kg",
rarity_level: 1,
created_at: "2025-09-30T08:38:14.151734Z",
updated_at: "2025-10-01T03:08:13.025517Z",
is_deleted: true,
},
];

View File

@@ -11,7 +11,6 @@ import {
import styles from "../style/NetDetailModal.styles";
import { CatchSectionHeader } from "./components/CatchSectionHeader";
import { FishCardList } from "./components/FishCardList";
import { InfoSection } from "./components/InfoSection";
import { NotesSection } from "./components/NotesSection";
interface NetDetailModalProps {
@@ -320,11 +319,11 @@ const NetDetailModal: React.FC<NetDetailModalProps> = ({
{/* Content */}
<ScrollView style={styles.content}>
{/* Thông tin chung */}
<InfoSection
{/* <InfoSection
netData={netData ?? undefined}
isCompleted={isCompleted}
stt={stt}
/>
/> */}
{/* Danh sách cá bắt được */}
<CatchSectionHeader totalCatch={totalCatch} />

View File

@@ -2,69 +2,54 @@ import React from "react";
import { Text, View } from "react-native";
import styles from "../../style/NetDetailModal.styles";
interface NetDetail {
id: string;
stt: string;
trangThai: string;
thoiGianBatDau?: string;
thoiGianKetThuc?: string;
viTriHaThu?: string;
viTriThuLuoi?: string;
doSauHaThu?: string;
doSauThuLuoi?: string;
catchList?: any[];
ghiChu?: string;
}
interface InfoSectionProps {
netData?: Model.FishingLog;
isCompleted: boolean;
fishingLog?: Model.FishingLog;
stt?: number;
}
export const InfoSection: React.FC<InfoSectionProps> = ({
netData,
isCompleted,
fishingLog,
stt,
}) => {
if (!netData) {
if (!fishingLog) {
return null;
}
const infoItems = [
{ label: "Số thứ tự", value: `Mẻ ${stt}` },
{
label: "Trạng thái",
value: netData.status === 1 ? "Đã hoàn thành" : "Chưa hoàn thành",
value: fishingLog.status === 1 ? "Đã hoàn thành" : "Chưa hoàn thành",
isStatus: true,
},
{
label: "Thời gian bắt đầu",
value: netData.start_at
? new Date(netData.start_at).toLocaleString()
value: fishingLog.start_at
? new Date(fishingLog.start_at).toLocaleString()
: "Chưa cập nhật",
},
{
label: "Thời gian kết thúc",
value: netData.start_at
? new Date(netData.end_at).toLocaleString()
: "Chưa cập nhật",
},
{
label: "Vị trí hạ thu",
value: netData.viTriHaThu || "Chưa cập nhật",
},
{
label: "Vị trí thu lưới",
value: netData.viTriThuLuoi || "Chưa cập nhật",
},
{
label: "Độ sâu hạ thu",
value: netData.doSauHaThu || "Chưa cập nhật",
},
{
label: "Độ sâu thu lưới",
value: netData.doSauThuLuoi || "Chưa cập nhật",
value:
fishingLog.end_at !== "0001-01-01T00:00:00Z"
? new Date(fishingLog.end_at).toLocaleString()
: "-",
},
// {
// label: "Vị trí hạ thu",
// value: fishingLog.viTriHaThu || "Chưa cập nhật",
// },
// {
// label: "Vị trí thu lưới",
// value: fishingLog.viTriThuLuoi || "Chưa cập nhật",
// },
// {
// label: "Độ sâu hạ thu",
// value: fishingLog.doSauHaThu || "Chưa cập nhật",
// },
// {
// label: "Độ sâu thu lưới",
// value: fishingLog.doSauThuLuoi || "Chưa cập nhật",
// },
];
return (

View File

@@ -152,8 +152,8 @@ declare namespace Model {
interface FishingLog {
fishing_log_id: string;
trip_id: string;
start_at: Date; // ISO datetime
end_at: Date; // ISO datetime
start_at: string; // ISO datetime
end_at: string; // ISO datetime
start_lat: number;
start_lon: number;
haul_lat: number;

View File

@@ -162,3 +162,11 @@ export function stopEvents() {
}
});
}
export function startEvents() {
getGpsEventBus();
getAlarmEventBus();
getEntitiesEventBus();
getTrackPointsEventBus();
getBanzonesEventBus();
}