Skip to content

Commit 1164195

Browse files
committed
refactor CookieConsent component for improved code readability and consistency
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 7c02c65 commit 1164195

1 file changed

Lines changed: 57 additions & 57 deletions

File tree

src/components/CookieConsent/index.js

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
import React, { useEffect, useState } from "react";
33
import {
4-
Snackbar,
5-
Typography,
6-
Box,
7-
Paper,
8-
Stack,
4+
Snackbar,
5+
Typography,
6+
Box,
7+
Paper,
8+
Stack,
99
} from "@mui/material";
1010

1111

@@ -17,72 +17,72 @@ const StyledContainer = styled.div`
1717
background-color: ${props => props.theme.elevationColor};
1818
color: ${props => props.theme.text};
1919
}
20-
`
20+
`;
2121

2222

2323
const CookieConsent = () => {
24-
const [open, setOpen] = useState(false);
24+
const [open, setOpen] = useState(false);
2525

26-
useEffect(() => {
27-
const consent = localStorage.getItem("cookie_consent");
28-
if (!consent) {
29-
setOpen(true);
30-
}
31-
}, []);
26+
useEffect(() => {
27+
const consent = localStorage.getItem("cookie_consent");
28+
if (!consent) {
29+
setOpen(true);
30+
}
31+
}, []);
3232

33-
const handleResponse = (response) => {
34-
localStorage.setItem("cookie_consent", response);
35-
setOpen(false);
36-
};
33+
const handleResponse = (response) => {
34+
localStorage.setItem("cookie_consent", response);
35+
setOpen(false);
36+
};
3737

38-
return (
39-
<Snackbar
40-
open={open}
41-
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
38+
return (
39+
<Snackbar
40+
open={open}
41+
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
42+
>
43+
<StyledContainer>
44+
<Paper
45+
elevation={6}
46+
sx={{
47+
p: 2,
48+
maxWidth: 620,
49+
borderRadius: 2,
50+
}}
51+
className="paper-container"
4252
>
43-
<StyledContainer>
44-
<Paper
45-
elevation={6}
46-
sx={{
47-
p: 2,
48-
maxWidth: 620,
49-
borderRadius: 2,
50-
}}
51-
className="paper-container"
52-
>
53-
<Stack spacing={2}>
54-
<Typography variant="body2" >
53+
<Stack spacing={2}>
54+
<Typography variant="body2" >
5555
We use cookies to enhance your browsing experience. By clicking
5656
"Accept", you consent to our use of cookies. Read more in our{" "}
57-
<a href="/company/legal/privacy" target="_blank" rel="noopener noreferrer">
57+
<a href="/company/legal/privacy" target="_blank" rel="noopener noreferrer">
5858
Privacy Policy
59-
</a>
59+
</a>
6060
.
61-
</Typography>
61+
</Typography>
6262

63-
<Box display="flex" justifyContent="flex-end" gap={1}>
64-
<Button
65-
variant="outlined"
66-
size="small"
67-
$outlined
68-
onClick={() => handleResponse("declined")}
69-
>
63+
<Box display="flex" justifyContent="flex-end" gap={1}>
64+
<Button
65+
variant="outlined"
66+
size="small"
67+
$outlined
68+
onClick={() => handleResponse("declined")}
69+
>
7070
Decline
71-
</Button>
72-
<Button
73-
variant="contained"
74-
size="small"
75-
$secondary
76-
onClick={() => handleResponse("accepted")}
77-
>
71+
</Button>
72+
<Button
73+
variant="contained"
74+
size="small"
75+
$secondary
76+
onClick={() => handleResponse("accepted")}
77+
>
7878
Accept
79-
</Button>
80-
</Box>
81-
</Stack>
82-
</Paper>
83-
</StyledContainer>
84-
</Snackbar>
85-
);
79+
</Button>
80+
</Box>
81+
</Stack>
82+
</Paper>
83+
</StyledContainer>
84+
</Snackbar>
85+
);
8686
};
8787

8888
export default CookieConsent;

0 commit comments

Comments
 (0)