import { EditOutlined, EyeOutlined } from '@ant-design/icons'; import { ProColumns, ProTable } from '@ant-design/pro-components'; import { useIntl, useModel } from '@umijs/max'; import { Button, Flex, message } from 'antd'; import React, { useState } from 'react'; import CreateOrUpdateFishingLog from './CreateOrUpdateFishingLog'; import HaulFishList from './HaulFishList'; export interface HaulTableProps { hauls: API.FishingLog[]; trip?: API.Trip; onReload?: (isTrue: boolean) => void; } const HaulTable: React.FC = ({ hauls, trip, onReload }) => { const [editOpen, setEditOpen] = useState(false); const [editFishingLogOpen, setEditFishingLogOpen] = useState(false); const [currentRow, setCurrentRow] = useState([]); const [currentFishingLog, setCurrentFishingLog] = useState(null); const intl = useIntl(); const { getApi } = useModel('getTrip'); console.log('HaulTable received hauls:', hauls); const fishing_logs_columns: ProColumns[] = [ { title:
STT
, dataIndex: 'fishing_log_id', align: 'center', render: (_, __, index, action) => { return `Mẻ ${hauls.length - index}`; }, }, { title:
Trạng Thái
, dataIndex: ['status'], // 👈 lấy từ status 1: đang align: 'center', valueEnum: { 0: { text: intl.formatMessage({ id: 'pages.trips.status.fishing', defaultMessage: 'Đang đánh bắt', }), status: 'Processing', }, 1: { text: intl.formatMessage({ id: 'pages.trips.status.end_fishing', defaultMessage: 'Đã hoàn thành', }), status: 'Success', }, 2: { text: intl.formatMessage({ id: 'pages.trips.status.cancel_fishing', defaultMessage: 'Đã huỷ', }), status: 'default', }, }, }, { title:
Thời tiết
, dataIndex: ['weather_description'], // 👈 lấy từ weather align: 'center', }, { title:
Thời điểm bắt đầu
, dataIndex: ['start_at'], // birth_date là date of birth align: 'center', render: (start_at: any) => { if (!start_at) return '-'; const date = new Date(start_at); return date.toLocaleString('vi-VN', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false, }); }, }, { title:
Thời điểm kết thúc
, dataIndex: ['end_at'], // birth_date là date of birth align: 'center', render: (end_at: any) => { // console.log('End at value:', end_at); if (end_at == '0001-01-01T00:00:00Z') return '-'; const date = new Date(end_at); return date.toLocaleString('vi-VN', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false, }); }, }, { title: 'Thao tác', align: 'center', hideInSearch: true, render: (_, record) => { console.log('Rendering action column for record:', record); return ( {/* Nút Edit */}