fix: removed date formatting as it is done in the backend

This commit is contained in:
etiennecollin
2025-08-14 12:50:05 -04:00
parent 34f9ebd098
commit 603a0c11b2
3 changed files with 6 additions and 20 deletions

View File

@@ -1,10 +1,5 @@
import { Voucher } from "@/types/voucher";
import {
formatCode,
formatDate,
formatDuration,
formatGuestUsage,
} from "@/utils/format";
import { formatCode, formatDuration, formatGuestUsage } from "@/utils/format";
import { memo } from "react";
type Props = {
@@ -62,7 +57,7 @@ const VoucherCard = ({ voucher, selected, editMode, onClick }: Props) => {
{voucher.activatedAt && (
<div className="flex justify-between">
<span>First Used:</span>
<span className="text-xs">{formatDate(voucher.activatedAt)}</span>
<span className="text-xs">{voucher.activatedAt}</span>
</div>
)}
@@ -73,9 +68,7 @@ const VoucherCard = ({ voucher, selected, editMode, onClick }: Props) => {
{voucher.expired ? "Expired" : "Active"}
</span>
{voucher.expiresAt && (
<span className="text-xs">
Expires: {formatDate(voucher.expiresAt)}
</span>
<span className="text-xs">Expires: {voucher.expiresAt}</span>
)}
</div>
</div>

View File

@@ -6,7 +6,6 @@ import { api } from "@/utils/api";
import { useEffect, useRef, useState } from "react";
import {
formatBytes,
formatDate,
formatDuration,
formatGuestUsage,
formatSpeed,
@@ -64,13 +63,11 @@ export default function VoucherModal({ voucher, onClose }: Props) {
[
["Status", details.expired ? "Expired" : "Active"],
["Name", details.name || "No note"],
["Created", formatDate(details.createdAt)],
["Created", details.createdAt],
...(details.activatedAt
? [["Activated", formatDate(details.activatedAt)]]
: []),
...(details.expiresAt
? [["Expires", formatDate(details.expiresAt)]]
? [["Activated", details.activatedAt]]
: []),
...(details.expiresAt ? [["Expires", details.expiresAt]] : []),
["Duration", formatDuration(details.timeLimitMinutes)],
[
"Guest Usage",

View File

@@ -2,10 +2,6 @@ export function formatCode(code: string) {
return code.length === 10 ? code.replace(/(.{5})(.{5})/, "$1-$2") : code;
}
export function formatDate(d: string) {
return new Date(d).toLocaleString();
}
export function formatDuration(m: number | null | undefined) {
if (!m) return "Unlimited";
const days = Math.floor(m / 1440),