Skip to content

Commit

Permalink
Post migration cleanup (#361)
Browse files Browse the repository at this point in the history
* Removed excess code leftover from migration

* Fixed build errors

* Removed old layout components
  • Loading branch information
bklaing2 authored May 29, 2024
1 parent 5b00d35 commit d48793d
Show file tree
Hide file tree
Showing 41 changed files with 350 additions and 1,678 deletions.
6 changes: 3 additions & 3 deletions src/app/api/download-reports/doi/related-works/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NextRequest } from 'next/server'
import { gql } from '@apollo/client';
import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { stringify } from 'csv-stringify/sync'
import { Work } from 'src/data/types';
import { QueryData } from 'src/data/queries/doiQuery'
Expand Down Expand Up @@ -159,7 +159,7 @@ export async function GET(request: NextRequest) {
{ key: 'connectionType', header: 'Connection Type' }
]
})

try {
return new Response(csv, {
status: 200,
Expand All @@ -171,4 +171,4 @@ export async function GET(request: NextRequest) {
} catch (error) {
return new Response(JSON.stringify({ error }), { status: 400 })
}
}
}
8 changes: 4 additions & 4 deletions src/app/api/download-reports/ror/funders/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NextRequest } from 'next/server'
import { gql } from '@apollo/client';
import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { stringify } from 'csv-stringify/sync'

const QUERY = gql`
Expand Down Expand Up @@ -53,11 +53,11 @@ export async function GET(request: NextRequest) {
query: QUERY,
variables: variables
})


const csv = stringify(data.organization.works.funders, {
header: true,
columns: [ { key: 'id', header: 'Funder ID' }, { key: 'title', header: 'Title' }, { key: 'count', header: 'Work Count' } ]
columns: [{ key: 'id', header: 'Funder ID' }, { key: 'title', header: 'Title' }, { key: 'count', header: 'Work Count' }]
})


Expand Down
6 changes: 3 additions & 3 deletions src/app/api/download-reports/ror/related-works/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NextRequest } from 'next/server'
import { gql } from '@apollo/client';
import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { stringify } from 'csv-stringify/sync'

const QUERY = gql`
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function GET(request: NextRequest) {
// { key: '???', header: 'Connection Type(s)' }
]
})

