skyouc
11 小时以前 ea2904d7ca03b42f5783cd659fe71c0fbedd2277
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import * as React from 'react';
import { useTranslate, useReference } from 'react-admin';
import {
    ListItem,
    ListItemSecondaryAction,
    ListItemAvatar,
    ListItemText,
    Avatar,
    Box,
    ListItemButton,
    Card,
    CardHeader,
    List,
} from '@mui/material';
import { Link } from 'react-router-dom';
 
const NbList = (props) => {
    const { orders = [] } = props;
    const translate = useTranslate();
 
    return (
        <Card sx={{ flex: 1 }}>
            <CardHeader title={translate('pos.dashboard.pending_orders')} />
            <List dense={true}>
                {orders.map(record => (
                    <PendingOrder key={record.id} order={record} />
                ))}
            </List>
        </Card>
    );
};
 
export const PendingOrder = (props) => {
    const { order } = props;
    console.log(order);
 
    const translate = useTranslate();
    const { referenceRecord: customer, isPending } = useReference({
        reference: 'customers',
        id: order.customer_id,
    });
 
    return (
        <ListItem disablePadding>
            <ListItemButton component={Link} to={`/orders/${order.id}`}>
                {/* <ListItemAvatar>
                    {isPending ? (
                        <Avatar />
                    ) : (
                        <Avatar
                            src={`${customer?.avatar}?size=32x32`}
                            sx={{ bgcolor: 'background.paper' }}
                            alt={`${customer?.first_name} ${customer?.last_name}`}
                        />
                    )}
                </ListItemAvatar> */}
                <ListItemText
                    primary={new Date(order.date).toLocaleString('en-GB')}
                    secondary={translate('pos.dashboard.order.items', {
                        name: order.name
                    })}
                />
                <ListItemSecondaryAction>
                    <Box
                        component="span"
                        sx={{
                            marginRight: '1em',
                            color: 'text.primary',
                        }}
                    >
                        {order.total}$
                    </Box>
                </ListItemSecondaryAction>
            </ListItemButton>
        </ListItem>
    );
};
 
export default NbList;