1- import React , { useEffect , useRef , useState } from "react" ;
2- import { useLocation } from "@reach/router" ;
1+ import React , { useEffect , useRef , useState , useCallback } from "react" ;
2+ // import { useLocation } from "@reach/router";
33import PT from "prop-types" ;
44import { connect } from "react-redux" ;
55import Modal from "../../components/Modal" ;
@@ -17,11 +17,11 @@ import UpdateSuccess from "./modals/UpdateSuccess";
1717import "./styles.scss" ;
1818
1919const MyGigs = ( {
20- myGigs,
21- getMyGigs,
22- loadMore,
23- total,
24- numLoaded,
20+ // myGigs,
21+ // getMyGigs,
22+ // loadMore,
23+ // total,
24+ // numLoaded,
2525 myActiveGigs,
2626 myOpenGigs,
2727 myCompletedGigs,
@@ -35,12 +35,17 @@ const MyGigs = ({
3535 startCheckingGigs,
3636 gigStatus,
3737 loadingMyGigs,
38+ getMyActiveGigs,
39+ getMyOpenGigs,
40+ getMyCompletedGigs,
41+ getMyArchivedGigs,
3842} ) => {
3943 // const location = useLocation();
4044 // const params = utils.url.parseUrlQuery(location.search);
4145 const propsRef = useRef ( ) ;
4246 propsRef . current = {
43- getMyGigs,
47+ // getMyGigs,
48+ getMyOpenGigs,
4449 getProfile,
4550 getAllCountries,
4651 startCheckingGigs,
@@ -59,7 +64,8 @@ const MyGigs = ({
5964 return ;
6065 }
6166 if ( ! checkingGigs ) {
62- propsRef . current . getMyGigs ( ) ;
67+ // propsRef.current.getMyGigs();
68+ propsRef . current . getMyOpenGigs ( ) ;
6369 }
6470 } , [ checkingGigs ] ) ;
6571
@@ -90,6 +96,30 @@ const MyGigs = ({
9096 }
9197 } , [ updateProfileSuccess ] ) ;
9298
99+ const currentLoadMore = useCallback (
100+ ( status , page ) => {
101+ if ( gigStatus == constants . GIGS_FILTER_STATUSES . ACTIVE_JOBS ) {
102+ getMyActiveGigs ( status , page ) ;
103+ }
104+ if ( gigStatus == constants . GIGS_FILTER_STATUSES . OPEN_JOBS ) {
105+ getMyOpenGigs ( status , page ) ;
106+ }
107+ if ( gigStatus == constants . GIGS_FILTER_STATUSES . COMPLETED_JOBS ) {
108+ getMyCompletedGigs ( status , page ) ;
109+ }
110+ if ( gigStatus == constants . GIGS_FILTER_STATUSES . ARCHIVED_JOBS ) {
111+ getMyArchivedGigs ( status , page ) ;
112+ }
113+ } ,
114+ [
115+ gigStatus ,
116+ getMyActiveGigs ,
117+ getMyOpenGigs ,
118+ getMyCompletedGigs ,
119+ getMyArchivedGigs ,
120+ ]
121+ ) ;
122+
93123 return (
94124 < >
95125 < div styleName = "page" >
@@ -126,12 +156,15 @@ const MyGigs = ({
126156 < JobListing
127157 gigStatus = { gigStatus }
128158 jobs = { currentGigs . myGigs }
129- loadMore = { loadMore }
159+ loadMore = { currentLoadMore }
130160 total = { currentGigs . total }
131161 numLoaded = { currentGigs . numLoaded }
162+ page = { currentGigs . page }
132163 />
133164 ) }
134- { checkingGigs || ( loadingMyGigs && ! currentGigs . myGigs && < Loading /> ) }
165+ { ( checkingGigs || ( loadingMyGigs && ! currentGigs . myGigs ) ) && (
166+ < Loading />
167+ ) }
135168 </ div >
136169 < Modal open = { openUpdateProfile } >
137170 < UpdateGigProfile
@@ -158,11 +191,11 @@ const MyGigs = ({
158191
159192MyGigs . propTypes = {
160193 gigStatus : PT . string ,
161- myGigs : PT . arrayOf ( PT . shape ( ) ) ,
162- getMyGigs : PT . func ,
163- loadMore : PT . func ,
164- total : PT . number ,
165- numLoaded : PT . number ,
194+ // myGigs: PT.arrayOf(PT.shape()),
195+ // getMyGigs: PT.func,
196+ // loadMore: PT.func,
197+ // total: PT.number,
198+ // numLoaded: PT.number,
166199 profile : PT . shape ( ) ,
167200 getProfile : PT . func ,
168201 updateProfile : PT . func ,
@@ -175,14 +208,18 @@ MyGigs.propTypes = {
175208 myCompletedGigs : PT . shape ( ) ,
176209 myArchivedGigs : PT . shape ( ) ,
177210 loadingMyGigs : PT . bool ,
211+ getMyActiveGigs : PT . func ,
212+ getMyOpenGigs : PT . func ,
213+ getMyCompletedGigs : PT . func ,
214+ getMyArchivedGigs : PT . func ,
178215} ;
179216
180217const mapStateToProps = ( state ) => ( {
181218 gigStatus : state . filter . gig . status ,
182219 checkingGigs : state . myGigs . checkingGigs ,
183- myGigs : state . myGigs . myGigs ,
184- total : state . myGigs . total ,
185- numLoaded : state . myGigs . numLoaded ,
220+ // myGigs: state.myGigs.myGigs,
221+ // total: state.myGigs.total,
222+ // numLoaded: state.myGigs.numLoaded,
186223 loadingMyGigs : state . myGigs . loadingMyGigs ,
187224 myActiveGigs : state . myGigs [ constants . GIGS_FILTER_STATUSES . ACTIVE_JOBS ] ,
188225 myOpenGigs : state . myGigs [ constants . GIGS_FILTER_STATUSES . OPEN_JOBS ] ,
@@ -193,8 +230,12 @@ const mapStateToProps = (state) => ({
193230} ) ;
194231
195232const mapDispatchToProps = {
196- getMyGigs : actions . myGigs . getMyGigs ,
197- loadMore : actions . myGigs . loadMoreMyGigs ,
233+ // getMyGigs: actions.myGigs.getMyGigs,
234+ // loadMore: actions.myGigs.loadMoreMyGigs,
235+ getMyActiveGigs : actions . myGigs . getMyActiveGigs ,
236+ getMyOpenGigs : actions . myGigs . getMyOpenGigs ,
237+ getMyCompletedGigs : actions . myGigs . getMyCompletedGigs ,
238+ getMyArchivedGigs : actions . myGigs . getMyArchivedGigs ,
198239 getProfile : actions . myGigs . getProfile ,
199240 updateProfile : actions . myGigs . updateProfile ,
200241 getAllCountries : actions . lookup . getAllCountries ,
0 commit comments