@@ -5,14 +5,15 @@ import React, { useState, useLayoutEffect, useEffect, useRef } from "react";
5
5
import { Router , useLocation , Redirect } from "@reach/router" ;
6
6
import Challenges from "./containers/Challenges" ;
7
7
import Filter from "./containers/Filter" ;
8
+ import MyGigsFilter from "./containers/MyGigsFilter" ;
8
9
import MyGigs from "./containers/MyGigs" ;
9
10
import Menu from "./components/Menu" ;
10
11
import { disableSidebarForRoute } from "@topcoder/micro-frontends-navbar-app" ;
11
12
import * as constants from "./constants" ;
12
13
import actions from "./actions" ;
13
14
import * as utils from "./utils" ;
14
15
import store from "./store" ;
15
- import { initialChallengeFilter } from "./reducers/filter" ;
16
+ import { initialChallengeFilter , initialGigFilter } from "./reducers/filter" ;
16
17
import _ from "lodash" ;
17
18
import { usePreviousLocation } from "./utils/hooks" ;
18
19
import { useSelector } from "react-redux" ;
@@ -38,6 +39,9 @@ const App = () => {
38
39
selected = { selectedMenuItem }
39
40
onSelect = { ( item ) => {
40
41
setSelectedMenuItem ( item ) ;
42
+ if ( item == "Gigs" ) {
43
+ window . location . href = `${ process . env . URL . BASE } /gigs` ;
44
+ }
41
45
} }
42
46
isLoggedIn = { isLoggedIn }
43
47
/>
@@ -46,7 +50,7 @@ const App = () => {
46
50
const location = useLocation ( ) ;
47
51
const previousLocation = usePreviousLocation ( ) ;
48
52
49
- const getChallengesDebounced = useRef ( _ . debounce ( ( f ) => f ( ) , 500 ) ) ;
53
+ const getDataDebounced = useRef ( _ . debounce ( ( f ) => f ( ) , 500 ) ) ;
50
54
51
55
useEffect ( ( ) => {
52
56
store . dispatch ( actions . lookup . checkIsLoggedIn ( ) ) ;
@@ -74,12 +78,46 @@ const App = () => {
74
78
if ( diff ) {
75
79
store . dispatch ( actions . filter . updateFilter ( updatedFilter ) ) ;
76
80
}
77
- getChallengesDebounced . current ( ( ) =>
81
+ getDataDebounced . current ( ( ) =>
78
82
store . dispatch ( actions . challenges . getChallenges ( updatedFilter ) )
79
83
) ;
80
84
}
81
85
} , [ location ] ) ;
82
86
87
+ useEffect ( ( ) => {
88
+ if ( location . pathname === "/earn/my-gigs" && isLoggedIn ) {
89
+ if ( ! location . search ) {
90
+ store . dispatch ( actions . filter . updateGigFilter ( initialGigFilter ) ) ;
91
+
92
+ store . dispatch (
93
+ actions . myGigs . getMyGigs (
94
+ constants . GIGS_FILTER_STATUSES_PARAM [ initialGigFilter . status ]
95
+ )
96
+ ) ;
97
+ return ;
98
+ }
99
+ const params = utils . url . parseUrlQuery ( location . search ) ;
100
+ if ( _ . keys ( params ) . length == 1 && params . externalId ) {
101
+ return ;
102
+ }
103
+ const updatedGigFilter = {
104
+ status : params . status || "Open Applications" ,
105
+ } ;
106
+ const currentGig = store . getState ( ) . filter . gig ;
107
+ const diff = ! _ . isEqual ( updatedGigFilter , currentGig ) ;
108
+ if ( diff ) {
109
+ store . dispatch ( actions . filter . updateGigFilter ( updatedGigFilter ) ) ;
110
+ }
111
+ getDataDebounced . current ( ( ) =>
112
+ store . dispatch (
113
+ actions . myGigs . getMyGigs (
114
+ constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
115
+ )
116
+ )
117
+ ) ;
118
+ }
119
+ } , [ location , isLoggedIn ] ) ;
120
+
83
121
const varsRef = useRef ( ) ;
84
122
varsRef . current = { previousLocation } ;
85
123
@@ -108,7 +146,8 @@ const App = () => {
108
146
< div className = "sidebar-content" >
109
147
{ menu }
110
148
< hr />
111
- < Filter />
149
+ { location . pathname === "/earn/find/challenges" && < Filter /> }
150
+ { location . pathname === "/earn/my-gigs" && < MyGigsFilter /> }
112
151
</ div >
113
152
< div className = "sidebar-footer" >
114
153
< a
0 commit comments