import * as React from "react";
import * as countries from "i18n-iso-countries";
// @ts-ignore
countries.registerLocale(require("i18n-iso-countries/langs/fr.json"));
import { AuthorsMLA } from "./Author";
import { Notice, NoticeTypeContext } from "../../Notice";
export const renderedGroups = ["OUV", "COUV", "ART", "COMM", "DOUV"];
export const Title: React.FC<{
title: string;
subTitle?: string;
}> = ({ title, subTitle }) => {
const { noticeType } = React.useContext(NoticeTypeContext);
if (title.length === 0) {
return <>>;
}
if (noticeType === "DOUV") {
return {title}.;
} else if (noticeType === "OUV") {
return (
{title}
{subTitle !== undefined && <> : {subTitle}>}.
);
}
return "{title}";
};
const TitleAndAuthor: React.FC<{
title: string;
authLastName_s: string[];
authFirstName_s: string[];
subTitle?: string;
}> = ({ title, subTitle, authLastName_s, authFirstName_s }) => {
const { noticeType } = React.useContext(NoticeTypeContext);
if (noticeType === "DOUV") {
return (
<>
{" "}
{" "}
>
);
}
return (
<>
{" "}
{" "}
>
);
};
const BookTitle: React.FC<{
bookTitle: string | undefined;
}> = ({ bookTitle }) => {
const { noticeType } = React.useContext(NoticeTypeContext);
if (noticeType === "COUV" && bookTitle !== undefined) {
return <>{bookTitle}.>;
}
return <>>;
};
const ScientificEditor: React.FC<{
scientificEditor: string | undefined;
}> = ({ scientificEditor }) => {
const { noticeType } = React.useContext(NoticeTypeContext);
if ((noticeType === "COUV" || noticeType === "DOUV") && scientificEditor !== undefined) {
return <>{scientificEditor}.>;
}
return <>>;
};
const PublicationLocationAndPublisher: React.FC<{
publicationLocation: string | undefined;
publisher: string | undefined;
}> = ({ publicationLocation, publisher }) => {
if (publicationLocation !== undefined && publisher !== undefined) {
return (
<>
{publicationLocation} : {publisher}
>
);
}
if (publicationLocation !== undefined) {
return <>{publicationLocation}>;
}
if (publisher) {
return <>{publisher}>;
}
return <>>;
};
const ProducedDate: React.FC<{
producedDate: string | undefined;
}> = ({ producedDate }) => {
if (producedDate !== undefined) {
return <>, {producedDate}>;
}
return <>>;
};
// TODO : regroup Page and InPress component to put the point at the end
const Page: React.FC<{ page: string | undefined }> = ({ page }) => {
const { noticeType } = React.useContext(NoticeTypeContext);
if (page !== undefined && noticeType === "COUV") {
return <>{page}.>;
}
return <>>;
};
const InPress: React.FC<{ inPress: boolean | undefined }> = ({ inPress }) => {
if (inPress !== undefined && inPress) {
return <>, Imprimé.>;
}
return <>>;
};
const isOUVorDOUVorCOUV = (noticeType: string): boolean =>
noticeType === "OUV" || noticeType === "DOUV" || noticeType === "COUV";
export const MLANotice: React.FC = (notice) => {
const { noticeType } = React.useContext(NoticeTypeContext);
return (
<>
{isOUVorDOUVorCOUV(noticeType) && (
<>
>
)}
>
);
};