mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 11:14:06 +00:00
Rename resources/scripts-v2 to resources/scripts and drop @v2 alias
Now that the legacy v1 frontend (commit 064bdf53) is gone, the v2 directory is the only frontend and the v2 suffix is just noise. Renames resources/scripts-v2 to resources/scripts via git mv (so git records the move as renames, preserving blame and log --follow), then bulk-rewrites the 152 files that imported via @v2/... to use @/scripts/... instead. The existing @ alias (resources/) covers the new path with no extra config needed.
Drops the now-unused @v2 alias from vite.config.js and points the laravel-vite-plugin entry at resources/scripts/main.ts. Updates the only blade reference (resources/views/app.blade.php) to match. The package.json test script (eslint ./resources/scripts) automatically targets the right place after the rename without any edit.
Verified: npm run build exits clean and the Vite warning lines now reference resources/scripts/plugins/i18n.ts, confirming every import resolved through the new path. git log --follow on any moved file walks back through its scripts-v2 history.
This commit is contained in:
92
resources/scripts/composables/use-date.ts
Normal file
92
resources/scripts/composables/use-date.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import {
|
||||
formatDate as formatDateUtil,
|
||||
relativeTime as relativeTimeUtil,
|
||||
parseDate as parseDateUtil,
|
||||
DEFAULT_DATE_FORMAT,
|
||||
DEFAULT_DATETIME_FORMAT,
|
||||
} from '../utils/format-date'
|
||||
import type { Locale } from 'date-fns'
|
||||
|
||||
export interface UseDateReturn {
|
||||
formatDate: (
|
||||
date: Date | string | number,
|
||||
formatStr?: string,
|
||||
options?: { locale?: Locale }
|
||||
) => string
|
||||
formatDateTime: (
|
||||
date: Date | string | number,
|
||||
options?: { locale?: Locale }
|
||||
) => string
|
||||
relativeTime: (
|
||||
date: Date | string | number,
|
||||
options?: { addSuffix?: boolean; locale?: Locale }
|
||||
) => string
|
||||
parseDate: (date: Date | string | number) => Date | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Composable for date formatting and parsing using date-fns.
|
||||
* Provides convenient wrappers around utility functions for use within Vue components.
|
||||
*/
|
||||
export function useDate(): UseDateReturn {
|
||||
/**
|
||||
* Format a date using a format pattern.
|
||||
*
|
||||
* @param date - A Date object, ISO string, or timestamp
|
||||
* @param formatStr - date-fns format pattern (default: 'yyyy-MM-dd')
|
||||
* @param options - Optional locale
|
||||
* @returns Formatted date string, or empty string if invalid
|
||||
*/
|
||||
function formatDate(
|
||||
date: Date | string | number,
|
||||
formatStr: string = DEFAULT_DATE_FORMAT,
|
||||
options?: { locale?: Locale }
|
||||
): string {
|
||||
return formatDateUtil(date, formatStr, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a date with date and time.
|
||||
*
|
||||
* @param date - A Date object, ISO string, or timestamp
|
||||
* @param options - Optional locale
|
||||
* @returns Formatted datetime string
|
||||
*/
|
||||
function formatDateTime(
|
||||
date: Date | string | number,
|
||||
options?: { locale?: Locale }
|
||||
): string {
|
||||
return formatDateUtil(date, DEFAULT_DATETIME_FORMAT, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human-readable relative time string (e.g. "3 days ago").
|
||||
*
|
||||
* @param date - A Date object, ISO string, or timestamp
|
||||
* @param options - Optional addSuffix and locale settings
|
||||
* @returns Relative time string
|
||||
*/
|
||||
function relativeTime(
|
||||
date: Date | string | number,
|
||||
options?: { addSuffix?: boolean; locale?: Locale }
|
||||
): string {
|
||||
return relativeTimeUtil(date, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a date value into a Date object.
|
||||
*
|
||||
* @param date - A Date object, ISO string, or timestamp
|
||||
* @returns Parsed Date or null
|
||||
*/
|
||||
function parseDate(date: Date | string | number): Date | null {
|
||||
return parseDateUtil(date)
|
||||
}
|
||||
|
||||
return {
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
relativeTime,
|
||||
parseDate,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user