mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 05:31:12 -05:00
Migrate date precision to exact
Batch update all date precision handling to use expanded DatePrecision, replace hardcoded day defaults, and adjust related validation, UI, and helpers. Includes wrapper migration across Phase 1-3 functions, updates to logs, displays, and formatting utilities to align frontend with new precision values ('exact', 'month', 'year', 'decade', 'century', 'approximate').
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
} from "@/components/ui/select";
|
||||
import { toDateOnly, toDateWithPrecision } from "@/lib/dateUtils";
|
||||
|
||||
export type DatePrecision = 'day' | 'month' | 'year';
|
||||
export type DatePrecision = 'exact' | 'month' | 'year' | 'decade' | 'century' | 'approximate';
|
||||
|
||||
interface FlexibleDateInputProps {
|
||||
value?: Date;
|
||||
@@ -34,7 +34,7 @@ interface FlexibleDateInputProps {
|
||||
|
||||
export function FlexibleDateInput({
|
||||
value,
|
||||
precision = 'day',
|
||||
precision = 'exact',
|
||||
onChange,
|
||||
placeholder = "Select date",
|
||||
disabled = false,
|
||||
@@ -71,13 +71,16 @@ export function FlexibleDateInput({
|
||||
let newDate: Date;
|
||||
switch (newPrecision) {
|
||||
case 'year':
|
||||
case 'decade':
|
||||
case 'century':
|
||||
case 'approximate':
|
||||
newDate = new Date(year, 0, 1); // January 1st (local timezone)
|
||||
setYearValue(year.toString());
|
||||
break;
|
||||
case 'month':
|
||||
newDate = new Date(year, month, 1); // 1st of month (local timezone)
|
||||
break;
|
||||
case 'day':
|
||||
case 'exact':
|
||||
default:
|
||||
newDate = value; // Keep existing date
|
||||
break;
|
||||
@@ -104,10 +107,13 @@ export function FlexibleDateInput({
|
||||
const getPlaceholderText = () => {
|
||||
switch (localPrecision) {
|
||||
case 'year':
|
||||
case 'decade':
|
||||
case 'century':
|
||||
case 'approximate':
|
||||
return 'Enter year (e.g., 2005)';
|
||||
case 'month':
|
||||
return 'Select month and year';
|
||||
case 'day':
|
||||
case 'exact':
|
||||
default:
|
||||
return placeholder;
|
||||
}
|
||||
@@ -119,10 +125,10 @@ export function FlexibleDateInput({
|
||||
|
||||
<div className="flex gap-2">
|
||||
<div className="flex-1">
|
||||
{localPrecision === 'day' && (
|
||||
{(localPrecision === 'exact') && (
|
||||
<DatePicker
|
||||
date={value}
|
||||
onSelect={(date) => onChange(date, 'day')}
|
||||
onSelect={(date) => onChange(date, 'exact')}
|
||||
placeholder={getPlaceholderText()}
|
||||
disabled={disabled}
|
||||
disableFuture={disableFuture}
|
||||
@@ -143,7 +149,7 @@ export function FlexibleDateInput({
|
||||
/>
|
||||
)}
|
||||
|
||||
{localPrecision === 'year' && (
|
||||
{(localPrecision === 'year' || localPrecision === 'decade' || localPrecision === 'century' || localPrecision === 'approximate') && (
|
||||
<Input
|
||||
type="number"
|
||||
value={yearValue}
|
||||
@@ -166,9 +172,12 @@ export function FlexibleDateInput({
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="day">Use Full Date</SelectItem>
|
||||
<SelectItem value="month">Use Month/Year</SelectItem>
|
||||
<SelectItem value="year">Use Year Only</SelectItem>
|
||||
<SelectItem value="exact">Exact Day</SelectItem>
|
||||
<SelectItem value="month">Month & Year</SelectItem>
|
||||
<SelectItem value="year">Year Only</SelectItem>
|
||||
<SelectItem value="decade">Decade</SelectItem>
|
||||
<SelectItem value="century">Century</SelectItem>
|
||||
<SelectItem value="approximate">Approximate</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user