fix(app): grant expiry ends the chosen day in Paris; species order 0..9999 (V1-2.5 L2)

Owner checkpoint 2026-11-02: expiry 23:59:59.999 Europe/Paris (picker, validation, display), tests under non-Paris zones and DST days; M7 redefines create_species and update_inactive_species with the range check; pgTAP 015 and 022; « Relecteur ou relectrice »; object_conflict EN; setup key selectable, no Copy.
This commit is contained in:
bchanot committed 2026-11-02 21:29:33 +01:00
1 parent 4111efa1d1
commit 51225cacf6
17 files changed
+437 -61

No files matched your search

+7 -2
View File
@@ -83,12 +83,17 @@ export function personName(
return person?.display_name || t('admin.person.unnamed')
}
/** A server timestamp as a date in the interface language. */
export function formatDay(iso: string, locale: Locale): string {
/** A server timestamp as a date in the interface language (in `timeZone` when given). */
export function formatDay(
iso: string,
locale: Locale,
timeZone?: string,
): string {
return new Date(iso).toLocaleDateString(locale, {
day: 'numeric',
month: 'long',
year: 'numeric',
...(timeZone ? { timeZone } : {}),
})
}
+15 -9
View File
@@ -1,6 +1,6 @@
import { z } from 'zod'
import { codePointLength } from '@faunosteo/supabase'
import { localDateIso } from '@/lib/dates'
import { endOfParisDayIso, parisDateIso } from '@/lib/dates'
/**
* The administration forms (contract §5.2, §7.2, §7.4). Bounds and patterns
@@ -173,11 +173,20 @@ export interface GrantFields {
kind: GrantKind
reason: string
verification_note?: string
/** The end of the chosen day, device time zone. */
/** The end of the chosen day, Europe/Paris (owner 2026-11-02). */
expires_at?: string
}
/** The expiry is a day after today (device date): the server refuses a past one. */
/** YYYY-MM-DD naming a real calendar day (no 2026-02-30). */
function isRealDay(day: string): boolean {
const match = day.match(/^(\d{4})-(\d{2})-(\d{2})$/)
if (!match) return false
const [y, mo, d] = [Number(match[1]), Number(match[2]), Number(match[3])]
const date = new Date(Date.UTC(y, mo - 1, d))
return date.getUTCMonth() === mo - 1 && date.getUTCDate() === d
}
/** The expiry is a real day after today (Paris date): the server refuses a past one. */
function grantSchema(today: string) {
return z
.object({
@@ -195,8 +204,7 @@ function grantSchema(today: string) {
expires_on: z
.string()
.refine(
(day) =>
day === '' || (/^\d{4}-\d{2}-\d{2}$/.test(day) && day > today),
(day) => day === '' || (isRealDay(day) && day > today),
'admin.access.error.expiry',
),
})
@@ -228,9 +236,7 @@ function grantSchema(today: string) {
: {}),
...(values.expires_on
? {
expires_at: new Date(
`${values.expires_on}T23:59:59`,
).toISOString(),
expires_at: endOfParisDayIso(values.expires_on),
}
: {}),
}),
@@ -239,7 +245,7 @@ function grantSchema(today: string) {
export function parseGrant(
values: GrantFormValues,
today: string = localDateIso(),
today: string = parisDateIso(),
): Parsed<GrantFields, keyof GrantFormValues> {
return parse(grantSchema(today), values)
}