DashboardIntro.tsx 5.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
import {
  Avatar,
  Card,
  CardContent,
  CardMedia,
  CircularProgress,
  createStyles,
  Divider,
  List,
  ListItem,
  ListItemAvatar,
  ListItemText,
  makeStyles,
14
  Theme,
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  Typography,
} from '@material-ui/core';
import { Container } from '@material-ui/core';
import classNames from 'classnames';
import ImageIcon from '@material-ui/icons/Image';
import { useEffect, useState } from 'react';
import { getCurrentMode, MODE_REACT_ONLY } from '../../../Constants/Constants';

const orgRepDataTest = [
  {
    name: 'John Demo',
    type: 'Company Rep',
  },
  {
    name: 'Tom Demo',
    type: 'Marketing Rep',
  },
  {
    name: 'Bob Demo',
    type: 'Accouting Rep',
  },
];

38
const useStyles = makeStyles((theme: Theme) =>
39
40
41
42
  createStyles({
    introCtn: {
      padding: 0,
      display: 'flex',
43
      flexWrap: 'wrap',
44
45
46
47
48
49
50
51
      justifyContent: 'space-between',
    },
    card: {
      height: 260,
      boxShadow: '1px 1px 15px rgba(0,0,0,0.1)',
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
52
53
54
55
56
57
58
59
60
61
62
      minWidth: 255,
      width: '100%',
      margin: theme.spacing(2, 0),
      [theme.breakpoints.up(650)]: {
        width: '45%',
        margin: theme.spacing(2.5, 0.5, 0, 0.5),
      },
      [theme.breakpoints.up(1280)]: {
        width: '30%',
        margin: theme.spacing(2.5, 1, 0, 1),
      },
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    },
    companyLogoCard: {
      backgroundColor: '#8A94A8',
    },
    companyLogo: {
      width: '90%',
      maxWidth: 250,
    },
    companyRepCard: {
      backgroundColor: '#D0D0D0',
    },
    repPrimary: {
      fontSize: 18,
    },
    repSecondary: {
      fontSize: 14,
    },
    companyContentCard: {
      flexDirection: 'column',
      justifyContent: 'start',
      alignItems: 'start',
84
      padding: theme.spacing(2, 3),
85
86
87
      backgroundColor: '#fff',
    },
    contentTitle: {
88
      marginBottom: theme.spacing(0.5),
89
90
91
    },
    divider: {
      width: '100%',
92
      margin: theme.spacing(0.5, 0),
93
94
95
96
97
    },
    contentList: {
      width: '100%',
    },
    contentItemCtn: {
98
      padding: theme.spacing(1, 0),
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    },
    contentAvatar: {
      width: 35,
      height: 35,
    },
    contentItemText: {
      display: 'flex',
      padding: 0,
      alignItems: 'center',
      justifyContent: 'space-between',
    },
    contentItemTextSub: {
      color: 'hsl(0, 0%, 75%)',
    },
  })
);

interface OrgRep {
  name: string;
  type: string;
}

121
export default function DashboardIntro() {
122
123
124
125
126
127
  const classes = useStyles();

  const [logoURL, setLogo] = useState('');
  const [orgRepData, setOrgRepData] = useState<Array<OrgRep> | null>(null);

  const renderOrgRep = orgRepData?.map((rep) => (
128
    <ListItem key={rep.name}>
129
130
131
132
      <ListItemText
        classes={{
          primary: classes.repPrimary,
          secondary: classes.repSecondary,
133
        }}
134
135
136
137
138
139
140
141
142
143
144
        primary={rep.name}
        secondary={rep.type}
      />
    </ListItem>
  ));

  useEffect(() => {
    if (getCurrentMode() === MODE_REACT_ONLY) {
      setLogo(require('../../../assets/logos/ef-registered-wht.svg').default);
      setOrgRepData(orgRepDataTest);
    } else {
145
146
      setLogo(require('../../../assets/logos/ef-registered-wht.svg').default);
      setOrgRepData(orgRepDataTest);
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
      // TO DO:
      // fetch the logo and set state
      // fetch the organization rep and set state
    }
  }, []);

  return (
    <Container className={classes.introCtn}>
      <Card className={classNames(classes.card, classes.companyLogoCard)}>
        {logoURL ? (
          <CardMedia component="img" className={classes.companyLogo} image={logoURL} alt="Company Logo" />
        ) : (
          <CircularProgress />
        )}
      </Card>

      <Card className={classNames(classes.card, classes.companyRepCard)}>
        <CardContent>
          <List>{renderOrgRep || <CircularProgress />}</List>
        </CardContent>
      </Card>

      <Card className={classNames(classes.card, classes.companyContentCard)}>
        <Typography component="h5" variant="h5" className={classes.contentTitle}>
          Lorem Ipsum
        </Typography>
        <List className={classes.contentList}>
          <ListItem className={classes.contentItemCtn}>
            <ListItemAvatar>
              <Avatar className={classes.contentAvatar}>
                <ImageIcon />
              </Avatar>
            </ListItemAvatar>
            <Container className={classes.contentItemText}>
              <Typography component="p" variant="body1">
                Lorem Ipsum
              </Typography>
              <Typography component="span" variant="body2" className={classes.contentItemTextSub}>
                Last 24 hours
              </Typography>
            </Container>
          </ListItem>
          <Divider className={classes.divider} />

          <ListItem className={classes.contentItemCtn}>
            <ListItemAvatar>
              <Avatar className={classes.contentAvatar}>
                <ImageIcon />
              </Avatar>
            </ListItemAvatar>
            <Container className={classes.contentItemText}>
              <Typography component="p" variant="body1">
                Lorem Ipsum
              </Typography>
              <Typography component="span" variant="body2" className={classes.contentItemTextSub}>
                Processing
              </Typography>
            </Container>
          </ListItem>
          <Divider className={classes.divider} />

          <ListItem className={classes.contentItemCtn}>
            <ListItemAvatar>
              <Avatar className={classes.contentAvatar}>
                <ImageIcon />
              </Avatar>
            </ListItemAvatar>
            <Container className={classes.contentItemText}>
              <Typography component="p" variant="body1">
                Lorem Ipsum
              </Typography>
              <Typography component="span" variant="body2" className={classes.contentItemTextSub}>
                On hold
              </Typography>
            </Container>
          </ListItem>
        </List>
      </Card>
    </Container>
226
227
  );
}