feat(journals): min in-world date 2156-03-19 and main-ops-only related mission dropdown
- Reject any journal in-world date before March 19, 2156 in the create/update validation (server-side) and add min to the date picker. - Filter the related-mission dropdown to operationType = "main" only.
This commit is contained in:
parent
9dea9d1e36
commit
b1dbf5569c
4 changed files with 18 additions and 0 deletions
|
|
@ -78,6 +78,8 @@ export default async function JournalDetailPage({
|
|||
|
||||
const missionsResult = await payload.find({
|
||||
collection: "missions",
|
||||
// Only main operations are eligible as a journal's related mission.
|
||||
where: { operationType: { equals: "main" } },
|
||||
limit: 200,
|
||||
depth: 0,
|
||||
sort: "-id",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@ import { emitGameEvent } from "@/utils/event-log/emit";
|
|||
import { EventTypes } from "@/utils/event-log/eventTypes";
|
||||
import type { Journal } from "@/payload-types";
|
||||
|
||||
/**
|
||||
* Earliest allowed in-universe date for journal entries (unit founding,
|
||||
* 2156-03-19). Stored as a UTC-midnight epoch so it compares cleanly against
|
||||
* the ISO `occurredAt` the client sends.
|
||||
*/
|
||||
const MIN_OCCURRENCE_DATE = Date.parse("2156-03-19T00:00:00.000Z");
|
||||
|
||||
export interface ActionResult<T = undefined> {
|
||||
success: boolean;
|
||||
error?: string;
|
||||
|
|
@ -45,6 +52,12 @@ function validate(input: JournalInput): string | null {
|
|||
if (!root || !Array.isArray(root.children) || root.children.length === 0) {
|
||||
return "Entry body is required.";
|
||||
}
|
||||
if (input.occurredAt) {
|
||||
const occurred = Date.parse(input.occurredAt);
|
||||
if (!Number.isNaN(occurred) && occurred < MIN_OCCURRENCE_DATE) {
|
||||
return "The in-world date cannot be before March 19, 2156.";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ export default async function JournalsPage() {
|
|||
|
||||
const missionsResult = await payload.find({
|
||||
collection: "missions",
|
||||
// Only main operations are eligible as a journal's related mission.
|
||||
where: { operationType: { equals: "main" } },
|
||||
limit: 200,
|
||||
depth: 0,
|
||||
sort: "-id",
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ export function JournalFormDialog({
|
|||
<Input
|
||||
id="journal-date"
|
||||
type="date"
|
||||
min="2156-03-19"
|
||||
value={occurredAt}
|
||||
onChange={(e) => setOccurredAt(e.target.value)}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue