Unauth users were unable to view collections
This commit is contained in:
parent
ea24777eb7
commit
54d34fed12
2 changed files with 16 additions and 6 deletions
|
|
@ -50,21 +50,26 @@ const ProfileRoute: React.FC = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const fetchProfile = useCallback(() => {
|
const fetchProfile = useCallback(() => {
|
||||||
const filterParams = {
|
const filters = {
|
||||||
params: {
|
params: {
|
||||||
element: element,
|
element: element,
|
||||||
raid: raidId,
|
raid: raidId,
|
||||||
recency: recencyInSeconds
|
recency: recencyInSeconds
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${cookies.account.access_token}`
|
'Authorization': `Bearer ${cookies.account.access_token}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const params = (cookies.account) ? {...filters, ...headers} : filters
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
if (username)
|
if (username)
|
||||||
api.endpoints.users.getOne({ id: username as string, params: filterParams })
|
api.endpoints.users.getOne({ id: username as string, params: params })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
setUser({
|
setUser({
|
||||||
id: response.data.user.id,
|
id: response.data.user.id,
|
||||||
|
|
|
||||||
|
|
@ -43,20 +43,25 @@ const TeamsRoute: React.FC = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const fetchTeams = useCallback(() => {
|
const fetchTeams = useCallback(() => {
|
||||||
const filterParams = {
|
const filters = {
|
||||||
params: {
|
params: {
|
||||||
element: element,
|
element: element,
|
||||||
raid: raidId,
|
raid: raidId,
|
||||||
recency: recencyInSeconds
|
recency: recencyInSeconds
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${cookies.account?.access_token}`
|
'Authorization': `Bearer ${cookies.account?.access_token}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const params = (cookies.account) ? {...filters, ...headers} : filters
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
api.endpoints.parties.getAll(filterParams)
|
api.endpoints.parties.getAll(params)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const parties: Party[] = response.data
|
const parties: Party[] = response.data
|
||||||
setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))
|
setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue