zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import {
    useDataProvider,
    useTranslate,
} from 'react-admin';
import { Box, Divider, Stack, LinearProgress } from '@mui/material';
 
import { Action } from './Action';
 
export const ActionsIterator = ({ actionIds }) => {
    const dataProvider = useDataProvider();
 
    const [actions, setActions] = useState([]);
 
    useEffect(() => {
        if (actionIds?.length > 0) {
            dataProvider.getMany('action', { ids: actionIds }).then(res => {
                if (res.data?.length > 0) {
                    setActions(res.data);
                }
            })
        }
    }, [actionIds])
 
    if (!actionIds?.length) return <LinearProgress />;
 
    return (
        <Box mt={2}>
            {actions && (
                <Stack mt={2} gap={1}>
                    {actions.map((action, idx) => (
                        <React.Fragment key={idx}>
                            <Action
                                data={action}
                                isLast={idx === actions.length - 1}
                                key={idx}
                            />
                            {idx < actions.length - 1 && <Divider />}
                        </React.Fragment>
                    ))}
                </Stack>
            )}
        </Box>
    );
};