From cc5b5fca241132ec90620aa9b13836fa293208da Mon Sep 17 00:00:00 2001 From: Jelaletdin12 Date: Mon, 31 Aug 2026 22:36:56 +0500 Subject: [PATCH] fixed date fields --- src/lib/utils/dateUtils.ts | 21 +++++++++--- src/pages/backups/index.tsx | 3 +- src/pages/backupsView/index.tsx | 5 +-- .../cardDepartment/cardBalance/index.tsx | 4 +-- .../cardDepartment/cardBalanceView/index.tsx | 8 ++--- src/pages/cardDepartment/cardPins/index.tsx | 4 +-- .../cardDepartment/cardPinsView/index.tsx | 32 ++++++++++++------- .../cardRequisitesView/index.tsx | 12 ++----- .../cardDepartment/cardTransactions/index.tsx | 3 +- .../cardTransactionsView/index.tsx | 5 +-- .../cardDepartment/orderNewCard/index.tsx | 3 +- .../cardDepartment/orderNewCardView/index.tsx | 9 +++--- src/pages/currencies/currencyRates/index.tsx | 3 +- .../currencies/currencyRatesView/index.tsx | 5 +-- .../visaMasterPayments/index.tsx | 5 ++- .../visaMasterPaymentsView/index.tsx | 3 +- src/pages/logs/index.tsx | 3 +- src/pages/logs/view.tsx | 3 +- 18 files changed, 78 insertions(+), 53 deletions(-) diff --git a/src/lib/utils/dateUtils.ts b/src/lib/utils/dateUtils.ts index ebbb99f..d811985 100644 --- a/src/lib/utils/dateUtils.ts +++ b/src/lib/utils/dateUtils.ts @@ -41,17 +41,28 @@ export function formatToApiDate(dateStr?: string | Date | null): string { } /** - * Backend'den gelen ISO UTC tarih formatını UI datepicker/input'unun beklediği 'YYYY-MM-DD' formatına çevirir. - * Örn: '1987-04-08T00:00:00Z' -> '1987-04-08' + * Backend'den gelen ISO UTC tarih formatını 'hh:mm, dd.mm.yyyy' formatına çevirir. + * Örn: '1987-04-08T14:35:00Z' -> '14:35, 08.04.1987' */ export function formatFromApiDate(isoStr?: string | null): string { if (!isoStr) return ""; const trimmed = isoStr.trim(); if (!trimmed) return ""; - if (/^\d{4}-\d{2}-\d{2}/.test(trimmed)) { - return trimmed.slice(0, 10); + const d = new Date(trimmed); + if (isNaN(d.getTime())) return trimmed; + + const hours = d.getUTCHours(); + const minutes = d.getUTCMinutes(); + const day = String(d.getUTCDate()).padStart(2, "0"); + const month = String(d.getUTCMonth() + 1).padStart(2, "0"); + const year = d.getUTCFullYear(); + + const dateStr = `${day}.${month}.${year}`; + + if (hours === 0 && minutes === 0) { + return dateStr; } - return trimmed; + return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}, ${dateStr}`; } diff --git a/src/pages/backups/index.tsx b/src/pages/backups/index.tsx index 3eb367f..e3ed02e 100644 --- a/src/pages/backups/index.tsx +++ b/src/pages/backups/index.tsx @@ -13,6 +13,7 @@ import { CreateButton } from "@/components/createButton"; import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge"; import { useBackups, useCreateBackup, useDeleteBackup, useDownloadBackup } from "@/features/backups/hooks/useBackups"; import type { Backup, BackupStatus } from "@/features/backups/api/backupsApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Status Badge ───────────────────────────────────────────────────────────── @@ -144,7 +145,7 @@ export default function BackupsPage() { accessorKey: "createdAt", header: t("backups.col.createdAt", "Döredilen wagty"), cell: ({ row }) => ( - {new Date(row.original.createdAt).toLocaleString()} + {formatFromApiDate(row.original.createdAt)} ), size: 180, }, diff --git a/src/pages/backupsView/index.tsx b/src/pages/backupsView/index.tsx index 1cd0615..38a2356 100644 --- a/src/pages/backupsView/index.tsx +++ b/src/pages/backupsView/index.tsx @@ -18,6 +18,7 @@ import { useBackup, useDeleteBackup, useDownloadBackup } from "@/features/backup import { InfoRow } from "@/components/viewPageComponents"; import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge"; import type { BackupStatus } from "@/features/backups/api/backupsApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Status Badge ───────────────────────────────────────────────────────────── @@ -116,8 +117,8 @@ export default function BackupViewPage() { isLink href={data.createdBy?.id != null ? `/all-users/${data.createdBy.id}` : undefined} /> - - + + {/* Delete dialog */} diff --git a/src/pages/cardDepartment/cardBalance/index.tsx b/src/pages/cardDepartment/cardBalance/index.tsx index 47e8e1a..03db890 100644 --- a/src/pages/cardDepartment/cardBalance/index.tsx +++ b/src/pages/cardDepartment/cardBalance/index.tsx @@ -14,7 +14,7 @@ import { DeleteDialog } from "@/components/deleteDialog"; import { useCardBalances, useDeleteCardBalance } from "@/features/cardBalance/hooks/useCardBalance"; import type { CardBalance, CardBalanceStatus } from "@/features/cardBalance/api/cardBalanceApi"; import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers"; - +import { formatFromApiDate } from "@/lib/utils"; // ─── Status Badge ───────────────────────────────────────────────────────────── const STATUS_CONFIG: Record< @@ -192,7 +192,7 @@ export default function CardBalancesPage() { accessorKey: "createdAt", header: t("Created at", "DÖREDILEN WAGTY"), cell: ({ row }) => ( - {new Date(row.original.createdAt).toLocaleString()} + {formatFromApiDate(row.original.createdAt)} ), size: 180, }, diff --git a/src/pages/cardDepartment/cardBalanceView/index.tsx b/src/pages/cardDepartment/cardBalanceView/index.tsx index 39138b5..43101ba 100644 --- a/src/pages/cardDepartment/cardBalanceView/index.tsx +++ b/src/pages/cardDepartment/cardBalanceView/index.tsx @@ -18,7 +18,7 @@ import { useCardBalance, useDeleteCardBalance } from "@/features/cardBalance/hoo import { InfoRow } from "@/components/viewPageComponents"; import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge"; import type { CardBalanceStatus } from "@/features/cardBalance/api/cardBalanceApi"; - +import { formatFromApiDate } from "@/lib/utils"; // ─── Status Badge ───────────────────────────────────────────────────────────── const STATUS_CONFIG: Record< @@ -109,15 +109,15 @@ export default function CardBalanceViewPage() { - + - - + + {/* Delete dialog */} diff --git a/src/pages/cardDepartment/cardPins/index.tsx b/src/pages/cardDepartment/cardPins/index.tsx index efa4844..330683e 100644 --- a/src/pages/cardDepartment/cardPins/index.tsx +++ b/src/pages/cardDepartment/cardPins/index.tsx @@ -18,7 +18,7 @@ import { useBranches } from "@/features/branches/hooks/useBranches"; import { useDistricts } from "@/features/districts/hooks/useDistricts"; import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes"; import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants"; - +import { formatFromApiDate } from "@/lib/utils"; // ─── Filter field IDs ────────────────────────────────────────────────────────── const FILTER_IDS = ["status", "branch_id", "user_id", "card_type_id", "region"] as const; @@ -152,7 +152,7 @@ export default function CardPinsPage() { header: t("cardPin.col.createdAt", "Döredilen wagty"), cell: ({ row }) => ( - {row.original.createdAt ? new Date(row.original.createdAt).toLocaleString() : "—"} + {row.original.createdAt ? formatFromApiDate(row.original.createdAt) : "—"} ), size: 180, diff --git a/src/pages/cardDepartment/cardPinsView/index.tsx b/src/pages/cardDepartment/cardPinsView/index.tsx index 54b10a2..8b09dc0 100644 --- a/src/pages/cardDepartment/cardPinsView/index.tsx +++ b/src/pages/cardDepartment/cardPinsView/index.tsx @@ -18,9 +18,10 @@ import { AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; -import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents"; +import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents"; import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants"; import type { LocalizedText } from "@/features/branches/api/branchesApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Helpers ────────────────────────────────────────────────────────────────── @@ -95,8 +96,6 @@ export default function CardPinViewPage() { return
{t("common.notFound", "Maglumat tapylmady")}
; } - const fmtDate = (v?: string | null) => (v ? new Date(v).toLocaleDateString() : "—"); - return (
{/* ── Page header ──────────────────────────────────────────────────── */} @@ -155,10 +154,7 @@ export default function CardPinViewPage() { - + @@ -195,17 +191,29 @@ export default function CardPinViewPage() { label={t("cardPin.fullName", "Doly ady")} value={`${data.customerSurname} ${data.customerName} ${data.customerPatronicName ?? ""}`.trim()} /> - + - - - - + + + + {/* ── Row 3: Pasport suratlary ──────────────────────────────────────── */} + + + + + + + + + + + +
diff --git a/src/pages/cardDepartment/cardRequisitesView/index.tsx b/src/pages/cardDepartment/cardRequisitesView/index.tsx index 2f72b1b..674bd3a 100644 --- a/src/pages/cardDepartment/cardRequisitesView/index.tsx +++ b/src/pages/cardDepartment/cardRequisitesView/index.tsx @@ -20,6 +20,7 @@ import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisit import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge"; import { AlertCircle, CheckCircle2, XCircle } from "lucide-react"; import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Status config ──────────────────────────────────────────────────────────── @@ -64,13 +65,6 @@ function CardRequisiteViewSkeleton() { ); } -function formatDate(value?: string): string { - if (!value) return ""; - const d = new Date(value); - if (isNaN(d.getTime())) return value; - return d.toLocaleDateString(); -} - // ─── Page ───────────────────────────────────────────────────────────────────── export default function CardRequisiteViewPage() { @@ -148,7 +142,7 @@ export default function CardRequisiteViewPage() { - + @@ -182,7 +176,7 @@ export default function CardRequisiteViewPage() { - + diff --git a/src/pages/cardDepartment/cardTransactions/index.tsx b/src/pages/cardDepartment/cardTransactions/index.tsx index ece0c02..63bd01b 100644 --- a/src/pages/cardDepartment/cardTransactions/index.tsx +++ b/src/pages/cardDepartment/cardTransactions/index.tsx @@ -10,6 +10,7 @@ import { TableActions } from "@/components/tableActions"; import type { VisibilityState } from "@tanstack/react-table"; import { useCardTransactions, useDeleteCardTransaction } from "@/features/cardTransactions/hooks/useCardTransactions"; import type { Card } from "@/features/cardTransactions/api/cardTransactionsApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Page ───────────────────────────────────────────────────────────────────── @@ -103,7 +104,7 @@ export default function CardTransactionsPage() { header: t("cardTransaction.col.createdAt", "Döredilen wagty"), cell: ({ row }) => ( - {row.original.createdAt ? new Date(row.original.createdAt).toLocaleString() : "—"} + {row.original.createdAt ? formatFromApiDate(row.original.createdAt) : "—"} ), size: 180, diff --git a/src/pages/cardDepartment/cardTransactionsView/index.tsx b/src/pages/cardDepartment/cardTransactionsView/index.tsx index c5e3ee0..5cf377f 100644 --- a/src/pages/cardDepartment/cardTransactionsView/index.tsx +++ b/src/pages/cardDepartment/cardTransactionsView/index.tsx @@ -17,6 +17,7 @@ import { import { useCardTransaction, useDeleteCardTransaction } from "@/features/cardTransactions/hooks/useCardTransactions"; import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents"; import i18n from "@/lib/i18n"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Page ───────────────────────────────────────────────────────────────────── @@ -106,11 +107,11 @@ export default function CardTransactionViewPage() { /> diff --git a/src/pages/cardDepartment/orderNewCard/index.tsx b/src/pages/cardDepartment/orderNewCard/index.tsx index 6ac1ea0..95dd646 100644 --- a/src/pages/cardDepartment/orderNewCard/index.tsx +++ b/src/pages/cardDepartment/orderNewCard/index.tsx @@ -18,6 +18,7 @@ import { useInfiniteBranches } from "@/features/branches/hooks/useBranches"; import { useInfiniteDistricts } from "@/features/districts/hooks/useDistricts"; import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes"; import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants"; +import { formatFromApiDate } from "@/lib/utils/dateUtils"; const PER_PAGE = 25; @@ -176,7 +177,7 @@ export default function CardOrdersPage() { header: t("cardOrder.col.createdAt", "Döredilen wagty"), cell: ({ row }) => ( - {row.original.createdAt ? new Date(row.original.createdAt).toLocaleString() : "—"} + {row.original.createdAt ? formatFromApiDate(row.original.createdAt) : "—"} ), size: 180, diff --git a/src/pages/cardDepartment/orderNewCardView/index.tsx b/src/pages/cardDepartment/orderNewCardView/index.tsx index 6cdc61c..d47fd93 100644 --- a/src/pages/cardDepartment/orderNewCardView/index.tsx +++ b/src/pages/cardDepartment/orderNewCardView/index.tsx @@ -20,6 +20,7 @@ import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadg import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react"; import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants"; import type { LocalizedText } from "@/features/branches/api/branchesApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Helpers ────────────────────────────────────────────────────────────────── @@ -96,8 +97,6 @@ export default function CardOrderDetailPage() { if (isLoading) return ; if (!order) return

{t("common.notFound", "Tapylmady")}

; - const fmtDate = (v?: string | null) => (v ? new Date(v).toLocaleDateString() : "—"); - return (
{/* ── Page header ──────────────────────────────────────────────────── */} @@ -149,7 +148,7 @@ export default function CardOrderDetailPage() { @@ -188,7 +187,7 @@ export default function CardOrderDetailPage() { label={t("cardOrder.field.fullName", "Doly ady")} value={[order.customerSurname, order.customerName, order.customerPatronicName].filter(Boolean).join(" ")} /> - + @@ -207,7 +206,7 @@ export default function CardOrderDetailPage() { - + diff --git a/src/pages/currencies/currencyRates/index.tsx b/src/pages/currencies/currencyRates/index.tsx index 21a9264..281157d 100644 --- a/src/pages/currencies/currencyRates/index.tsx +++ b/src/pages/currencies/currencyRates/index.tsx @@ -11,6 +11,7 @@ import { TableActions } from "@/components/tableActions"; import { DeleteDialog } from "@/components/deleteDialog"; import { useGetCurrencyRates, useDeleteCurrencyRate } from "@/features/currencyRates/hooks/useCurrencyRates"; import { CURRENCY_OPTIONS, type CurrencyRate } from "@/features/currencyRates/api/currencyRatesApi"; +import { formatFromApiDate } from "@/lib/utils"; // ─── Column meta for toggle dropdown ───────────────────────────────────────── @@ -125,7 +126,7 @@ export default function CurrencyRatesPage() { accessorKey: "createdAt", header: t("Created at", "DÖREDILEN WAGTY"), cell: ({ row }) => ( - {new Date(row.original.createdAt).toLocaleString()} + {formatFromApiDate(row.original.createdAt)} ), size: 180, }, diff --git a/src/pages/currencies/currencyRatesView/index.tsx b/src/pages/currencies/currencyRatesView/index.tsx index db3c8ad..480f590 100644 --- a/src/pages/currencies/currencyRatesView/index.tsx +++ b/src/pages/currencies/currencyRatesView/index.tsx @@ -9,6 +9,7 @@ import { Skeleton } from "@/components/ui/skeleton"; import { Section, InfoRow } from "@/components/viewPageComponents"; import { useGetCurrencyRateById, useDeleteCurrencyRate } from "@/features/currencyRates/hooks/useCurrencyRates"; import { ConfirmDialog } from "@/components/confirmDialog"; +import { formatFromApiDate } from "@/lib/utils"; // ─── CurrencyRateDetailPage ─────────────────────────────────────────────────── @@ -96,8 +97,8 @@ export default function CurrencyRateDetailPage() { isLink href={rate.updatedBy?.id != null ? `/all-users/${rate.updatedBy.id}` : undefined} /> - - + + {row.original.created_at}, + cell: ({ row }) => ( + {formatFromApiDate(row.original.created_at)} + ), }, { accessorKey: "province_label", diff --git a/src/pages/internationalPayments/visaMasterPaymentsView/index.tsx b/src/pages/internationalPayments/visaMasterPaymentsView/index.tsx index 3702dd3..b3c78b9 100644 --- a/src/pages/internationalPayments/visaMasterPaymentsView/index.tsx +++ b/src/pages/internationalPayments/visaMasterPaymentsView/index.tsx @@ -8,6 +8,7 @@ import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadg import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents"; import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments"; import type { IntlPaymentStatus } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi"; +import { formatFromApiDate } from "@/lib/utils/dateUtils"; // ─── Status config ──────────────────────────────────────────────────────────── @@ -201,7 +202,7 @@ export default function IntlPaymentViewPage() { - + diff --git a/src/pages/logs/index.tsx b/src/pages/logs/index.tsx index 8aaf46c..c18a888 100644 --- a/src/pages/logs/index.tsx +++ b/src/pages/logs/index.tsx @@ -8,6 +8,7 @@ import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar import { useActivityLogs } from "@/features/activityLogs/hooks/useActivityLogs"; import type { ActivityLog } from "@/features/activityLogs/api/activityLogsApi"; import type { VisibilityState } from "@tanstack/react-table"; +import { formatFromApiDate } from "@/lib/utils"; const MODULE_OPTIONS = [ "loan-orders", @@ -135,7 +136,7 @@ export default function ActivityLogsPage() { { accessorKey: "createdAt", header: t("logs.fields.createdAt", "Wagty"), - cell: ({ row }) => {new Date(row.original.createdAt).toLocaleString()}, + cell: ({ row }) => {formatFromApiDate(row.original.createdAt)}, size: 170, }, { diff --git a/src/pages/logs/view.tsx b/src/pages/logs/view.tsx index f079629..2d86aa4 100644 --- a/src/pages/logs/view.tsx +++ b/src/pages/logs/view.tsx @@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { Spinner } from "@/components/ui/spinner"; import { useActivityLog } from "@/features/activityLogs/hooks/useActivityLogs"; +import { formatFromApiDate } from "@/lib/utils"; export default function ActivityLogViewPage() { const { t } = useTranslation(); @@ -115,7 +116,7 @@ export default function ActivityLogViewPage() {
{t("logs.fields.createdAt", "Wagty")} - {new Date(log.createdAt).toLocaleString()} + {formatFromApiDate(log.createdAt)}