diff --git a/src/app/(payload)/admin/importMap.js b/src/app/(payload)/admin/importMap.js index 863ba62..de71ba6 100644 --- a/src/app/(payload)/admin/importMap.js +++ b/src/app/(payload)/admin/importMap.js @@ -21,8 +21,8 @@ import { StrikethroughFeatureClient as StrikethroughFeatureClient_e70f5e05f09f93 import { UnderlineFeatureClient as UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client' import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client' import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client' -import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage' import { default as default_0edde40a6ccd30c893b1227360f69360 } from '@/components/static/TickDurationDescription' +import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage' import { default as default_2f6c866ab4d4d51b3789f090b84b85c7 } from '@/components/static/VersionOverlay' import { default as default_508743824696caae2894ebf34c2e68bb } from '@/components/graphics/AppIcon' import { default as default_e752fee78378294ff03f91dba0a75a04 } from '@/components/graphics/AppLogo' @@ -52,8 +52,8 @@ export const importMap = { "@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, "@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - "@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825, "@/components/static/TickDurationDescription#default": default_0edde40a6ccd30c893b1227360f69360, + "@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825, "@/components/static/VersionOverlay#default": default_2f6c866ab4d4d51b3789f090b84b85c7, "@/components/graphics/AppIcon#default": default_508743824696caae2894ebf34c2e68bb, "@/components/graphics/AppLogo#default": default_e752fee78378294ff03f91dba0a75a04, diff --git a/src/collections/intelligence/Missions.ts b/src/collections/intelligence/Missions.ts index fe7af24..b8d09d4 100644 --- a/src/collections/intelligence/Missions.ts +++ b/src/collections/intelligence/Missions.ts @@ -141,7 +141,6 @@ export const Missions: CollectionConfig = { label: "Estimated Duration (in minutes)", defaultValue: 60 * 4, // Usually about 4 hours required: true, - }, ], }, diff --git a/src/collections/intelligence/Technologies.ts b/src/collections/intelligence/Technologies.ts index d8177c7..4d9d22e 100644 --- a/src/collections/intelligence/Technologies.ts +++ b/src/collections/intelligence/Technologies.ts @@ -128,9 +128,17 @@ export const Technologies: CollectionConfig = { name: "minimumResearchDuration", type: "number", admin: { - description: - "The minimum amount of time in minutes that it takes to research this technology. If no maximum duration is provided, this technology will be researched in an amount of time exactly equal to this number.", + components: { + Description: { + path: "@/components/static/TickDurationDescription", + clientProps: { + task: "research this technology", + }, + }, + }, }, + min: 1, + max: 10000, required: true, defaultValue: 0, }, @@ -138,9 +146,25 @@ export const Technologies: CollectionConfig = { name: "maximumResearchDuration", type: "number", admin: { - description: - "The maximum amount of time in minutes that it takes to research this technology.", + components: { + Description: { + path: "@/components/static/TickDurationDescription", + clientProps: { + task: "research this technology", + field: "maximumResearchDuration", + }, + }, + }, }, + min: 1, + max: 10000, + /*validate: (value: number, { data, siblingData }: { data: any; siblingData: any }) => { + const minDuration = siblingData?.minimumResearchDuration; + if (value !== undefined && minDuration !== undefined && value < minDuration) { + return `Maximum research duration must be at least ${minDuration} (the minimum research duration)`; + } + return true; + },*/ }, ], }, diff --git a/src/collections/logistics/Assets.ts b/src/collections/logistics/Assets.ts index c22734e..5d2f9fd 100644 --- a/src/collections/logistics/Assets.ts +++ b/src/collections/logistics/Assets.ts @@ -412,9 +412,20 @@ export const Assets: CollectionConfig = { { name: "craftingTimePerUnit", type: "number", - label: "Crafting Time per Unit (minutes)", - required: true, + label: "Crafting Time per Unit", defaultValue: 1, + min: 1, + required: true, + admin: { + components: { + Description: { + path: "@/components/static/TickDurationDescription", + clientProps: { + task: "complete production of one unit of this asset", + }, + }, + }, + }, }, { name: "byproducts", diff --git a/src/components/static/TickDurationDescription.tsx b/src/components/static/TickDurationDescription.tsx index 17def07..2e14f71 100644 --- a/src/components/static/TickDurationDescription.tsx +++ b/src/components/static/TickDurationDescription.tsx @@ -1,6 +1,6 @@ "use client"; -import { useFormFields } from "@payloadcms/ui"; +import { useField, useFormFields } from "@payloadcms/ui"; const calculateTicks = (value: number) => { const totalMinutes = value * 10; @@ -11,18 +11,16 @@ const calculateTicks = (value: number) => { }; export const TickDurationDescription = ({ task }: { task: string }) => { - const ticks = useFormFields(([fields, dispatch]) => fields.constructionTime); + const { value, setValue } = useField(); - return ticks && typeof ticks?.value === "number" ? ( + return value && typeof value === "number" ? (

The number of ticks (10 minutes *{" "} - {ticks.value} ={" "} - {calculateTicks(ticks.value)}) it takes to {task}. + {value} ={" "} + {calculateTicks(value)}) it takes to {task}.

) : ( -

- The number of ticks it takes to {task}. -

+

The number of ticks it takes to {task}.

); }; diff --git a/src/payload-types.ts b/src/payload-types.ts index 8805f2b..ecde44a 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -561,13 +561,7 @@ export interface Technology { id?: string | null; }[] | null; - /** - * The minimum amount of time in minutes that it takes to research this technology. If no maximum duration is provided, this technology will be researched in an amount of time exactly equal to this number. - */ minimumResearchDuration: number; - /** - * The maximum amount of time in minutes that it takes to research this technology. - */ maximumResearchDuration?: number | null; }; updatedAt: string;