Add user database migration, core reusable components, and layout structure
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
export function formatDate(iso) {
|
||||
if (!iso) return '—';
|
||||
return new Date(iso).toLocaleDateString('en-US', {
|
||||
year: 'numeric', month: 'short', day: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
export function formatDateTime(iso) {
|
||||
if (!iso) return '—';
|
||||
return new Date(iso).toLocaleString('en-US', {
|
||||
month: 'short', day: 'numeric', year: 'numeric',
|
||||
hour: 'numeric', minute: '2-digit',
|
||||
});
|
||||
}
|
||||
|
||||
export function formatRelative(iso) {
|
||||
if (!iso) return '—';
|
||||
const diff = Date.now() - new Date(iso).getTime();
|
||||
const mins = Math.floor(diff / 60000);
|
||||
if (mins < 1) return 'just now';
|
||||
if (mins < 60) return `${mins}m ago`;
|
||||
const hrs = Math.floor(mins / 60);
|
||||
if (hrs < 24) return `${hrs}h ago`;
|
||||
const days = Math.floor(hrs / 24);
|
||||
if (days < 7) return `${days}d ago`;
|
||||
return formatDate(iso);
|
||||
}
|
||||
|
||||
export function formatPhone(phone) {
|
||||
if (!phone) return '—';
|
||||
const d = phone.replace(/\D/g, '');
|
||||
return d.length === 10
|
||||
? `(${d.slice(0,3)}) ${d.slice(3,6)}-${d.slice(6)}`
|
||||
: phone;
|
||||
}
|
||||
|
||||
export function toLocalDatetime(iso) {
|
||||
if (!iso) return '';
|
||||
return new Date(iso).toISOString().slice(0, 16);
|
||||
}
|
||||
Reference in New Issue
Block a user