try {
return new Response(csv, {
status: 200,
Expand All @@ -95,4 +95,4 @@ export async function GET(request: NextRequest) {
} catch (error) {
return new Response(JSON.stringify({ error }), { status: 400 })
}
}
}
14 changes: 7 additions & 7 deletions src/app/doi.org/[...doi]/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import ReactHtmlParser from 'react-html-parser'
import { Row, Col } from "src/components/Layout";

import apolloClient from 'src/utils/server/apolloClient'
import { Work as WorkType } from 'src/data/types'
import apolloClient from 'src/utils/apolloClient'
import { Work as WorkType } from 'src/data/types'
import { DOI_QUERY, QueryVar, QueryData } from 'src/data/queries/doiQuery'

import Error from 'src/components/Error/Error'
Expand All @@ -21,7 +21,7 @@ interface Props {
isBot?: boolean
}

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

const { data, error } = await apolloClient.query<QueryData, QueryVar>({
Expand Down Expand Up @@ -50,13 +50,13 @@ export default async function Content (props: Props) {
<Row>
<Col md={3} id="side-bar">
<div className='left-menu-buttons'>
{ work.registrationAgency.id == "datacite" && (
{work.registrationAgency.id == "datacite" && (
<Claim doi_id={work.doi} />
)}
<DownloadMetadata doi={work} />
</div>
<CiteAs doi={work} />
{ !isBot && <DownloadReports
{!isBot && <DownloadReports
links={[
{
title: 'Related Works (CSV)',
Expand All @@ -65,7 +65,7 @@ export default async function Content (props: Props) {
}
]}
variables={variables as any}
/> }
/>}
<ShareLinks url={'doi.org/' + work.doi} title={title} />
</Col>
<Col md={9} id="content">
Expand All @@ -74,4 +74,4 @@ export default async function Content (props: Props) {
</Row>
</>
)
}
}
14 changes: 7 additions & 7 deletions src/app/doi.org/[...doi]/RelatedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RELATED_CONTENT_QUERY, QueryVar, QueryData } from 'src/data/queries/doi
import { Works } from 'src/data/types'

import Error from 'src/components/Error/Error'
import WorksListing from 'src/components/WorksListing/Server'
import WorksListing from 'src/components/WorksListing/WorksListing'

interface Props {
variables: QueryVar
Expand All @@ -18,7 +18,7 @@ interface Props {
isBot?: boolean
}

export default function RelatedContent (props: Props) {
export default function RelatedContent(props: Props) {
const { variables, showSankey, connectionType, isBot = false } = props

const { loading, data, error } = useQuery<QueryData, QueryVar>(
Expand Down Expand Up @@ -65,9 +65,9 @@ export default function RelatedContent (props: Props) {

const defaultConnectionType =
referenceCount > 0 ? 'references' :
citationCount > 0 ? 'citations' :
partCount > 0 ? 'parts' :
partOfCount > 0 ? 'partOf' : 'otherRelated'
citationCount > 0 ? 'citations' :
partCount > 0 ? 'parts' :
partOfCount > 0 ? 'partOf' : 'otherRelated'

const displayedConnectionType = connectionType ? connectionType : defaultConnectionType

Expand All @@ -78,7 +78,7 @@ export default function RelatedContent (props: Props) {

const hasNextPage = works.pageInfo ? works.pageInfo.hasNextPage : false
const endCursor = works.pageInfo ? works.pageInfo.endCursor : ''

return (
<>
<Row>
Expand Down Expand Up @@ -110,4 +110,4 @@ export default function RelatedContent (props: Props) {
</Row>
</>
)
}
}
16 changes: 8 additions & 8 deletions src/app/doi.org/[...doi]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import truncate from 'lodash/truncate'

import { rorFromUrl, isProject, isDMP } from 'src/utils/helpers'

import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { CROSSREF_FUNDER_GQL } from 'src/data/queries/crossrefFunderQuery'
import Content from './Content'
import { DOI_METADATA_QUERY, MetadataQueryData, MetadataQueryVar } from 'src/data/queries/doiQuery'
Expand Down Expand Up @@ -37,7 +37,7 @@ interface Props {

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const doi = params.doi.join('/')

const { data } = await apolloClient.query<MetadataQueryData, MetadataQueryVar>({
query: DOI_METADATA_QUERY,
variables: { id: doi },
Expand Down Expand Up @@ -73,9 +73,9 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
const description = !data.work.descriptions[0]
? undefined
: truncate(data.work.descriptions[0].description, {
length: 2500,
separator: '… '
})
length: 2500,
separator: '… '
})

// TODO: Refer here for type https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function:~:text=image.png%22%20/%3E-,Good%20to%20know,-%3A
// https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function:~:text=image.png%22%20/%3E-,Good%20to%20know,-%3A
Expand All @@ -85,7 +85,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {


// <script type="application/ld+json">{work.schemaOrg}</script>


return {
title: title,
Expand All @@ -101,7 +101,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
}

function mapSearchparams (searchParams: Props['searchParams']) {
function mapSearchparams(searchParams: Props['searchParams']) {
return {
filterQuery: searchParams.filterQuery,
cursor: searchParams.cursor,
Expand Down Expand Up @@ -130,7 +130,7 @@ export default async function Page({ params, searchParams }: Props) {
variables: { crossrefFunderId: doi },
errorPolicy: 'all'
})

if (!data) notFound()
redirect(`/ror.org${rorFromUrl(data.organization.id)}?filterQuery=${vars.filterQuery}`)
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/grid.ac/[...grid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { notFound, redirect } from "next/navigation"
import { GRID_GQL, QueryData, QueryVar } from "src/data/queries/gridQuery"
import apolloClient from "src/utils/server/apolloClient"
import apolloClient from "src/utils/apolloClient"
import { rorFromUrl } from "src/utils/helpers"

interface Props {
Expand All @@ -16,7 +16,7 @@ export default async function GridPage({ params }: Props) {
variables: { gridId },
errorPolicy: 'all'
})

if (!data) notFound()
redirect(`/ror.org${rorFromUrl(data.organization.id)}`)
}
}
6 changes: 3 additions & 3 deletions src/app/orcid.org/[orcid]/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Row, Col } from "src/components/Layout";

import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { PERSON_QUERY, QueryVar, QueryData } from 'src/data/queries/personQuery'

import Error from 'src/components/Error/Error'
Expand All @@ -14,7 +14,7 @@ interface Props {
isBot?: boolean
}

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

const { data, error } = await apolloClient.query<QueryData, QueryVar>({
Expand Down Expand Up @@ -48,4 +48,4 @@ export default async function Content (props: Props) {
</Row>
</>
)
}
}
6 changes: 3 additions & 3 deletions src/app/orcid.org/[orcid]/RelatedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Loading from 'src/components/Loading/Loading'
import { RELATED_CONTENT_QUERY, QueryVar, QueryData } from 'src/data/queries/personQuery'

import Error from 'src/components/Error/Error'
import WorksListing from 'src/components/WorksListing/Server'
import WorksListing from 'src/components/WorksListing/WorksListing'
import { pluralize } from 'src/utils/helpers';

interface Props {
Expand All @@ -17,7 +17,7 @@ interface Props {
isBot?: boolean
}

export default function RelatedContent (props: Props) {
export default function RelatedContent(props: Props) {
const { orcid, variables, isBot = false } = props

const { loading, data, error } = useQuery<QueryData, QueryVar>(
Expand Down Expand Up @@ -80,4 +80,4 @@ export default function RelatedContent (props: Props) {
</Row>
</>
)
}
}
8 changes: 4 additions & 4 deletions src/app/orcid.org/[orcid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import truncate from 'lodash/truncate'

import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import Content from './Content'
import { PERSON_METADATA_QUERY, MetadataQueryData, MetadataQueryVar } from 'src/data/queries/personQuery'
import RelatedContent from './RelatedContent'
Expand Down Expand Up @@ -32,7 +32,7 @@ interface Props {

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const orcid = 'http://orcid.org/' + params.orcid

const { data } = await apolloClient.query<MetadataQueryData, MetadataQueryVar>({
query: PERSON_METADATA_QUERY,
variables: { id: orcid },
Expand Down Expand Up @@ -79,7 +79,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {


// <script type="application/ld+json">{work.schemaOrg}</script>


return {
title: title,
Expand All @@ -95,7 +95,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
}

function mapSearchparams (searchParams: Props['searchParams']) {
function mapSearchparams(searchParams: Props['searchParams']) {
return {
filterQuery: searchParams.filterQuery,
cursor: searchParams.cursor,
Expand Down
8 changes: 4 additions & 4 deletions src/app/repositories/[...repoid]/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Row, Col } from "src/components/Layout";

import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import { Repository as RepositoryType } from 'src/data/types'
import { REPOSITORY_QUERY, QueryData, QueryVar } from 'src/data/queries/repositoryQuery';

Expand All @@ -13,7 +13,7 @@ interface Props {
isBot?: boolean
}

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

const { data, error } = await apolloClient.query<QueryData, QueryVar>({
Expand All @@ -34,11 +34,11 @@ export default async function Content (props: Props) {
return (
<Row>
<Col md={3}>
<RepositorySidebar repo={repository}/>
<RepositorySidebar repo={repository} />
</Col>
<Col md={9}>
<RepositoryDetail repo={repository} />
</Col>
</Row>
)
}
}
8 changes: 4 additions & 4 deletions src/app/repositories/[...repoid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Suspense } from 'react'
import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import apolloClient from 'src/utils/server/apolloClient'
import apolloClient from 'src/utils/apolloClient'
import Content from './Content'
import Loading from 'src/components/Loading/Loading'
import { MetadataQueryData, MetadataQueryVar, REPOSITORY_METADATA_QUERY } from 'src/data/queries/repositoryQuery'
Expand All @@ -17,7 +17,7 @@ interface Props {

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const repoid = params.repoid.join('/')

const { data } = await apolloClient.query<MetadataQueryData, MetadataQueryVar>({
query: REPOSITORY_METADATA_QUERY,
variables: { id: repoid },
Expand All @@ -43,8 +43,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {

const baseUrl =
process.env.NEXT_PUBLIC_API_URL === 'https://api.datacite.org'
? 'https://commons.datacite.org/'
: 'https://commons.stage.datacite.org/'
? 'https://commons.datacite.org/'
: 'https://commons.stage.datacite.org/'

const pageUrl = repo.re3dataDoi
? baseUrl + "repositories/" + repo.re3dataDoi
Expand Down
Loading

0 comments on commit d48793d

Please sign in to comment.