diff --git a/src/write-review/add-authors-page/add-authors-form.ts b/src/write-review/add-authors-page/add-authors-form.ts index 1bcb7160d..7f9322047 100644 --- a/src/write-review/add-authors-page/add-authors-form.ts +++ b/src/write-review/add-authors-page/add-authors-form.ts @@ -5,6 +5,7 @@ import { Status } from 'hyper-ts' import { match } from 'ts-pattern' import { type MissingE, hasAnError } from '../../form.js' import { html, plainText, rawHtml } from '../../html.js' +import type { SupportedLocale } from '../../locales/index.js' import type { PreprintTitle } from '../../preprint.js' import { StreamlinePageResponse } from '../../response.js' import { @@ -29,6 +30,7 @@ export function addAuthorsForm({ authors: ReadonlyNonEmptyArray<{ name: NonEmptyString; emailAddress: EmailAddress }> form: AddAuthorsForm preprint: PreprintTitle + locale: SupportedLocale }) { const error = hasAnError(form) diff --git a/src/write-review/add-authors-page/index.ts b/src/write-review/add-authors-page/index.ts index c2aab15c4..910e9a2ef 100644 --- a/src/write-review/add-authors-page/index.ts +++ b/src/write-review/add-authors-page/index.ts @@ -10,6 +10,7 @@ import { get } from 'spectacles-ts' import { match } from 'ts-pattern' import { missingE } from '../../form.js' import { havingProblemsPage, pageNotFound } from '../../http-error.js' +import { DefaultLocale, type SupportedLocale } from '../../locales/index.js' import { type GetPreprintTitleEnv, type PreprintTitle, getPreprintTitle } from '../../preprint.js' import { type LogInResponse, type PageResponse, RedirectResponse, type StreamlinePageResponse } from '../../response.js' import { writeReviewAddAuthorMatch, writeReviewMatch } from '../../routes.js' @@ -46,6 +47,7 @@ export const writeReviewAddAuthors = ({ pipe( RTE.Do, RTE.apS('user', pipe(RTE.fromNullable('no-session' as const)(user))), + RTE.apS('locale', RTE.of(DefaultLocale)), RTE.let('preprint', () => preprint), RTE.let('method', () => method), RTE.let('body', () => body), @@ -76,6 +78,7 @@ export const writeReviewAddAuthors = ({ ...state, authors: state.authors.value, form: { anotherAuthor: E.right(undefined) }, + locale: state.locale, }), ) .otherwise(() => pageNotFound), @@ -89,11 +92,13 @@ const handleAddAuthorsForm = ({ body, form, preprint, + locale, }: { authors: O.Some[number]>> body: unknown form: Form preprint: PreprintTitle + locale: SupportedLocale }) => pipe( E.Do, @@ -106,7 +111,7 @@ const handleAddAuthorsForm = ({ ), ), E.matchW( - error => addAuthorsForm({ authors: authors.value, form: error, preprint }), + error => addAuthorsForm({ authors: authors.value, form: error, preprint, locale }), state => match(state) .with({ anotherAuthor: 'yes' }, () => diff --git a/visual-regression/write-review/write-review-add-authors.spec.ts b/visual-regression/write-review/write-review-add-authors.spec.ts index 896ba7423..0c495e853 100644 --- a/visual-regression/write-review/write-review-add-authors.spec.ts +++ b/visual-regression/write-review/write-review-add-authors.spec.ts @@ -2,6 +2,7 @@ import { Doi } from 'doi-ts' import * as E from 'fp-ts/lib/Either.js' import { missingE } from '../../src/form.js' import { html } from '../../src/html.js' +import { DefaultLocale } from '../../src/locales/index.js' import type { PreprintTitle } from '../../src/preprint.js' import type { EmailAddress } from '../../src/types/email-address.js' import type { NonEmptyString } from '../../src/types/string.js' @@ -17,6 +18,8 @@ const preprint = { language: 'en', } satisfies PreprintTitle +const locale = DefaultLocale + test('content looks right when there is another author', async ({ showPage }) => { const response = addAuthorsForm({ authors: [{ name: 'Josiah Carberry' as NonEmptyString, emailAddress: 'jcarberry@example.com' as EmailAddress }], @@ -24,6 +27,7 @@ test('content looks right when there is another author', async ({ showPage }) => anotherAuthor: E.right(undefined), }, preprint, + locale, }) const content = await showPage(response) @@ -43,6 +47,7 @@ test('content looks right when there are other authors', async ({ showPage }) => anotherAuthor: E.right(undefined), }, preprint, + locale, }) const content = await showPage(response) @@ -57,6 +62,7 @@ test('content looks right when fields are missing', async ({ showPage }) => { anotherAuthor: E.left(missingE()), }, preprint, + locale, }) const content = await showPage(response)