Skip to content

Commit e6faf3a

Browse files
committed
Notifications
1 parent 2677c27 commit e6faf3a

File tree

2 files changed

+85
-82
lines changed

2 files changed

+85
-82
lines changed

src/components/fields/SwitchField.js

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
FormLabel,
66
Switch,
77
Text,
8-
useColorModeValue,
8+
useColorModeValue
99
} from "@chakra-ui/react";
1010
// Custom components
1111
import React from "react";
@@ -22,82 +22,81 @@ export default function Default(props) {
2222
fontSize,
2323
...rest
2424
} = props;
25+
let [checked, setChecked] = React.useState(isChecked);
2526
const textColorPrimary = useColorModeValue("secondaryGray.900", "white");
2627
return (
27-
<Box w='100%' fontWeight='500' {...rest}>
28+
<Box w="100%" fontWeight="500" {...rest}>
2829
{reversed ? (
29-
<Flex align='center' borderRadius='16px'>
30-
{isChecked && onChange ? (
30+
<Flex align="center" borderRadius="16px">
31+
{isChecked ? (
3132
<Switch
32-
isChecked={isChecked}
33+
isChecked={checked}
3334
id={id}
34-
variant='main'
35-
colorScheme='brandScheme'
36-
size='md'
37-
onChange={onChange}
35+
variant="main"
36+
colorScheme="brandScheme"
37+
size="md"
38+
onChange={() => setChecked(!checked)}
3839
/>
3940
) : (
4041
<Switch
4142
id={id}
42-
variant='main'
43-
colorScheme='brandScheme'
44-
size='md'
43+
variant="main"
44+
colorScheme="brandScheme"
45+
size="md"
4546
/>
4647
)}
4748
<FormLabel
48-
ms='15px'
49+
ms="15px"
4950
htmlFor={id}
5051
_hover={{ cursor: "pointer" }}
51-
direction='column'
52-
mb='0px'
53-
maxW={textWidth ? textWidth : "75%"}>
54-
<Text
55-
color={textColorPrimary}
56-
fontSize='md'
57-
fontWeight='500'>
52+
direction="column"
53+
mb="0px"
54+
maxW={textWidth ? textWidth : "75%"}
55+
>
56+
<Text color={textColorPrimary} fontSize="md" fontWeight="500">
5857
{label}
5958
</Text>
6059
<Text
61-
color='secondaryGray.600'
62-
fontSize={fontSize ? fontSize : "md"}>
60+
color="secondaryGray.600"
61+
fontSize={fontSize ? fontSize : "md"}
62+
>
6363
{desc}
6464
</Text>
6565
</FormLabel>
6666
</Flex>
6767
) : (
68-
<Flex justify='space-between' align='center' borderRadius='16px'>
68+
<Flex justify="space-between" align="center" borderRadius="16px">
6969
<FormLabel
7070
htmlFor={id}
7171
_hover={{ cursor: "pointer" }}
72-
direction='column'
73-
maxW={textWidth ? textWidth : "75%"}>
74-
<Text
75-
color={textColorPrimary}
76-
fontSize='md'
77-
fontWeight='500'>
72+
direction="column"
73+
maxW={textWidth ? textWidth : "75%"}
74+
>
75+
<Text color={textColorPrimary} fontSize="md" fontWeight="500">
7876
{label}
7977
</Text>
8078
<Text
81-
color='secondaryGray.600'
82-
fontSize={fontSize ? fontSize : "md"}>
79+
color="secondaryGray.600"
80+
fontSize={fontSize ? fontSize : "md"}
81+
>
8382
{desc}
8483
</Text>
8584
</FormLabel>
8685
{isChecked && onChange ? (
8786
<Switch
8887
isChecked={isChecked}
8988
id={id}
90-
variant='main'
91-
colorScheme='brandScheme'
92-
size='md'
89+
variant="main"
90+
colorScheme="brandScheme"
91+
size="md"
9392
onChange={onChange}
9493
/>
9594
) : (
9695
<Switch
9796
id={id}
98-
variant='main'
99-
colorScheme='brandScheme'
100-
size='md'
97+
variant="main"
98+
colorScheme="brandScheme"
99+
size="md"
101100
/>
102101
)}
103102
</Flex>

src/views/admin/profile/components/Notifications.js

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,87 +10,91 @@ export default function Notifications(props) {
1010
// Chakra Color Mode
1111
const textColorPrimary = useColorModeValue("secondaryGray.900", "white");
1212
return (
13-
<Card mb='20px' {...rest}>
14-
<Flex align='center' w='100%' justify='space-between' mb='30px'>
13+
<Card mb="20px" mt="40px" mx="auto" maxW="410px" {...rest}>
14+
<Flex align="center" w="100%" justify="space-between" mb="30px">
1515
<Text
1616
color={textColorPrimary}
17-
fontWeight='bold'
18-
fontSize='2xl'
19-
mb='4px'>
17+
fontWeight="bold"
18+
fontSize="2xl"
19+
mb="4px"
20+
>
2021
Notifications
2122
</Text>
2223
<Menu />
2324
</Flex>
2425
<SwitchField
2526
isChecked={true}
2627
reversed={true}
27-
fontSize='sm'
28-
mb='20px'
29-
id='1'
30-
label='Item update notifications'
28+
fontSize="sm"
29+
mb="20px"
30+
id="1"
31+
label="Item update notifications"
3132
/>
3233
<SwitchField
3334
reversed={true}
34-
fontSize='sm'
35-
mb='20px'
36-
id='2'
37-
label='Item comment notifications'
35+
fontSize="sm"
36+
mb="20px"
37+
id="2"
38+
label="Item comment notifications"
3839
/>
3940
<SwitchField
41+
isChecked={true}
4042
reversed={true}
41-
fontSize='sm'
42-
mb='20px'
43-
id='3'
44-
label='Buyer review notifications'
43+
fontSize="sm"
44+
mb="20px"
45+
id="3"
46+
label="Buyer review notifications"
4547
/>
4648
<SwitchField
49+
isChecked={true}
4750
reversed={true}
48-
fontSize='sm'
49-
mb='20px'
50-
id='4'
51-
label='Rating reminders notifications'
51+
fontSize="sm"
52+
mb="20px"
53+
id="4"
54+
label="Rating reminders notifications"
5255
/>
5356
<SwitchField
5457
reversed={true}
55-
fontSize='sm'
56-
mb='20px'
57-
id='5'
58-
label='Meetups near you notifications'
58+
fontSize="sm"
59+
mb="20px"
60+
id="5"
61+
label="Meetups near you notifications"
5962
/>
6063
<SwitchField
6164
reversed={true}
62-
fontSize='sm'
63-
mb='20px'
64-
id='6'
65-
label='Company news notifications'
65+
fontSize="sm"
66+
mb="20px"
67+
id="6"
68+
label="Company news notifications"
6669
/>
6770
<SwitchField
71+
isChecked={true}
6872
reversed={true}
69-
fontSize='sm'
70-
mb='20px'
71-
id='7'
72-
label='New launches and projects'
73+
fontSize="sm"
74+
mb="20px"
75+
id="7"
76+
label="New launches and projects"
7377
/>
7478
<SwitchField
7579
reversed={true}
76-
fontSize='sm'
77-
mb='20px'
78-
id='8'
79-
label='Monthly product changes'
80+
fontSize="sm"
81+
mb="20px"
82+
id="8"
83+
label="Monthly product changes"
8084
/>
8185
<SwitchField
86+
isChecked={true}
8287
reversed={true}
83-
fontSize='sm'
84-
mb='20px'
85-
id='9'
86-
label='Subscribe to newsletter'
88+
fontSize="sm"
89+
mb="20px"
90+
id="9"
91+
label="Subscribe to newsletter"
8792
/>
8893
<SwitchField
8994
reversed={true}
90-
fontSize='sm'
91-
mb='20px'
92-
id='10'
93-
label='Email me when someone follows me'
95+
fontSize="sm"
96+
id="10"
97+
label="Email me when someone follows me"
9498
/>
9599
</Card>
96100
);

0 commit comments

Comments
 (0)