File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,14 +18,18 @@ const App = (props) => {
1818 const [ loading , setLoading ] = useState ( true ) ; // shapes loading
1919
2020 const [ searchTerm , setSearchTerm ] = useState ( "" ) ; // search
21- const [ sort , setSort ] = useState ( "popularity" ) ; // sort
21+ const [ sort , setSort ] = useState ( "recent" ) ; // sort
22+
23+ const [ shapeAction , setShapeAction ] = useState ( {
24+ 'action' : '' ,
25+ 'payload' : { }
26+ } ) ;
2227
2328 const { user } = props ;
2429
2530 useEffect ( async ( ) => {
2631 setData ( [ ] ) ;
2732 setLoading ( true ) ;
28-
2933 let shapes = [ ] ;
3034
3135 if ( user . length === 0 ) {
@@ -84,18 +88,21 @@ const App = (props) => {
8488 } ) ;
8589
8690 console . log ( shapes ) ;
87-
91+ console . log ( { shapeAction } ) ;
8892 await setData ( shapes ) ;
93+ console . log ( shapes ) ;
8994 setLoading ( false ) ;
90- } , [ user ] ) ;
95+ } , [ user , shapeAction ] ) ;
9196
9297 return (
9398 < >
9499 < Header { ...props }
95100 searchTerm = { searchTerm }
96101 setSearchTerm = { setSearchTerm }
97102 sort = { sort }
98- setSort = { setSort } />
103+ setSort = { setSort }
104+ shapeAction = { shapeAction }
105+ setShapeAction = { setShapeAction } />
99106 { loading ? (
100107 < Loader
101108 style = { { margin : '20% auto auto 42%' } }
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const CreateShape = (props) => {
2222 "edges" : 4 ,
2323 "notes" : "" ,
2424 "clipPathType" : "polygon" ,
25- "showShadow" : false ,
25+ "showShadow" : true ,
2626 "backgroundColor" : "#d61284" ,
2727 "verticeCoordinates" : [
2828 {
@@ -258,6 +258,26 @@ const CreateShape = (props) => {
258258 }
259259 props . handleClose ( ) ;
260260 toast . success ( `Shape ${ shapeInformation . name } created successfully.` ) ;
261+ props . setShapeAction ( {
262+ ...props . shapeAction ,
263+ "action" : "add" ,
264+ "payload" : {
265+ "backgroundColor" : shapeInformation . backgroundColor ,
266+ "createdAt" : null ,
267+ "createdBy" : props . user . email ,
268+ "edges" : shapeInformation . edges ,
269+ "email" : null ,
270+ "email1" : props . user . email ,
271+ "formula" : shapeInformation . formula ,
272+ "likes" : 0 ,
273+ "name" : shapeInformation . name ,
274+ "name1" : props . user . displayName ,
275+ "notes" : shapeInformation . notes ,
276+ "photoURL" : props . user . photoURL ,
277+ "private" : shapeInformation . private ,
278+ "type" : shapeInformation . clipPathType
279+ }
280+ } ) ;
261281 }
262282
263283 return (
Original file line number Diff line number Diff line change @@ -137,7 +137,9 @@ const Header = ({
137137 searchTerm,
138138 setSearchTerm,
139139 sort,
140- setSort
140+ setSort,
141+ shapeAction,
142+ setShapeAction
141143} ) => {
142144
143145 const [ searchterm , setSearchterm ] = useState ( '' ) ;
@@ -233,7 +235,12 @@ const Header = ({
233235 < div > Sign In</ div >
234236 </ Button >
235237 ) }
236- < CreateShape show = { showCreateShape } handleClose = { closeModal } user = { user } />
238+ < CreateShape
239+ show = { showCreateShape }
240+ handleClose = { closeModal }
241+ user = { user }
242+ shapeAction = { shapeAction }
243+ setShapeAction = { setShapeAction } />
237244 </ AppHeader >
238245 ) ;
239246} ;
You can’t perform that action at this time.
0 commit comments