fill data API CrewList, FishingTools, TripCost
This commit is contained in:
@@ -1,86 +1,162 @@
|
||||
import { IconSymbol } from "@/components/ui/icon-symbol";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { useTrip } from "@/state/use-trip";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { Animated, Text, TouchableOpacity, View } from "react-native";
|
||||
import CrewDetailModal from "./modal/CrewDetailModal";
|
||||
import styles from "./style/CrewListTable.styles";
|
||||
|
||||
// ---------------------------
|
||||
// 🧩 Interface
|
||||
// ---------------------------
|
||||
interface CrewMember {
|
||||
id: string;
|
||||
maDinhDanh: string;
|
||||
ten: string;
|
||||
chucVu: string;
|
||||
ngaySinh?: string;
|
||||
cccd?: string;
|
||||
soDienThoai?: string;
|
||||
diaChi?: string;
|
||||
ngayVaoLam?: string;
|
||||
trinhDoChuyenMon?: string;
|
||||
bangCap?: string;
|
||||
tinhTrang?: string;
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// ⚓ Dữ liệu mẫu
|
||||
// ---------------------------
|
||||
const data: CrewMember[] = [
|
||||
const mockCrews: Model.TripCrews[] = [
|
||||
{
|
||||
id: "10",
|
||||
maDinhDanh: "ChuTau",
|
||||
ten: "Nguyễn Nhật Minh",
|
||||
chucVu: "Chủ tàu",
|
||||
ngaySinh: "08/06/2006",
|
||||
cccd: "079085012345",
|
||||
soDienThoai: "0912345678",
|
||||
diaChi: "Hà Nội",
|
||||
ngayVaoLam: "",
|
||||
trinhDoChuyenMon: "Thuyền trưởng hạng I",
|
||||
bangCap: "Bằng thuyền trưởng xa bờ",
|
||||
tinhTrang: "Đang làm việc",
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "480863197307",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.230053Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "480863197307",
|
||||
name: "Huỳnh Tấn Trang",
|
||||
phone: "0838944284",
|
||||
email: "huynhtantrang@crew.sgw.vn",
|
||||
birth_date: new Date("2025-01-11T00:00:00Z"),
|
||||
note: "",
|
||||
address: "49915 Poplar Avenue",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "1",
|
||||
maDinhDanh: "TV001",
|
||||
ten: "Nguyễn Văn A",
|
||||
chucVu: "Thuyền trưởng",
|
||||
ngaySinh: "20/05/1988",
|
||||
cccd: "079088011111",
|
||||
soDienThoai: "0901234567",
|
||||
diaChi: "456 Đường Cảng, Phường Thanh Khê, Đà Nẵng",
|
||||
ngayVaoLam: "15/06/2015",
|
||||
trinhDoChuyenMon: "Thuyền trưởng hạng II",
|
||||
bangCap: "Bằng thuyền trưởng ven bờ",
|
||||
tinhTrang: "Đang làm việc",
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "714834545296",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.301376Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "714834545296",
|
||||
name: "Trương Văn Nam",
|
||||
phone: "0773396753",
|
||||
email: "truongvannam@crew.sgw.vn",
|
||||
birth_date: new Date("2025-07-24T00:00:00Z"),
|
||||
note: "",
|
||||
address: "3287 Carlotta Underpass",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
maDinhDanh: "TV002",
|
||||
ten: "Trần Văn B",
|
||||
chucVu: "Máy trưởng",
|
||||
ngaySinh: "10/08/1990",
|
||||
cccd: "079090022222",
|
||||
soDienThoai: "0987654321",
|
||||
diaChi: "789 Đường Nguyễn Văn Linh, Quận Sơn Trà, Đà Nẵng",
|
||||
ngayVaoLam: "20/03/2016",
|
||||
trinhDoChuyenMon: "Máy trưởng hạng III",
|
||||
bangCap: "Bằng máy trưởng ven bờ",
|
||||
tinhTrang: "Đang làm việc",
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "049299828990",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.373037Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "049299828990",
|
||||
name: "Đặng Anh Minh",
|
||||
phone: "0827640820",
|
||||
email: "danganhminh@crew.sgw.vn",
|
||||
birth_date: new Date("2024-10-30T00:00:00Z"),
|
||||
note: "",
|
||||
address: "68909 Gerda Burgs",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
maDinhDanh: "TV003",
|
||||
ten: "Lê Văn C",
|
||||
chucVu: "Thủy thủ",
|
||||
ngaySinh: "25/12/1995",
|
||||
cccd: "079095033333",
|
||||
soDienThoai: "0976543210",
|
||||
diaChi: "321 Đường Hoàng Sa, Quận Ngũ Hành Sơn, Đà Nẵng",
|
||||
ngayVaoLam: "10/07/2018",
|
||||
trinhDoChuyenMon: "Thủy thủ hạng I",
|
||||
bangCap: "Chứng chỉ thủy thủ",
|
||||
tinhTrang: "Đang làm việc",
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "851494873747",
|
||||
role: "captain",
|
||||
joined_at: new Date("2025-11-06T08:13:33.442774Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "851494873747",
|
||||
name: "Tô Thị Linh",
|
||||
phone: "0337906041",
|
||||
email: "tothilinh@crew.sgw.vn",
|
||||
birth_date: new Date("2025-06-18T00:00:00Z"),
|
||||
note: "",
|
||||
address: "6676 Kulas Groves",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "384839614682",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.515532Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "384839614682",
|
||||
name: "Lê Thanh Hoa",
|
||||
phone: "0937613034",
|
||||
email: "lethanhhoa@crew.sgw.vn",
|
||||
birth_date: new Date("2025-07-17T00:00:00Z"),
|
||||
note: "",
|
||||
address: "244 Cicero Estate",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "702319275290",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.588038Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "702319275290",
|
||||
name: "Nguyễn Phước Hải",
|
||||
phone: "0347859214",
|
||||
email: "nguyenphuochai@crew.sgw.vn",
|
||||
birth_date: new Date("2025-08-13T00:00:00Z"),
|
||||
note: "",
|
||||
address: "6874 Devon Key",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "943534816439",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.668984Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "943534816439",
|
||||
name: "Lý Hữu Hà",
|
||||
phone: "0768548881",
|
||||
email: "lyhuuha@crew.sgw.vn",
|
||||
birth_date: new Date("2025-08-18T00:00:00Z"),
|
||||
note: "",
|
||||
address: "655 Middle Street",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
{
|
||||
TripID: "f9884294-a7f2-46dc-aaf2-032da08a1ab6",
|
||||
PersonalID: "096528446981",
|
||||
role: "crew",
|
||||
joined_at: new Date("2025-11-06T08:13:33.74379Z"),
|
||||
left_at: null,
|
||||
note: null,
|
||||
Person: {
|
||||
personal_id: "096528446981",
|
||||
name: "Trần Xuân Thi",
|
||||
phone: "0963449523",
|
||||
email: "tranxuanthi@crew.sgw.vn",
|
||||
birth_date: new Date("2024-09-21T00:00:00Z"),
|
||||
note: "",
|
||||
address: "59344 Burley Isle",
|
||||
created_at: new Date("0001-01-01T00:00:00Z"),
|
||||
updated_at: new Date("0001-01-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -89,9 +165,22 @@ const CrewListTable: React.FC = () => {
|
||||
const [contentHeight, setContentHeight] = useState<number>(0);
|
||||
const animatedHeight = useRef(new Animated.Value(0)).current;
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [selectedCrew, setSelectedCrew] = useState<CrewMember | null>(null);
|
||||
const [selectedCrew, setSelectedCrew] = useState<Model.TripCrews | null>(
|
||||
null
|
||||
);
|
||||
|
||||
const { trip } = useTrip();
|
||||
|
||||
const data: Model.TripCrews[] = trip?.crews ?? mockCrews;
|
||||
|
||||
const tongThanhVien = data.length;
|
||||
|
||||
// Reset animated height khi dữ liệu thay đổi
|
||||
useEffect(() => {
|
||||
setContentHeight(0); // Reset để tính lại chiều cao
|
||||
setCollapsed(true); // Reset về trạng thái gập lại
|
||||
}, [data]);
|
||||
|
||||
const handleToggle = () => {
|
||||
const toValue = collapsed ? contentHeight : 0;
|
||||
Animated.timing(animatedHeight, {
|
||||
@@ -103,7 +192,7 @@ const CrewListTable: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleCrewPress = (crewId: string) => {
|
||||
const crew = data.find((item) => item.id === crewId);
|
||||
const crew = data.find((item) => item.Person.personal_id === crewId);
|
||||
if (crew) {
|
||||
setSelectedCrew(crew);
|
||||
setModalVisible(true);
|
||||
@@ -146,9 +235,6 @@ const CrewListTable: React.FC = () => {
|
||||
>
|
||||
{/* Header */}
|
||||
<View style={[styles.row, styles.tableHeader]}>
|
||||
<Text style={[styles.cell, styles.left, styles.headerText]}>
|
||||
Mã định danh
|
||||
</Text>
|
||||
<View style={styles.cellWrapper}>
|
||||
<Text style={[styles.cell, styles.headerText]}>Tên</Text>
|
||||
</View>
|
||||
@@ -159,25 +245,23 @@ const CrewListTable: React.FC = () => {
|
||||
|
||||
{/* Body */}
|
||||
{data.map((item) => (
|
||||
<View key={item.id} style={styles.row}>
|
||||
<Text style={[styles.cell, styles.left]}>{item.maDinhDanh}</Text>
|
||||
<View key={item.Person.personal_id} style={styles.row}>
|
||||
<TouchableOpacity
|
||||
style={styles.cellWrapper}
|
||||
onPress={() => handleCrewPress(item.id)}
|
||||
onPress={() => handleCrewPress(item.Person.personal_id)}
|
||||
>
|
||||
<Text style={[styles.cell, styles.linkText]}>{item.ten}</Text>
|
||||
<Text style={[styles.cell, styles.linkText]}>
|
||||
{item.Person.name}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<Text style={[styles.cell, styles.right]}>{item.chucVu}</Text>
|
||||
<Text style={[styles.cell, styles.right]}>{item.role}</Text>
|
||||
</View>
|
||||
))}
|
||||
|
||||
{/* Footer */}
|
||||
<View style={[styles.row]}>
|
||||
<Text style={[styles.cell, styles.left, styles.footerText]}>
|
||||
Tổng cộng
|
||||
</Text>
|
||||
<Text style={[styles.cell, styles.footerText]}>Tổng cộng</Text>
|
||||
<Text style={[styles.cell, styles.footerTotal]}>{tongThanhVien}</Text>
|
||||
<Text style={[styles.cell, styles.right]}></Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -185,9 +269,6 @@ const CrewListTable: React.FC = () => {
|
||||
<Animated.View style={{ height: animatedHeight, overflow: "hidden" }}>
|
||||
{/* Header */}
|
||||
<View style={[styles.row, styles.tableHeader]}>
|
||||
<Text style={[styles.cell, styles.left, styles.headerText]}>
|
||||
Mã định danh
|
||||
</Text>
|
||||
<View style={styles.cellWrapper}>
|
||||
<Text style={[styles.cell, styles.headerText]}>Tên</Text>
|
||||
</View>
|
||||
@@ -198,25 +279,23 @@ const CrewListTable: React.FC = () => {
|
||||
|
||||
{/* Body */}
|
||||
{data.map((item) => (
|
||||
<View key={item.id} style={styles.row}>
|
||||
<Text style={[styles.cell, styles.left]}>{item.maDinhDanh}</Text>
|
||||
<View key={item.Person.personal_id} style={styles.row}>
|
||||
<TouchableOpacity
|
||||
style={styles.cellWrapper}
|
||||
onPress={() => handleCrewPress(item.id)}
|
||||
onPress={() => handleCrewPress(item.Person.personal_id)}
|
||||
>
|
||||
<Text style={[styles.cell, styles.linkText]}>{item.ten}</Text>
|
||||
<Text style={[styles.cell, styles.linkText]}>
|
||||
{item.Person.name}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<Text style={[styles.cell, styles.right]}>{item.chucVu}</Text>
|
||||
<Text style={[styles.cell, styles.right]}>{item.role}</Text>
|
||||
</View>
|
||||
))}
|
||||
|
||||
{/* Footer */}
|
||||
<View style={[styles.row]}>
|
||||
<Text style={[styles.cell, styles.left, styles.footerText]}>
|
||||
Tổng cộng
|
||||
</Text>
|
||||
<Text style={[styles.cell, styles.footerText]}>Tổng cộng</Text>
|
||||
<Text style={[styles.cell, styles.footerTotal]}>{tongThanhVien}</Text>
|
||||
<Text style={[styles.cell, styles.right]}></Text>
|
||||
</View>
|
||||
</Animated.View>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user