diff --git a/src/app/components/Editor.tsx b/src/app/components/Editor.tsx index ba7d354..812448e 100644 --- a/src/app/components/Editor.tsx +++ b/src/app/components/Editor.tsx @@ -28,6 +28,7 @@ import EditorDate from "./EditorDate"; import YAML from "yaml"; import { Col, Container, Row } from "design-react-kit"; import EditorContacts from "./EditorContacts"; +import EditorContractors from "./EditorContractors"; const resolver: Resolver = async (values) => { const res = await validator(JSON.stringify(values), "main"); @@ -203,6 +204,7 @@ export default function Editor() { required /> +
diff --git a/src/app/components/EditorContacts.tsx b/src/app/components/EditorContacts.tsx index 5e58131..99a73c9 100644 --- a/src/app/components/EditorContacts.tsx +++ b/src/app/components/EditorContacts.tsx @@ -35,7 +35,7 @@ export default function EditorContacts(): JSX.Element { # - {t(`publiccodeyml.${fieldName}.name.label`)} + {t(`publiccodeyml.${fieldName}.name.label`)} * {t(`publiccodeyml.${fieldName}.email.label`)} diff --git a/src/app/components/EditorContractors.tsx b/src/app/components/EditorContractors.tsx new file mode 100644 index 0000000..a7907df --- /dev/null +++ b/src/app/components/EditorContractors.tsx @@ -0,0 +1,100 @@ +import { Button, Icon, Input, Table } from "design-react-kit"; +import { get } from "lodash"; +import { useController, useFieldArray, useFormContext } from "react-hook-form"; +import { useTranslation } from "react-i18next"; + +import PublicCode from "../contents/publiccode"; + +const fieldName = "maintenance.contractors"; +const subfields = ["name", "until", "email", "website"] as const; + +export default function EditorContractors(): JSX.Element { + const { control, register } = useFormContext(); + const { append, fields, remove } = useFieldArray< + PublicCode, + typeof fieldName + >({ + control, + name: fieldName, + }); + const { + field, + formState: { errors }, + } = useController({ + control, + name: fieldName, + }); + const { t } = useTranslation(); + + return ( +
+ {t(`publiccodeyml.${fieldName}.label`)} + {field.value?.length === 0 ? null : ( + + + + + + + + + + + + + {fields.map(({ id }, index) => ( + + + {subfields.map((subfield) => { + const { ref, ...reg } = register( + `${fieldName}.${index}.${subfield}` + ); + + return ( + + ); + })} + + + ))} + +
# + {t(`publiccodeyml.${fieldName}.name.label`)} * + + {t(`publiccodeyml.${fieldName}.until.label`)} * + + {t(`publiccodeyml.${fieldName}.email.label`)} + {t(`publiccodeyml.${fieldName}.website.label`)}
{index + 1} + + + +
+ )} + +
+ ); +} diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index f6d6b1c..260806a 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -230,8 +230,12 @@ "label": "Until", "description": "The date the maintenance is going to end. In case of community maintenance, the value should not be more than 2 years in the future, and thus will need to be regularly updated as the community continues working on the project." }, + "email": { + "description": "The e-mail address of the technical contact. It must be an email address of where the technical contact can be directly reached; do NOT populate it with mailing-lists or generic contact points like info@acme.inc. ", + "label": "Email" + }, "website": { - "label": "website", + "label": "Website", "description": "The maintainer website. It can either point to the main institutional website, or to a more project-specific page or website." } } diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 5d2dacf..cc6bbd8 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -227,8 +227,12 @@ "label": "Until", "description": "The date the maintenance is going to end. In case of community maintenance, the value should not be more than 2 years in the future, and thus will need to be regularly updated as the community continues working on the project." }, + "email": { + "description": "The e-mail address of the technical contact. It must be an email address of where the technical contact can be directly reached; do NOT populate it with mailing-lists or generic contact points like info@acme.inc. ", + "label": "Email" + }, "website": { - "label": "website", + "label": "Website", "description": "The maintainer website. It can either point to the main institutional website, or to a more project-specific page or website." } } diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index 5f62d88..2fecbe9 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -230,6 +230,10 @@ "label": "Email", "description": "L’indirizzo email del contatto tecnico. Deve essere un indirizzo email per il contatto diretto con il tecnico; NON compilare questo campo con mailing-list o punti di contatto generico tipo “info@acme.inc”." }, + "email": { + "description": "L’indirizzo email del contatto tecnico. NON compilare questo campo con mailing-list o punti di contatto generico tipo “info@acme.inc”.", + "label": "Email" + }, "website": { "label": "Website", "description": "L’indirizzo del sito del maintainer. Può puntare al principale sito istituzionale, o ad una pagina o sito più specifica."