File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ const App = (props) => {
115115 < ShapeList
116116 { ...props }
117117 data = { data }
118+ setSearchTerm = { setSearchTerm }
118119 searchTerm = { searchTerm }
119120 sort = { sort }
120121 shapeAction = { shapeAction }
Original file line number Diff line number Diff line change @@ -370,6 +370,9 @@ const CreateShape = (props) => {
370370
371371 // Finally, close the modal and update the shape in UI
372372 props . handleClose ( ) ;
373+ if ( props . setSearchTerm ) {
374+ props . setSearchTerm ( '' ) ;
375+ }
373376 toast . success ( `Shape ${ shapeInformation . name } created successfully.` ) ;
374377 props . setShapeAction ( {
375378 ...props . shapeAction ,
Original file line number Diff line number Diff line change @@ -41,11 +41,26 @@ const PageWrapper = styled.div`
4141
4242` ;
4343
44- const NoShapeFound = ( props ) => {
44+ const NoShapeFound = ( {
45+ setOpen,
46+ user,
47+ setSearchTerm,
48+ shapeAction,
49+ setShapeAction
50+ } ) => {
4551
4652 // Controls when CreateShape Modal Shows
4753 const [ showCreateShape , setShowCreateShape ] = useState ( false ) ;
4854
55+ const performCreate = ( ) => {
56+
57+ if ( user . length === 0 ) {
58+ setOpen ( true ) ;
59+ } else {
60+ setShowCreateShape ( true ) ;
61+ }
62+ }
63+
4964 const closeModal = ( ) => {
5065 setShowCreateShape ( false ) ;
5166 }
@@ -56,7 +71,7 @@ const NoShapeFound = (props) => {
5671 < img src = { ImgFeelingSad } width = "360" />
5772 < h2 className = "title" > Whooops!</ h2 >
5873 < p className = "desc" > We couldn't find the shape you are looking for. Why don't you start creating a shape of your own choice? or try to refine your search. </ p >
59- < Button variant = 'secondary' onClick = { ( ) => setShowCreateShape ( true ) } >
74+ < Button variant = 'secondary' onClick = { ( ) => performCreate ( ) } >
6075 < FiPlus />
6176 Create Shape
6277 </ Button >
@@ -65,9 +80,10 @@ const NoShapeFound = (props) => {
6580 show = { showCreateShape }
6681 handleClose = { closeModal }
6782 edit = { false }
68- user = { props . user }
69- shapeAction = { props . shapeAction }
70- setShapeAction = { props . setShapeAction }
83+ user = { user }
84+ shapeAction = { shapeAction }
85+ setShapeAction = { setShapeAction }
86+ setSearchTerm = { setSearchTerm }
7187 />
7288 </ >
7389 )
Original file line number Diff line number Diff line change @@ -202,7 +202,8 @@ const ShapeList = (
202202 setOpen,
203203 user,
204204 data,
205- searchTerm,
205+ searchTerm,
206+ setSearchTerm,
206207 sort,
207208 shapeAction,
208209 setShapeAction
@@ -426,7 +427,9 @@ const ShapeList = (
426427 < NoShapeFound
427428 shapeAction = { shapeAction }
428429 setShapeAction = { setShapeAction }
429- user = { user }
430+ user = { user }
431+ setOpen = { setOpen }
432+ setSearchTerm = { setSearchTerm }
430433 /> : filteredShape . map ( ( shape , index ) => (
431434 < React . Fragment key = { index } >
432435 < ShapeCard >
You can’t perform that action at this time.
0 commit comments