Skip to content

Commit

Permalink
Refactor remaining pages (#416)
Browse files Browse the repository at this point in the history
* refactor remaining pages

* fix react-bootstrap imports

* Remove variables from content (#417)

* remove doi vars

* remove organization vars

* remove people vars

* remove unused vars

* remove unnecessary import
  • Loading branch information
bklaing2 authored Nov 12, 2024
1 parent 7944e96 commit 5ca707a
Show file tree
Hide file tree
Showing 41 changed files with 180 additions and 206 deletions.
75 changes: 72 additions & 3 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,80 @@
import React from 'react'
import About from 'src/components/About/About'
import { Container } from 'react-bootstrap'
import Container from 'react-bootstrap/Container'
import Col from 'react-bootstrap/Col'
import Row from 'react-bootstrap/Row'

export default function AboutPage() {
return (
<Container fluid>
<About title={'About'} />
<Row>
<Col md={{ span: 9, offset: 3 }}>
<div className="panel panel-transparent">
<div className="panel-body">
<h3 className="member">About</h3>
<p>
DataCite Commons is a web search interface for the{' '}
<a
href="https://doi.org/10.5438/jwvf-8a66"
target="_blank"
rel="noreferrer"
>
PID Graph
</a>
, the graph formed by the collection of scholarly resources such
as publications, datasets, people and research organizations, and
their connections. The PID Graph uses persistent identifiers and{' '}
<a href="https://graphql.org/" target="_blank" rel="noreferrer">
GraphQL
</a>
, with PIDs and metadata provided by DataCite, Crossref, ORCID,
and others.
</p>
<p>
DataCite Commons was officially launched in October 2020 by the{' '}
<a
href="https://www.project-freya.eu/en/about/mission"
target="_blank"
rel="noreferrer"
>
FREYA project
</a>
, funded by the European Union’s Horizon 2020 research and
innovation programme under grant agreement No 777523.
</p>
<p>
DataCite Commons is partially supported by the{' '}
<a
href="https://parsecproject.org"
target="_blank"
rel="noreferrer"
>
PARSEC project
</a>{' '}
funded by the Belmont Forum (Collaborative Research Action on
Science-Driven e-Infrastructures Innovation) managed through the
National Science Foundation (Grant ID 1929464).
</p>
<p>
<a
href="https://portal.productboard.com/71qotggkmbccdwzokuudjcsb/c/35-common-doi-search"
target="_blank"
rel="noreferrer"
>
Provide input to the DataCite Roadmap
</a>{' '}
|{' '}
<a
href="https://support.datacite.org/docs/datacite-commons"
target="_blank"
rel="noreferrer"
>
Information in DataCite Support
</a>
</p>
</div>
</div>
</Col>
</Row>
</Container>
)
}
10 changes: 5 additions & 5 deletions src/app/doi.org/[...doi]/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Row from 'react-bootstrap/Row'
import Col from 'react-bootstrap/Col'

import { Work as WorkType } from 'src/data/types'
import { fetchDoi, QueryVar } from 'src/data/queries/doiQuery'
import { fetchDoi } from 'src/data/queries/doiQuery'

import Error from 'src/components/Error/Error'
import TitleComponent from 'src/components/Title/Title'
Expand All @@ -18,14 +18,14 @@ import { isProject } from 'src/utils/helpers';
import ExportMetadata from 'src/components/DownloadMetadata/ExportMetadata'

interface Props {
variables: QueryVar
doi: string
isBot?: boolean
}

export default async function Content(props: Props) {
const { variables, isBot = false } = props
const { doi, isBot = false } = props

const { data, error } = await fetchDoi(variables)
const { data, error } = await fetchDoi(doi)

if (error) return (
<Col md={{ span: 9, offset: 3 }}>
Expand Down Expand Up @@ -73,7 +73,7 @@ export default async function Content(props: Props) {
type: 'doi/related-works',
}
]}
variables={variables as any}
variables={{ id: doi }}
/>}
</Row>
<Row className="mb-2 pb-4">
Expand Down
4 changes: 3 additions & 1 deletion src/app/doi.org/[...doi]/RelatedAggregateGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react'
import { Col, Container, Row } from 'react-bootstrap'
import Container from 'react-bootstrap/Container'
import Row from 'react-bootstrap/Row'
import Col from 'react-bootstrap/Col'
import { GraphData, getRelatedWorksGraph } from 'src/data/queries/relatedWorks'
import ForceDirectedGraph from 'src/components/ForceDirectedGraph/ForceDirectedGraph'
import EmptyChart from 'src/components/EmptyChart/EmptyChart'
Expand Down
14 changes: 5 additions & 9 deletions src/app/doi.org/[...doi]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import { fetchDoiMetadata } from 'src/data/queries/doiQuery'
import RelatedContent from './RelatedContent'
import RelatedAggregateGraph from './RelatedAggregateGraph'
import Loading from 'src/components/Loading/Loading'
import mapSearchparams, { SearchParams } from './mapSearchParams'


interface Props {
params: {
doi: string[]
},
searchParams: SearchParams
}
}


Expand Down Expand Up @@ -83,18 +81,16 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
}

