@@ -10,7 +10,10 @@ import {
1010 Box ,
1111 Chip
1212} from '@material-ui/core' ;
13-
13+ import { useState } from 'react' ;
14+ import copy from 'copy-to-clipboard' ;
15+ import { SnackbarProvider , useSnackbar } from 'notistack' ;
16+ import { useSelector } from 'react-redux' ;
1417const useStyles = makeStyles ( theme => ( {
1518 root : {
1619 fontFamily : 'Montserrat' ,
@@ -103,100 +106,125 @@ const AntSwitch = withStyles(theme => ({
103106 checked : { }
104107} ) ) ( Switch ) ;
105108
106- function ProfileInfo ( { myProfile } ) {
109+ function ProfileInfo ( { myProfile, profileType } ) {
107110 const classes = useStyles ( ) ;
108111 const interestedInArr = myProfile . interestedIn . split ( ',' ) ;
112+ const [ copyText , setCopyText ] = useState ( true ) ;
113+ const { enqueueSnackbar } = useSnackbar ( ) ;
114+ const user = useSelector ( state => state . account . user ) ;
115+
116+ const handleClick = ( ) => {
117+ let variant = 'success' ;
118+ let publicUrl =
119+ window . location . protocol +
120+ '//' +
121+ window . location . host +
122+ '/publicProfile/' +
123+ user . uid ;
124+ if ( copyText ) {
125+ copy ( publicUrl ) ;
126+ enqueueSnackbar ( 'Your Public Profile Link Is Copied!🥳' , { variant } ) ;
127+ }
128+ setCopyText ( ! copyText ) ;
129+ } ;
109130
110131 return (
111132 < Grid container className = { classes . root } >
112- < Box >
113- < Avatar
114- alt = "ProfileIcon"
115- src = "./static/profile/icons/icons.png"
116- className = { classes . medium }
117- />
118- </ Box >
119-
120- < Box
121- display = "flex"
122- justifyContent = "flex-end"
123- style = { { position : 'absolute' , right : '60px' , paddingTop : '50px' } }
124- >
125- < Typography variant = "h2" className = { classes . publictext } >
126- Public View
127- </ Typography >
128-
129- < AntSwitch />
130- </ Box >
131-
132- < Card className = { classes . cards } >
133- < Box display = "flex" justifyContent = "flex-end" >
134- < Box flexGrow = { 1 } />
135- < Box xs = { 12 } sm = { 8 } >
136- < IconButton href = { myProfile . linkedIn } >
137- < img
138- className = { classes . tiny }
139- alt = "LinkedIn"
140- src = "./static/profile/icons/Vector.png"
141- />
142- </ IconButton >
143- < IconButton href = { myProfile . twitter } >
144- < img
145- className = { classes . tiny }
146- alt = "Twitter"
147- src = "./static/profile/icons/Vector-1.png"
148- />
149- </ IconButton >
150- < IconButton href = { myProfile . github } >
151- < img
152- className = { classes . tiny }
153- alt = "GitHub"
154- src = "./static/profile/icons/Vector-3.png"
155- />
156- </ IconButton >
157- < IconButton href = { myProfile . website } >
158- < img
159- className = { classes . tiny }
160- alt = "Website"
161- src = "./static/profile/icons/Vector-2.png"
162- />
163- </ IconButton >
164- </ Box >
133+ < SnackbarProvider maxSnack = { 3 } >
134+ < Box >
135+ < Avatar
136+ alt = "ProfileIcon"
137+ src = {
138+ myProfile . photoURL . length > 0
139+ ? myProfile . photoURL
140+ : '.././static/profile/icons/icons.png'
141+ }
142+ className = { classes . medium }
143+ />
165144 </ Box >
166145
167- < Box
168- display = "flex"
169- flexWrap = "wrap"
170- style = { { paddingLeft : '60px' , paddingTop : '10px' } }
171- >
172- < Box flexGrow = { 1 } minWidth = { 200 } >
173- < Typography variant = "h1" style = { { fontWeight : '650' } } >
174- { myProfile . fullName }
175- </ Typography >
176- < Typography variant = "body2" style = { { fontWeight : '650' } } >
177- { myProfile . role }
178- </ Typography >
179- < Typography variant = "body2" className = { classes . profiledesc } >
180- { myProfile . description }
146+ { profileType === 'private' && (
147+ < Box
148+ display = "flex"
149+ justifyContent = "flex-end"
150+ style = { { position : 'absolute' , right : '60px' , paddingTop : '50px' } }
151+ >
152+ < Typography variant = "h2" className = { classes . publictext } >
153+ Public View
181154 </ Typography >
155+
156+ < AntSwitch onClick = { handleClick } />
182157 </ Box >
158+ ) }
159+ < Card className = { classes . cards } >
160+ < Box display = "flex" justifyContent = "flex-end" >
161+ < Box flexGrow = { 1 } />
162+ < Box xs = { 12 } sm = { 8 } >
163+ < IconButton href = { myProfile . linkedIn } >
164+ < img
165+ className = { classes . tiny }
166+ alt = "LinkedIn"
167+ src = ".././static/profile/icons/Vector.png"
168+ />
169+ </ IconButton >
170+ < IconButton href = { myProfile . twitter } >
171+ < img
172+ className = { classes . tiny }
173+ alt = "Twitter"
174+ src = ".././static/profile/icons/Vector-1.png"
175+ />
176+ </ IconButton >
177+ < IconButton href = { myProfile . github } >
178+ < img
179+ className = { classes . tiny }
180+ alt = "GitHub"
181+ src = ".././static/profile/icons/Vector-3.png"
182+ />
183+ </ IconButton >
184+ < IconButton href = { myProfile . website } >
185+ < img
186+ className = { classes . tiny }
187+ alt = "Website"
188+ src = ".././static/profile/icons/Vector-2.png"
189+ />
190+ </ IconButton >
191+ </ Box >
192+ </ Box >
193+
183194 < Box
184- flexGrow = { 1.5 }
185- maxWidth = { 380 }
186- mt = { 1 }
187- style = { { marginTop : '50px' } }
195+ display = "flex"
196+ flexWrap = "wrap"
197+ style = { { paddingLeft : '60px' , paddingTop : '10px' } }
188198 >
189- < Typography variant = "h2" style = { { fontWeight : '650' } } >
190- Interested in:
191- </ Typography >
192- { interestedInArr
193- . filter ( e => String ( e ) . trim ( ) )
194- . map ( tagName => (
195- < Chip key = { tagName } className = { classes . tags } label = { tagName } />
196- ) ) }
199+ < Box flexGrow = { 1 } minWidth = { 200 } >
200+ < Typography variant = "h1" style = { { fontWeight : '650' } } >
201+ { myProfile . fullName }
202+ </ Typography >
203+ < Typography variant = "body2" style = { { fontWeight : '650' } } >
204+ { myProfile . role }
205+ </ Typography >
206+ < Typography variant = "body2" className = { classes . profiledesc } >
207+ { myProfile . description }
208+ </ Typography >
209+ </ Box >
210+ < Box
211+ flexGrow = { 1.5 }
212+ maxWidth = { 380 }
213+ mt = { 1 }
214+ style = { { marginTop : '50px' } }
215+ >
216+ < Typography variant = "h2" style = { { fontWeight : '650' } } >
217+ Interested in:
218+ </ Typography >
219+ { interestedInArr
220+ . filter ( e => String ( e ) . trim ( ) )
221+ . map ( ( tagName , idx ) => (
222+ < Chip key = { idx } className = { classes . tags } label = { tagName } />
223+ ) ) }
224+ </ Box >
197225 </ Box >
198- </ Box >
199- </ Card >
226+ </ Card >
227+ </ SnackbarProvider >
200228 </ Grid >
201229 ) ;
202230}
0 commit comments