← All changes
|
resources/js/components/dashboard/RecentBookings.tsx
+11
-42
3.0.2.8
→
3.0.17
View file →
| @@ -4,12 +4,13 @@ | ||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | import React from "react"; |
| 7 | 7 | import { __ } from "../../lib/i18n"; |
| 8 | +import { toDateValue } from "../../lib/dateFormat"; | |
| 8 | 9 | import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; |
| 9 | 10 | import { Badge } from "../ui/badge"; |
| 10 | 11 | import { Calendar, User, ArrowRight } from "lucide-react"; |
| 11 | -import { getCurrencySymbol } from "../../data/currencies"; | |
| 12 | +import { formatYatraMoney } from "../../lib/currency-display"; | |
| 12 | 13 | |
| 13 | 14 | interface Booking { |
| 14 | 15 | id: number; |
| 15 | 16 | booking_id: string; |
| @@ -33,10 +34,13 @@ | ||
| 33 | 34 | bookings, |
| 34 | 35 | loading = false, |
| 35 | 36 | onView, |
| 36 | 37 | }) => { |
| 37 | - const formatDate = (dateString: string) => { | |
| 38 | - return new Date(dateString).toLocaleDateString("en-US", { | |
| 38 | + const formatDate = (dateString?: string | null) => { | |
| 39 | + // toDateValue: a date-only booking_date must not roll back a day in behind-UTC zones. | |
| 40 | + const date = toDateValue(dateString); | |
| 41 | + if (isNaN(date.getTime())) return "-"; | |
| 42 | + return date.toLocaleDateString("en-US", { | |
| 39 | 43 | month: "short", |
| 40 | 44 | day: "numeric", |
| 41 | 45 | year: "numeric", |
| 42 | 46 | }); |
| @@ -41,48 +45,13 @@ | ||
| 41 | 45 | year: "numeric", |
| 42 | 46 | }); |
| 43 | 47 | }; |
| 44 | 48 | |
| 45 | - // Get global currency settings | |
| 46 | 49 | const globalCurrency = (window as any)?.yatraAdmin?.currency || "USD"; |
| 47 | - const currencyPosition = | |
| 48 | - (window as any)?.yatraAdmin?.currencyPosition || | |
| 49 | - (window as any)?.yatraAdmin?.currency_position || | |
| 50 | - "before"; | |
| 51 | - const decimalPlaces = Number( | |
| 52 | - (window as any)?.yatraAdmin?.decimalPlaces || | |
| 53 | - (window as any)?.yatraAdmin?.currency_decimals || | |
| 54 | - 2, | |
| 55 | - ); | |
| 56 | - const thousandSeparator = | |
| 57 | - (window as any)?.yatraAdmin?.thousandSeparator || ","; | |
| 58 | - const decimalSeparator = (window as any)?.yatraAdmin?.decimalSeparator || "."; | |
| 59 | - | |
| 60 | - const formatCurrency = (amount: number) => { | |
| 61 | - if (!amount || amount === 0) return getCurrencySymbol(globalCurrency) + "0"; | |
| 62 | - | |
| 63 | - const numPrice = Number(amount) || 0; | |
| 64 | - | |
| 65 | - // Format the number with proper separators | |
| 66 | - const formattedAmount = new Intl.NumberFormat(undefined, { | |
| 67 | - minimumFractionDigits: decimalPlaces, | |
| 68 | - maximumFractionDigits: decimalPlaces, | |
| 69 | - }) | |
| 70 | - .format(numPrice) | |
| 71 | - .replace(/,/g, "TEMP_THOUSAND") | |
| 72 | - .replace(/\./g, decimalSeparator) | |
| 73 | - .replace(/TEMP_THOUSAND/g, thousandSeparator); | |
| 74 | - | |
| 75 | - // Get currency symbol | |
| 76 | - const currencySymbol = getCurrencySymbol(globalCurrency); | |
| 77 | - | |
| 78 | - // Apply currency position | |
| 79 | - if (currencyPosition === "after" || currencyPosition === "right") { | |
| 80 | - return `${formattedAmount} ${currencySymbol}`; | |
| 81 | - } else { | |
| 82 | - return `${currencySymbol}${formattedAmount}`; | |
| 83 | - } | |
| 84 | - }; | |
| 50 | + const formatCurrency = (amount: number) => | |
| 51 | + formatYatraMoney(Number(amount) || 0, globalCurrency, { | |
| 52 | + zeroAsUnknown: false, | |
| 53 | + }); | |
| 85 | 54 | |
| 86 | 55 | const getStatusColor = (status: string) => { |
| 87 | 56 | switch (status) { |
| 88 | 57 | case "confirmed": |