import React, { memo, useState, useEffect } from 'react'; import { Space, Tag, ConfigProvider, Button, Row, Col, Card, Input } from 'antd'; import { PlusOutlined, EditOutlined, DeleteOutlined, EyeOutlined, SearchOutlined, } from '@ant-design/icons'; import { NotifAlert, NotifConfirmDialog } from '../../../../components/Global/ToastNotif'; import { useNavigate } from 'react-router-dom'; import { deleteShift, getAllShift } from '../../../../api/master-shift'; import TableList from '../../../../components/Global/TableList'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; dayjs.extend(utc); // Helper function untuk convert ISO time ke HH:mm const formatTime = (timeValue) => { if (!timeValue) return '-'; if (typeof timeValue === 'string' && timeValue.match(/^\d{2}:\d{2}$/)) { return timeValue; } // UTC untuk menghindari timezone conversion const time = dayjs.utc(timeValue); return time.isValid() ? time.format('HH:mm') : '-'; }; const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ { title: 'Shift Name', dataIndex: 'shift_name', key: 'shift_name', width: '30%', }, { title: 'Start Time', dataIndex: 'start_time', key: 'start_time', width: '15%', align: 'center', render: (time) => formatTime(time), }, { title: 'End Time', dataIndex: 'end_time', key: 'end_time', width: '15%', align: 'center', render: (time) => formatTime(time), }, { title: 'Status', dataIndex: 'is_active', key: 'is_active', width: '15%', align: 'center', render: (status) => ( {status ? 'Active' : 'Inactive'} ), }, { title: 'Aksi', key: 'aksi', align: 'center', width: '25%', render: (_, record) => ( } size="large" /> ); }); export default ListShift;