@@ -16,10 +16,13 @@ export const challengeService = createApi({
16
16
refetchOnMountOrArgChange : true ,
17
17
endpoints : ( builder ) => ( {
18
18
findChallengeById : builder . query ( {
19
- query : ( { id, relations } ) => {
19
+ query : ( { id, relations, locale } ) => {
20
20
const params = queryString . stringify ( { relations : relations || [ ] } , { arrayFormat : "bracket" } ) ;
21
21
return {
22
22
url : `challenges/${ id } ?${ params } ` ,
23
+ headers : {
24
+ "accept-language" : locale ,
25
+ } ,
23
26
} ;
24
27
} ,
25
28
onQueryStarted : async ( _ , { dispatch, queryFulfilled } ) => {
@@ -36,7 +39,14 @@ export const challengeService = createApi({
36
39
} ) ,
37
40
38
41
getAllChallenges : builder . query ( {
39
- query : ( slug ) => `communities/${ slug } /challenges` ,
42
+ query : ( { slug, locale } ) => {
43
+ return {
44
+ url : `communities/${ slug } /challenges` ,
45
+ headers : {
46
+ "accept-language" : locale ,
47
+ } ,
48
+ } ;
49
+ } ,
40
50
onQueryStarted : async ( _ , { dispatch, queryFulfilled } ) => {
41
51
try {
42
52
const { data } = await queryFulfilled ;
@@ -49,10 +59,13 @@ export const challengeService = createApi({
49
59
} ) ,
50
60
51
61
fetchChallengeByIdAuthenticated : builder . query ( {
52
- query : ( { id, relations } ) => {
62
+ query : ( { id, relations, locale } ) => {
53
63
const params = queryString . stringify ( { relations : relations || [ ] } , { arrayFormat : "bracket" } ) ;
54
64
return {
55
65
url : `challenges/${ id } ?${ params } ` ,
66
+ headers : {
67
+ "accept-language" : locale ,
68
+ } ,
56
69
} ;
57
70
} ,
58
71
onQueryStarted : async ( _ , { dispatch, queryFulfilled } ) => {
@@ -95,14 +108,15 @@ export const challengeService = createApi({
95
108
} ) ,
96
109
} ) ;
97
110
98
- export const fetchChallenge = ( { id, relations } : { id : string ; relations ?: string [ ] } ) =>
111
+ export const fetchChallenge = ( { id, relations, locale } : { id : string ; relations ?: string [ ] ; locale ?: string } ) =>
99
112
challengeService . endpoints . findChallengeById . initiate ( {
100
113
id,
101
114
relations : relations || [ ] ,
115
+ locale,
102
116
} ) ;
103
117
104
- export const fetchAllChallenges = ( { slug } : { slug : string } ) => {
105
- return challengeService . endpoints . getAllChallenges . initiate ( slug ) ;
118
+ export const fetchAllChallenges = ( { slug, locale } : { slug : string ; locale ? : string } ) => {
119
+ return challengeService . endpoints . getAllChallenges . initiate ( { slug, locale } ) ;
106
120
} ;
107
121
108
122
/**
0 commit comments