Skip to content

Commit

Permalink
add endpoint to DashboardContainer key and no need for authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
goplayoutside3 committed Jun 7, 2024
1 parent 0685e44 commit 6359f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { panoptes } from '@zooniverse/panoptes-js'
import auth from 'panoptes-client/lib/auth'
import useSWR from 'swr'

import Dashboard from './Dashboard'
Expand All @@ -13,13 +12,9 @@ const SWROptions = {
}

/* This is a similar pattern to usePanoptesUser hook, but includes the profile_header */
const fetchProfileBanner = async ({ authUser }) => {
const token = await auth.checkBearerToken()
const authorization = `Bearer ${token}`
const query = { include: 'profile_header', user_id: authUser.id }

const fetchProfileBanner = async ({ authUser}) => {
try {
const { body } = await panoptes.get('/users', query, { authorization })
const { body } = await panoptes.get(`/users/${authUser.id}/?include=profile_header`)
const user = body.users?.[0]

if (body.linked?.profile_headers?.length) {
Expand All @@ -33,7 +28,7 @@ const fetchProfileBanner = async ({ authUser }) => {
}

export default function DashboardContainer({ authUser }) {
const key = { authUser }
const key = { endpoint: '/users/[id]', authUser }
const { data: user, isLoading } = useSWR(key, fetchProfileBanner, SWROptions)

return <Dashboard user={user} isLoading={isLoading} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import styled from 'styled-components'
import { Anchor, Box } from 'grommet'
import { Media, SpacedText } from '@zooniverse/react-components'
import { number, string } from 'prop-types'
import { string } from 'prop-types'

const StyledAnchor = styled(Anchor)`
text-decoration: none;
Expand Down Expand Up @@ -99,5 +99,5 @@ SubjectCard.propTypes = {
size: string,
projectSlug: string,
mediaSrc: string,
subjectID: number.isRequired
subjectID: string.isRequired
}

0 comments on commit 6359f59

Please sign in to comment.