feat: implement permissions and actions management
- Add permissions logic for status options in corrective actions. - Create tests for permissions functionality. - Implement queries for user authentication and actions management. - Develop Actions page to display and manage corrective actions. - Create authentication pages for login, setup, and password reset. - Add IncidentDetail page to view incident details and associated actions. - Implement Settings page for user management and password changes.
This commit is contained in:
1 parent
708da6b9f7
commit
3f6dff5f24
94 files changed
+7213
-643
No files matched your search
+25
-8
@@ -1,24 +1,41 @@
|
||||
const displayDate = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })
|
||||
const dateFormat = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric' })
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: '2-digit' })
|
||||
const dayFormat = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })
|
||||
const longDate = new Intl.DateTimeFormat('en-US', { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' })
|
||||
const weekLabel = new Intl.DateTimeFormat('en-US', { month: 'short', day: '2-digit', timeZone: 'UTC' })
|
||||
|
||||
/** Formats an ISO calendar date (`2024-08-28`) as `Aug 28, 2024`. */
|
||||
export function formatDate(isoDate: string): string {
|
||||
return displayDate.format(new Date(`${isoDate}T00:00:00Z`))
|
||||
}
|
||||
/** `2026-10-06T14:00:00Z` → `Oct 6, 2026` in the viewer's time zone. */
|
||||
export const formatDate = (iso: string) => dateFormat.format(new Date(iso))
|
||||
|
||||
export const formatDateTime = (iso: string) => dateTimeFormat.format(new Date(iso))
|
||||
|
||||
/** Calendar date without a time (`2026-10-06`) → `Oct 6, 2026`, never shifted by time zone. */
|
||||
export const formatDay = (isoDate: string) => dayFormat.format(new Date(`${isoDate}T00:00:00Z`))
|
||||
|
||||
export const formatWeek = (isoDate: string) => weekLabel.format(new Date(`${isoDate}T00:00:00Z`))
|
||||
|
||||
/** Today's date in the viewer's local time zone as an ISO calendar date. */
|
||||
export function toIsoDate(date: Date): string {
|
||||
const pad = (value: number) => String(value).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
||||
}
|
||||
|
||||
export function formatLongDate(date: Date): string {
|
||||
return longDate.format(date)
|
||||
/** Value for an `<input type="datetime-local">` in local time. */
|
||||
export function toDateTimeLocal(date: Date): string {
|
||||
const pad = (value: number) => String(value).padStart(2, '0')
|
||||
return `${toIsoDate(date)}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
}
|
||||
|
||||
export const formatLongDate = (date: Date) => longDate.format(date)
|
||||
|
||||
export function greeting(date: Date): string {
|
||||
const hour = date.getHours()
|
||||
if (hour < 12) return 'Good morning'
|
||||
if (hour < 18) return 'Good afternoon'
|
||||
return 'Good evening'
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`
|
||||
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`
|
||||
return `${(bytes / 1024 / 1024).toFixed(1)} MB`
|
||||
}
|
||||
Reference in new issue
Block a user