import * as React from "react"; import * as countries from "i18n-iso-countries"; // @ts-ignore countries.registerLocale(require("i18n-iso-countries/langs/fr.json")); import { Authors } from "./Author"; import { Notice, NoticeTypeContext } from "../../Notice"; import { Separator } from "../../common/Separator"; import Italic from "../../common/Italic"; export const renderedGroups = ["OUV", "COUV", "ART", "COMM", "DOUV", "POSTER", "THESE", "HDR"]; export const Title: React.FC<{ title: string; bookTitle?: string; journalTitle?: string; conferenceTitle?: string; }> = ({ title, bookTitle, journalTitle, conferenceTitle }) => { if (title.length === 0) { return <>; } if (bookTitle !== undefined || journalTitle !== undefined || conferenceTitle !== undefined) { return «{title}»; } return {title}; }; export const BookTitleAndScientificEditor: React.FC<{ bookTitle?: string; journalTitle?: string; conferenceTitle?: string; scientificEditor?: string; }> = ({ bookTitle, journalTitle, conferenceTitle, scientificEditor }) => { const { noticeType } = React.useContext(NoticeTypeContext); if ( noticeType === "COUV" || (bookTitle !== undefined && journalTitle === undefined && conferenceTitle === undefined && (noticeType === "DEFAULT" || noticeType === "DOUV")) ) { const ret: JSX.Element[] = []; if (scientificEditor !== undefined) { ret.push( <> in {scientificEditor} (dir.) ); } if (bookTitle !== undefined) { ret.push( <> in {bookTitle} ); } return ( <> {ret.map((val, i) => ( {val} ))} ); } return <>; }; export const JournalTitleAndVolumeAndIssue: React.FC<{ journalTitle?: string; volume?: string; issue?: string; }> = ({ journalTitle, volume, issue }) => { const { noticeType } = React.useContext(NoticeTypeContext); if (noticeType === "ART" || (journalTitle !== undefined && (noticeType === "DEFAULT" || noticeType === "DOUV"))) { return ( <> {journalTitle !== undefined && ( {journalTitle} )} {volume !== undefined && ( vol. {volume} )} {issue !== undefined && ( n°{issue} )} ); } return <>; }; const AuthorityInstitution: React.FC<{ authorityInstitution: string | undefined }> = ({ authorityInstitution }) => { const { noticeType } = React.useContext(NoticeTypeContext); if ((noticeType !== "THESE" && noticeType !== "HDR") || authorityInstitution === undefined) { return <>; } return ( <> {authorityInstitution} ); }; const ConferenceTitle: React.FC<{ journalTitle: string | undefined; scientificEditor: string | undefined; conferenceTitle: string | undefined; }> = ({ journalTitle, scientificEditor, conferenceTitle }) => { const { noticeType } = React.useContext(NoticeTypeContext); if ( noticeType === "COMM" || noticeType === "POSTER" || (noticeType === "DEFAULT" && conferenceTitle !== undefined && journalTitle === undefined) ) { const ret: JSX.Element[] = []; ret.push(in ); if (scientificEditor !== undefined) { ret.push( <> {scientificEditor} (dir.) ); } if (conferenceTitle !== undefined) { ret.push( <> {conferenceTitle} ); } if (ret.length > 1) { return ( <> {ret.map((val, i) => ( {val} ))} ); } } return <>; }; const Location: React.FC<{ journalTitle: string | undefined; publicationLocation: string | undefined; city: string | undefined; country: string | undefined; }> = ({ journalTitle, publicationLocation, city, country }) => { const { noticeType } = React.useContext(NoticeTypeContext); if ((noticeType === "DOUV" && journalTitle === undefined) || noticeType !== "ART") { const ret: JSX.Element[] = []; if (publicationLocation !== undefined) { ret.push( <> {publicationLocation} ); } else if (city !== undefined) { ret.push( <> {city} ); } if (country !== undefined) { ret.push( <> {countries.getName(country, "fr", { select: "official" })} ); } return ( <> {ret.map((val, i) => ( {val} ))} ); } return <>; }; const Page: React.FC<{ year: string | undefined; page: string | undefined; }> = ({ year, page }) => { const { noticeType } = React.useContext(NoticeTypeContext); if (noticeType !== "OUV" && noticeType !== "DEFAULT" && page !== undefined) { return ( <> {year !== undefined ? : <>} {page.indexOf("-") !== -1 ? `p. ${page}` : `${page} p.`} ); } return <>; }; export const EHESSNotice: React.FC = (notice) => { return ( <> <Separator /> <BookTitleAndScientificEditor bookTitle={notice.bookTitle_s} journalTitle={notice.journalTitle_s} conferenceTitle={notice.conferenceTitle_s} scientificEditor={notice.scientificEditor_s} /> <JournalTitleAndVolumeAndIssue journalTitle={notice.journalTitle_s} volume={notice.volume_s} issue={notice.issue_s} /> <AuthorityInstitution authorityInstitution={notice.authorityInstitution_s} /> <ConferenceTitle journalTitle={notice.journalTitle_s} scientificEditor={notice.scientificEditor_s} conferenceTitle={notice.conferenceTitle_s} /> <Location journalTitle={notice.journalTitle_s} publicationLocation={notice.publicationLocation_s} city={notice.city_s} country={notice.country_s} /> {notice.publisher_s !== undefined ? ( <> {notice.publisher_s} <Separator /> </> ) : ( <></> )} {notice.producedDateY_i !== undefined ? <>{notice.producedDateY_i}</> : <></>} <Page year={notice.producedDateY_i} page={notice.page_s} /> </> ); };