initial commit

This commit is contained in:
Sone
2026-05-19 18:46:16 +02:00
parent a92d70ca74
commit 7e67fa8ea0
33 changed files with 6316 additions and 3952 deletions
+20 -5
View File
@@ -1,22 +1,33 @@
import { format, isSameWeek } from "date-fns";
/** Formats a date input to a time string in "HH:mm" format. Returns an empty string if input is null or undefined. */
export const formatTime = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
return format(date, "HH:mm");
};
/** Formats a date input to a time string in "HH:mm:ss" format. Returns an empty string if input is null or undefined. */
export const formatTimeWithSeconds = (
dateInput: string | Date | null | undefined
dateInput: string | Date | null | undefined,
) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
return format(date, "HH:mm:ss");
};
/** Formats a date input to a human-readable date string.
* Returns "Today" or "Tomorrow" for those respective days,
* the weekday name (e.g. "Monday") if the date falls within the current week,
* or "MM/dd" otherwise. Returns an empty string if input is null or undefined. */
export const formatDate = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
const now = new Date();
if (
@@ -40,11 +51,15 @@ export const formatDate = (dateInput: string | Date | null | undefined) => {
if (isSameWeek(date, now, { weekStartsOn: 1 })) {
return format(date, "EEEE");
}
return format(date, "MM/dd");
};
/** Formats a date input to a "MM/dd/yyyy" string. Returns an empty string if input is null or undefined. */
export const formatDateMDY = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
return format(date, "MM/dd/yyyy");
};
+8 -8
View File
@@ -8,21 +8,21 @@ export enum LoginFailureReason {
UNKNOWN = "UNKNOWN",
}
export const reasonLabel = (reason?: LoginFailureReason | string | null) => {
export const reasonLabel = (reason?: LoginFailureReason | string) => {
switch (reason) {
case "MISSING_CREDENTIALS":
case LoginFailureReason.MISSING_CREDENTIALS:
return "Missing credentials";
case "INVALID_CREDENTIALS":
case LoginFailureReason.INVALID_CREDENTIALS:
return "Invalid credentials";
case "WRONG_PASSWORD":
case LoginFailureReason.WRONG_PASSWORD:
return "Wrong password";
case "ACCOUNT_LOCKED":
case LoginFailureReason.ACCOUNT_LOCKED:
return "Account locked";
case "NOT_ACTIVATED":
case LoginFailureReason.NOT_ACTIVATED:
return "Account not activated";
case "NOT_ALLOWED":
case LoginFailureReason.NOT_ALLOWED:
return "Not allowed";
case "UNKNOWN":
case LoginFailureReason.UNKNOWN:
return "Unknown";
default:
return null;