export default async function Page({ params, searchParams }: Props) {
export default async function Page({ params }: Props) {
const doi = decodeURIComponent(params.doi.join('/'))
const { variables } = mapSearchparams(searchParams)
const vars = { id: doi, ...variables }


// Redirect to organization page if DOI is a Crossref Funder ID
if (doi.startsWith('10.13039')) {
const { data } = await fetchCrossrefFunder(doi)

if (!data) notFound()
redirect(`/ror.org${rorFromUrl(data.organization.id)}?filterQuery=${vars.filterQuery}`)
redirect(`/ror.org${rorFromUrl(data.organization.id)}`)
}


Expand All @@ -106,10 +102,10 @@ export default async function Page({ params, searchParams }: Props) {

return <>
<Suspense fallback={<Loading />}>
<Content variables={vars} isBot={false} />
<Content doi={doi} />
</Suspense>
<Suspense>
<RelatedAggregateGraph doi={doi} isBot={false} />
<RelatedAggregateGraph doi={doi} />
</Suspense>
<RelatedContent />
<Script type="application/ld+json" id="schemaOrg">{data.work.schemaOrg}</Script>
Expand Down
8 changes: 4 additions & 4 deletions src/app/orcid.org/[orcid]/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import Container from 'react-bootstrap/Container'
import Row from 'react-bootstrap/Row'
import Col from 'react-bootstrap/Col'

import { QueryVar, fetchPerson } from 'src/data/queries/personQuery'
import { fetchPerson } from 'src/data/queries/personQuery'

import Error from 'src/components/Error/Error'
import ShareLinks from 'src/components/ShareLinks/ShareLinks'
import Person from 'src/components/Person/Person'
import { orcidFromUrl } from 'src/utils/helpers'

interface Props {
variables: QueryVar
orcid: string
isBot?: boolean
}

export default async function Content(props: Props) {
const { variables } = props
const { orcid } = props

const { data, error } = await fetchPerson(variables)
const { data, error } = await fetchPerson(orcid)

if (error) return (
<Col md={{ span: 9, offset: 3 }}>
Expand Down
10 changes: 3 additions & 7 deletions src/app/orcid.org/[orcid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import Content from './Content'
import { fetchPersonMetadata } from 'src/data/queries/personQuery'
import RelatedContent from './RelatedContent'
import Loading from 'src/components/Loading/Loading'
import mapSearchparams, { SearchParams } from './mapSearchParams'


interface Props {
params: {
orcid: string
},
searchParams: SearchParams
}
}


Expand Down Expand Up @@ -78,10 +76,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
}

export default async function Page({ params, searchParams }: Props) {
export default async function Page({ params }: Props) {
const orcid = 'http://orcid.org/' + params.orcid
const { variables } = mapSearchparams(searchParams)
const vars = { id: orcid, ...variables }


// Fetch Person metadata
Expand All @@ -92,7 +88,7 @@ export default async function Page({ params, searchParams }: Props) {

return <>
<Suspense fallback={<Loading />}>
<Content variables={vars} />
<Content orcid={orcid} />
</Suspense>
<RelatedContent />
</>
Expand Down
10 changes: 5 additions & 5 deletions src/app/ror.org/[rorid]/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Row from 'react-bootstrap/Row'
import Col from 'react-bootstrap/Col'

import { Organization as OrganizationType } from 'src/data/types'
import { fetchOrganization, QueryVar } from 'src/data/queries/organizationQuery';
import { fetchOrganization } from 'src/data/queries/organizationQuery';

import Error from 'src/components/Error/Error'
import Title from 'src/components/Title/Title'
Expand All @@ -14,14 +14,14 @@ import Organization from 'src/components/Organization/Organization'
import { rorFromUrl } from 'src/utils/helpers'

interface Props {
variables: QueryVar
rorid: string
isBot?: boolean
}

export default async function Content(props: Props) {
const { variables, isBot = false } = props
const { rorid, isBot = false } = props

const { data, error } = await fetchOrganization(variables)
const { data, error } = await fetchOrganization(rorid)

if (error) return (
<Col md={{ span: 9, offset: 3 }}>
Expand Down Expand Up @@ -55,7 +55,7 @@ export default async function Content(props: Props) {
type: 'ror/funders',
}
]}
variables={variables as any}
variables={{ id: rorid }}
/>}
<ShareLinks url={'ror.org' + rorFromUrl(organization.id)} title={organization.name} />
</Col>
Expand Down
10 changes: 3 additions & 7 deletions src/app/ror.org/[rorid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import Content from './Content'
import RelatedContent from './RelatedContent'
import Loading from 'src/components/Loading/Loading'
import { fetchOrganizationMetadata } from 'src/data/queries/organizationQuery'
import mapSearchparams, { SearchParams } from './mapSearchParams'


interface Props {
params: {
rorid: string
},
searchParams: SearchParams
}
}


Expand Down Expand Up @@ -65,10 +63,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {



export default async function Page({ params, searchParams }: Props) {
export default async function Page({ params }: Props) {
const { rorid } = params
const { variables } = mapSearchparams(searchParams)
const vars = { id: rorid, ...variables }

// Fetch Organization metadata
const { data } = await fetchOrganizationMetadata(rorid)
Expand All @@ -77,7 +73,7 @@ export default async function Page({ params, searchParams }: Props) {

return <>
<Suspense fallback={<Loading />}>
<Content variables={vars} isBot={false} />
<Content rorid={rorid} />
</Suspense>
<RelatedContent />
</>
Expand Down
5 changes: 4 additions & 1 deletion src/app/statistics/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use client'

import React from 'react'
import { Alert, Col, Container, Row } from 'react-bootstrap'
import Container from 'react-bootstrap/Container'
import Row from 'react-bootstrap/Row'
import Col from 'react-bootstrap/Col'
import Alert from 'react-bootstrap/Alert'
import Loading from 'src/components/Loading/Loading'

import { useStatisticsQuery } from 'src/data/queries/statisticsQuery'
Expand Down
Loading

0 comments on commit 5ca707a

Please sign in to comment.