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

View File

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

View File

@@ -2,10 +2,6 @@ export function formatCode(code: string) {
return code.length === 10 ? code.replace(/(.{5})(.{5})/, "$1-$2") : code; 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) { export function formatDuration(m: number | null | undefined) {
if (!m) return "Unlimited"; if (!m) return "Unlimited";
const days = Math.floor(m / 1440), const days = Math.floor(m / 1440),