DashboardFAQs.tsx 4.22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
import { useState } from 'react';
import {
  ListItem,
  ListItemText,
  Collapse,
  Container,
  makeStyles,
  createStyles,
  ListItemIcon,
  List,
  Typography,
12
  Theme,
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
} from '@material-ui/core';
import ContactSupportIcon from '@material-ui/icons/ContactSupport';
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import { borderRadiusSize, iconGray, mainContentBGColor } from '../../../Constants/Constants';

const faqItems = [
  {
    question: 'Question-1',
    answer:
      "Lorem Ipsum 1 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum 1 is simply dummy text of the printing and typesetting industry.",
  },
  {
    question: 'Question-2',
    answer:
      "Lorem Ipsum 2 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
  },
  {
    question: 'Question-3',
    answer:
      "Lorem Ipsum 3 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
  },
  {
    question: 'Question-4',
    answer:
      "Lorem Ipsum 4 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
  },
];

42
const useStyles = makeStyles((theme: Theme) =>
43
44
45
46
  createStyles({
    faqContainer: {
      position: 'relative',
      display: 'flex',
47
48
      marginTop: theme.spacing(4),
      padding: theme.spacing(0, 1),
49
50
      border: '2px #DCDFE5 solid',
      borderRadius: borderRadiusSize,
51
      maxWidth: '100%',
52
53
54
      [theme.breakpoints.up('lg')]: {
        paddingLeft: theme.spacing(6.5),
      },
55
56
57
    },
    faqIcon: {
      position: 'absolute',
58
59
      top: theme.spacing(-3),
      left: theme.spacing(1),
60
61
62
63
      color: iconGray,
      backgroundColor: mainContentBGColor,
      fontSize: 60,
    },
64
65
66
67
68
69
70
    faqTitle: {
      textAlign: 'center',
      paddingTop: theme.spacing(9),
      [theme.breakpoints.up('sm')]: {
        textAlign: 'left',
      },
    },
71
72
73
74
    faqIconForBG: {
      fontSize: 200,
      opacity: 0.15,
      color: iconGray,
75
76
77
78
79
      marginTop: theme.spacing(4),
      display: 'none',
      [theme.breakpoints.up('lg')]: {
        display: 'block',
      },
80
81
    },
    faqList: {
82
83
84
      marginTop: theme.spacing(3),
      marginBottom: theme.spacing(2.5),
      padding: theme.spacing(1),
85
86
87
88
89
    },
    faqItemCtn: {
      padding: 0,
      border: '2px #EDEDED solid',
      borderRadius: borderRadiusSize,
90
      marginBottom: theme.spacing(0.5),
91
92
93
94
95
96
97
98
99
    },
    faqQuestion: {
      backgroundColor: '#EDEDED',
      cursor: 'pointer',
    },
    faqExpandIcon: {
      flexDirection: 'row-reverse',
    },
    faqAnswer: {
100
      padding: theme.spacing(1.5, 3),
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    },
  })
);

export default function DashboardFAQs() {
  const [shouldCollapse, setShouldCollapse] = useState<Array<boolean>>([]);
  const classes = useStyles();

  const handleClick = (index: number) => {
    const newShouldCollapse = [...shouldCollapse];
    newShouldCollapse[index] = !newShouldCollapse[index];
    setShouldCollapse(newShouldCollapse);
  };

  const renderFAQs = faqItems.map((item, index) => (
    <List className={classes.faqItemCtn} key={index}>
117
118
      <ListItem className={classes.faqQuestion} onClick={() => handleClick(index)}>
        <ListItemText primary={item.question} />
119
120
121
122
123
124
125
126
127
128
129
130
        <ListItemIcon className={classes.faqExpandIcon}>
          {shouldCollapse[index] ? <ExpandLessIcon /> : <ExpandMoreIcon />}
        </ListItemIcon>
      </ListItem>
      <Collapse in={shouldCollapse[index]} timeout="auto" unmountOnExit>
        <ListItem className={classes.faqAnswer}>
          <ListItemText primary={item.answer} />
        </ListItem>
      </Collapse>
    </List>
  ));
  return (
131
132
133
134
    <div id="faqs">
      <Typography className={classes.faqTitle} variant="h4">
        FAQs
      </Typography>
135
136
137
138
139
140
141
142
      <Container className={classes.faqContainer}>
        <ContactSupportIcon className={classes.faqIcon} />
        <Container className={classes.faqList}>{renderFAQs}</Container>
        <ContactSupportIcon className={classes.faqIconForBG} />
      </Container>
    </div>
  );
}