Files
sarlinkportal-webui/lib/utils.ts
T
shihaam c137ef0847
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 4s
code clean up, remove frontend sms api??? why was it there at all?? and some cron things
2026-08-02 06:10:25 +05:00

53 lines
1.3 KiB
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import type { Payment, Topup } from "./backend-types";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const formatDate = (date: Date): string => {
const pad = (num: number): string => num.toString().padStart(2, "0");
const year = date.getFullYear();
const month = pad(date.getMonth() + 1); // Months are zero-based
const day = pad(date.getDate());
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes() + 5);
return `${year}-${month}-${day} ${hours}:${minutes}`;
};
export const formatMacAddress = (mac: string): string => {
const formatted = mac
.replace(/[^A-Fa-f0-9]/g, "")
.toUpperCase()
.match(/.{2}/g);
// Provide a fallback if formatted is null
return formatted ? formatted.join("-") : "";
};
export function shouldShowTopupPaymentInfo(topup: Topup | undefined): boolean {
if (!topup) return false;
return !(
topup.paid ||
topup.is_expired ||
topup.status === "CANCELLED" ||
topup.status === "VERIFIED"
);
}
export function shouldShowPaymentInfo(topup: Payment | undefined): boolean {
if (!topup) return false;
return !(
topup.paid ||
topup.is_expired ||
topup.status === "CANCELLED" ||
topup.status === "PAID"
);
}