Skip to content

Commit 2bc5f86

Browse files
fixed dashboard responsive issue
1 parent eb0f6b1 commit 2bc5f86

File tree

1 file changed

+60
-28
lines changed

1 file changed

+60
-28
lines changed

src/ui/layouts/Home.tsx

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import styles from './Home.module.scss';
2222
import { iconColors, DEFAULT_PROJECT_NAME } from '../../constants';
2323
import { sessionSelectors } from '../../redux/selectors/session';
2424
import { usePushRoute, useSelector } from '../hooks';
25-
import axios from 'axios'
25+
import axios from 'axios';
2626

2727
export const translate = getTranslateByScope('ui.layouts.Dashboard');
2828

@@ -49,7 +49,9 @@ const GreyBoxWithIcon: React.FC<{
4949
<H4 bold>{title}</H4>
5050
</FlexBox.Row>
5151
<Box>
52-
<GhostButton style={{ width: '124px' }} onClick={onClick}>{buttonText}</GhostButton>
52+
<GhostButton style={{ width: '124px' }} onClick={onClick}>
53+
{buttonText}
54+
</GhostButton>
5355
</Box>
5456
</FlexBox.Row>
5557
);
@@ -58,24 +60,27 @@ const GreyBoxWithIcon: React.FC<{
5860
export const Home: React.FC = () => {
5961
const { push } = usePushRoute();
6062

61-
const [box, setBox] = useState('')
63+
const [box, setBox] = useState('');
6264

63-
const [dashboardData, setDashboardData] = useState('')
65+
const [dashboardData, setDashboardData] = useState('');
6466
const authToken = useSelector(sessionSelectors.authenticationToken);
6567

66-
useEffect(() => {
68+
useEffect(() => {
6769
const getDashboardData = async () => {
68-
const { data } = await axios.get(`${process.env.REACT_APP_BASE_API_URL}/projects/${DEFAULT_PROJECT_NAME}/statistics`, {
69-
headers: {
70-
'Authorization': `bearer ${authToken}`
71-
}
72-
})
73-
setDashboardData(data)
74-
}
75-
getDashboardData()
76-
}, [authToken])
70+
const { data } = await axios.get(
71+
`${process.env.REACT_APP_BASE_API_URL}/projects/${DEFAULT_PROJECT_NAME}/statistics`,
72+
{
73+
headers: {
74+
Authorization: `bearer ${authToken}`,
75+
},
76+
},
77+
);
78+
setDashboardData(data);
79+
};
80+
getDashboardData();
81+
}, [authToken]);
7782

78-
const preData = Object.entries(dashboardData)
83+
const preData = Object.entries(dashboardData);
7984
const data = preData?.map(([key, value]) => {
8085
const objData = { text: key, value: value };
8186
return objData;
@@ -85,7 +90,7 @@ export const Home: React.FC = () => {
8590
<AuthenticatedLayout>
8691
<SidebarContainer>
8792
<EaseInBox>
88-
<Box marginTop="5xl" marginLeft='xl' >
93+
<Box marginTop="5xl" marginLeft="xl">
8994
<Row style={{ alignItems: 'center' }}>
9095
<Col xs={12} lg={10}>
9196
<Box paddingBottom="md">
@@ -94,19 +99,46 @@ export const Home: React.FC = () => {
9499
<Box paddingBottom="lg">
95100
<H4 bold>{translate('subtitle')}</H4>
96101
</Box>
97-
98-
<FlexBox>
99-
{data?.map((e, index) => (
100-
<Box key={index} marginRight="xxl" style={{ width: '220px', minHeight: '100px', border: '1px solid #C9CBD0', borderRadius: '6px', padding: '13px 14px', backgroundColor: box === e.text ? '#431D93' : '#fff' }} onClick={() => setBox(e.text)} >
101-
<Paragraph style={{ fontSize: '24px', fontWeight: "bold", color: box === e.text ? '#fff' : '#431D93' }}>{e.value}</Paragraph>
102-
<Paragraph style={{ fontSize: '14px', fontWeight: "inherit", color: box === e.text ? '#fff' : '#646972', marginTop: '38px' }}>Number of {e.text}</Paragraph>
103-
</Box>
104-
))}
105-
</FlexBox>
106102
</Col>
107-
103+
{data?.map((e, index) => (
104+
<Box
105+
key={index}
106+
marginRight="xxl"
107+
style={{
108+
width: '220px',
109+
minHeight: '100px',
110+
border: '1px solid #C9CBD0',
111+
borderRadius: '6px',
112+
padding: '13px 14px',
113+
marginTop: '10px',
114+
backgroundColor: box === e.text ? '#431D93' : '#fff',
115+
}}
116+
onClick={() => setBox(e.text)}
117+
>
118+
<Paragraph
119+
style={{
120+
fontSize: '24px',
121+
fontWeight: 'bold',
122+
color: box === e.text ? '#fff' : '#431D93',
123+
}}
124+
>
125+
{e.value}
126+
</Paragraph>
127+
<Paragraph
128+
style={{
129+
fontSize: '14px',
130+
fontWeight: 'inherit',
131+
color: box === e.text ? '#fff' : '#646972',
132+
marginTop: '38px',
133+
}}
134+
>
135+
Number of {e.text}
136+
</Paragraph>
137+
</Box>
138+
))}
139+
108140
<Col xs={12} lg={7}>
109-
<Box marginTop="xxxl" >
141+
<Box marginTop="xxxl">
110142
<GreyBoxWithIcon
111143
onClick={() =>
112144
window.open(translate('cardOne.button.href'), '_blank')
@@ -137,4 +169,4 @@ export const Home: React.FC = () => {
137169
);
138170
};
139171

140-
export default Home;
172+
export default Home;

0 commit comments

Comments
 (0)