#
luxiaotao1123
2024-09-27 de7df1d489bdad38dcbeb78d74cad8e3bfa09e3d
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
import { LinearProgress, Stack, Typography } from '@mui/material';
import { CreateButton, useGetList } from 'react-admin';
import useAppBarHeight from '../misc/useAppBarHeight';
import { matchPath, useLocation } from 'react-router';
import { DealCreate } from './DealCreate';
import { Contact } from '../types';
import { Link } from 'react-router-dom';
 
export const MissionEmpty = ({ children }) => {
    const location = useLocation();
    const matchCreate = matchPath('/mission/create', location.pathname);
    const appBarHeight = useAppBarHeight();
 
    // get Contact data
    const { data: contacts, isPending: contactsLoading } = useGetList < Contact > (
        'contacts',
        {
            pagination: { page: 1, perPage: 1 },
        }
    );
 
    if (contactsLoading) return <LinearProgress />;
 
    return (
        <Stack
            justifyContent="center"
            alignItems="center"
            gap={3}
            sx={{
                height: `calc(100dvh - ${appbarHeight}px)`,
            }}
        >
            <img src="./img/empty.svg" alt="No contacts found" />
            {contacts && contacts.length > 0 ? (
                <>
                    <Stack gap={0} alignItems="center">
                        <Typography variant="h6" fontWeight="bold">
                            No deals found
                        </Typography>
                        <Typography
                            variant="body2"
                            align="center"
                            color="text.secondary"
                            gutterBottom
                        >
                            It seems your deal list is empty.
                        </Typography>
                    </Stack>
                    <Stack spacing={2} direction="row">
                        <CreateButton variant="contained" label="Create deal" />
                    </Stack>
                    <DealCreate open={!!matchCreate} />
                    {children}
                </>
            ) : (
                <Stack gap={0} alignItems="center">
                    <Typography variant="h6" fontWeight="bold">
                        No deals found
                    </Typography>
                    <Typography
                        variant="body2"
                        align="center"
                        color="text.secondary"
                        gutterBottom
                    >
                        It seems your contact list is empty.
                        <br />
                        <Link to="/contacts/create">
                            Add your first contact
                        </Link>{' '}
                        before creating a deal.
                    </Typography>
                </Stack>
            )}
        </Stack>
    );
};