Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions src/pages/abs/[id]/citations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ItemsSkeleton } from '@/components/ResultList';
import { createAbsGetServerSideProps } from '@/lib/serverside/absCanonicalization';
import { useGetAbstractParams } from '@/lib/useGetAbstractParams';
import { parseAPIError } from '@/utils/common/parseAPIError';
import { RecordNotFound } from '@/components/RecordNotFound';
import { feedbackItems } from '@/components/NavBar';

const CitationsPage: NextPage = () => {
const router = useRouter();
Expand Down Expand Up @@ -36,30 +38,42 @@ const CitationsPage: NextPage = () => {
const isEmpty = isSuccess && !isFetching && (!data?.docs || data.docs.length === 0);
const citationsParams = getCitationsParams(doc?.bibcode, 0, rows);

const handleMissingRecordFeedback = () => {
void router.push({
pathname: feedbackItems.record.path,
});
};

return (
<AbsLayout doc={doc} titleDescription="Papers that cite" label="Citations">
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{hasError && <StandardAlertMessage title={parseAPIError(hasError)} />}
{isEmpty && (
<EmptyStatePanel
title="No citations yet"
description="Papers that cite this work will appear here as they are indexed."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={citationsParams}
/>
{!doc ? (
<RecordNotFound recordId={id || 'N/A'} onFeedback={handleMissingRecordFeedback} />
) : (
<>
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{hasError && <StandardAlertMessage title={parseAPIError(hasError)} />}
{isEmpty && (
<EmptyStatePanel
title="No citations yet"
description="Papers that cite this work will appear here as they are indexed."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={citationsParams}
/>
)}
</>
)}
</AbsLayout>
);
Expand Down
58 changes: 36 additions & 22 deletions src/pages/abs/[id]/coreads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ItemsSkeleton } from '@/components/ResultList';
import { createAbsGetServerSideProps } from '@/lib/serverside/absCanonicalization';
import { useGetAbstractParams } from '@/lib/useGetAbstractParams';
import { parseAPIError } from '@/utils/common/parseAPIError';
import { feedbackItems } from '@/components/NavBar';
import { RecordNotFound } from '@/components/RecordNotFound';

const CoreadsPage: NextPage = () => {
const router = useRouter();
Expand All @@ -29,30 +31,42 @@ const CoreadsPage: NextPage = () => {
const isEmpty = isSuccess && !isFetching && (!data?.docs || data.docs.length === 0);
const coreadsParams = getCoreadsParams(doc?.bibcode, 0, rows);

const handleMissingRecordFeedback = () => {
void router.push({
pathname: feedbackItems.record.path,
});
};

return (
<AbsLayout doc={doc} titleDescription="Papers also read by those who read" label="Coreads">
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{isError && <StandardAlertMessage title={parseAPIError(error)} />}
{isEmpty && (
<EmptyStatePanel
title="No co-reads available"
description="Co-reads show papers frequently read alongside this one. Requires read activity data."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={coreadsParams}
/>
{!doc ? (
<RecordNotFound recordId={id || 'N/A'} onFeedback={handleMissingRecordFeedback} />
) : (
<>
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{isError && <StandardAlertMessage title={parseAPIError(error)} />}
{isEmpty && (
<EmptyStatePanel
title="No co-reads available"
description="Co-reads show papers frequently read alongside this one. Requires read activity data."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={coreadsParams}
/>
)}
</>
)}
</AbsLayout>
);
Expand Down
58 changes: 36 additions & 22 deletions src/pages/abs/[id]/credits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ItemsSkeleton } from '@/components/ResultList';
import { createAbsGetServerSideProps } from '@/lib/serverside/absCanonicalization';
import { useGetAbstractParams } from '@/lib/useGetAbstractParams';
import { parseAPIError } from '@/utils/common/parseAPIError';
import { feedbackItems } from '@/components/NavBar';
import { RecordNotFound } from '@/components/RecordNotFound';

const CreditsPage: NextPage = () => {
const router = useRouter();
Expand Down Expand Up @@ -36,30 +38,42 @@ const CreditsPage: NextPage = () => {
const isEmpty = isSuccess && !isFetching && (!data?.docs || data.docs.length === 0);
const creditsParams = getCreditsParams(doc?.bibcode, 0, rows);

const handleMissingRecordFeedback = () => {
void router.push({
pathname: feedbackItems.record.path,
});
};

return (
<AbsLayout doc={doc} titleDescription="Papers that credited" label="Credits">
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{hasError && <StandardAlertMessage title={parseAPIError(hasError)} />}
{isEmpty && (
<EmptyStatePanel
title="No credits found"
description="Papers that credit this record will appear here."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={creditsParams}
/>
{!doc ? (
<RecordNotFound recordId={id || 'N/A'} onFeedback={handleMissingRecordFeedback} />
) : (
<>
{isLoading || isFetching ? <ItemsSkeleton count={10} /> : null}
{hasError && <StandardAlertMessage title={parseAPIError(hasError)} />}
{isEmpty && (
<EmptyStatePanel
title="No credits found"
description="Papers that credit this record will appear here."
secondaryAction={{
label: 'Back to Abstract',
href: `/abs/${id}/abstract`,
}}
/>
)}
{isSuccess && !isEmpty && (
<AbstractRefList
doc={doc}
docs={data.docs}
totalResults={data.numFound}
onPageChange={onPageChange}
pageSize={rows}
onPageSizeChange={onPageSizeChange}
searchLinkParams={creditsParams}
/>
)}
</>
)}
</AbsLayout>
);
Expand Down
38 changes: 26 additions & 12 deletions src/pages/abs/[id]/exportcitation/[format].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import { useGetAbstract } from '@/api/search/search';
import { IDocsEntity } from '@/api/search/types';
import { useExportFormats } from '@/lib/useExportFormats';
import { createAbsGetServerSideProps } from '@/lib/serverside/absCanonicalization';
import { feedbackItems } from '@/components/NavBar';
import { RecordNotFound } from '@/components/RecordNotFound';

const ExportCitationPage: NextPage = () => {
const router = useRouter();

const { isValidFormat } = useExportFormats();

const { data } = useGetAbstract({ id: router.query.id as string });
const id = router.query.id as string;

const { data } = useGetAbstract({ id });

const doc = path<IDocsEntity>(['docs', 0], data);

Expand Down Expand Up @@ -47,19 +51,29 @@ const ExportCitationPage: NextPage = () => {
maxauthor: parseInt(settings.bibtexMaxAuthors, 10),
};

const handleMissingRecordFeedback = () => {
void router.push({
pathname: feedbackItems.record.path,
});
};

return (
<AbsLayout doc={doc} titleDescription="Export citation for" label="Export Citations">
<Box pt="1">
<CitationExporter
initialFormat={format}
keyformat={keyformat}
journalformat={JournalFormatMap[journalformat]}
maxauthor={maxauthor}
authorcutoff={authorcutoff}
records={doc?.bibcode ? [doc.bibcode] : []}
singleMode
/>
</Box>
{!doc ? (
<RecordNotFound recordId={id || 'N/A'} onFeedback={handleMissingRecordFeedback} />
) : (
<Box pt="1">
<CitationExporter
initialFormat={format}
keyformat={keyformat}
journalformat={JournalFormatMap[journalformat]}
maxauthor={maxauthor}
authorcutoff={authorcutoff}
records={doc?.bibcode ? [doc.bibcode] : []}
singleMode
/>
</Box>
)}
</AbsLayout>
);
};
Expand Down
Loading
Loading