import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
import { Link, Stack, Typography, Avatar } from '@mui/material';
|
import {
|
useDataProvider,
|
useTranslate,
|
} from 'react-admin';
|
import { getTaskStsColor } from '@/utils/color-util';
|
import { blueGrey } from "@mui/material/colors";
|
|
export const TaskList = ({ taskIds }) => {
|
const dataProvider = useDataProvider();
|
|
const [tasks, setTasks] = useState([]);
|
|
useEffect(() => {
|
if (taskIds?.length > 0) {
|
dataProvider.getMany('task', { ids: taskIds }).then(res => {
|
if (res.data?.length > 0) {
|
setTasks(res.data);
|
}
|
})
|
}
|
}, [taskIds])
|
|
if (!taskIds?.length) return <div style={{ height: '2em' }} />;
|
|
return (
|
<Stack direction="row" flexWrap="wrap" gap={3} mt={1}>
|
{tasks.map(task => (
|
<Stack direction="row" key={task.id} gap={1}>
|
<Avatar
|
alt={task.seqNum}
|
// variant="square"
|
sx={{
|
'& img': { objectFit: 'contain' },
|
fontSize: '1rem',
|
width: 55,
|
height: 40,
|
bgcolor: blueGrey[400],
|
// bgcolor: getTaskStsColor(task.taskSts$),
|
}}
|
>
|
{task.seqNum}
|
</Avatar>
|
<Stack>
|
<Typography variant="body2" color="inherit">
|
{task.taskType$}
|
</Typography>
|
<Typography variant="caption" color="text.secondary">
|
{task.oriDesc || ''} - {task.destDesc || ''}
|
</Typography>
|
</Stack>
|
</Stack>
|
))}
|
</Stack>
|
);
|
};
|