fix timezone
This commit is contained in:
@@ -19,3 +19,5 @@ export const labels: Record<string, string> = {
|
||||
PENDING: 'Em aberto',
|
||||
CLOSED: 'Fechado'
|
||||
}
|
||||
|
||||
export const tz = 'America/Sao_Paulo'
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { useSearchParams } from 'react-router'
|
||||
import { ChevronRightIcon, ChevronLeftIcon } from 'lucide-react'
|
||||
import { subMonths, addMonths } from 'date-fns'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
import { Button } from '@repo/ui/components/ui/button'
|
||||
import { ButtonGroup } from '@repo/ui/components/ui/button-group'
|
||||
import { Badge } from '@repo/ui/components/ui/badge'
|
||||
|
||||
import { formatDate, billingPeriod } from './util'
|
||||
import { useSearchParams } from 'react-router'
|
||||
import { tz } from './data'
|
||||
|
||||
type RangePeriodProps = {
|
||||
startDate: Date
|
||||
@@ -19,7 +21,7 @@ export function RangePeriod({
|
||||
endDate,
|
||||
billingDay
|
||||
}: RangePeriodProps) {
|
||||
const today = new Date()
|
||||
const today = DateTime.now().setZone(tz).toJSDate()
|
||||
const [, setSearchParams] = useSearchParams()
|
||||
const prevPeriod = billingPeriod(billingDay, subMonths(startDate, 1))
|
||||
const nextPeriod = billingPeriod(billingDay, addMonths(startDate, 1))
|
||||
|
||||
@@ -33,7 +33,7 @@ import { Kbd } from '@repo/ui/components/ui/kbd'
|
||||
|
||||
import { billingPeriod, formatDate } from './util'
|
||||
import { RangePeriod } from './range-period'
|
||||
import { statuses } from './data'
|
||||
import { tz, statuses } from './data'
|
||||
|
||||
export function meta({}) {
|
||||
return [{ title: 'Resumo de cobranças' }]
|
||||
@@ -49,7 +49,7 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
|
||||
|
||||
const [startDate, endDate] = billingPeriod(
|
||||
subscription?.billing_day || 1,
|
||||
new Date()
|
||||
DateTime.now().setZone(tz).toJSDate()
|
||||
)
|
||||
const start = searchParams.get('start') || formatDate(startDate)
|
||||
const end = searchParams.get('end') || formatDate(endDate)
|
||||
@@ -63,8 +63,8 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
|
||||
return {
|
||||
subscription,
|
||||
billing,
|
||||
startDate: DateTime.fromISO(start).toJSDate(),
|
||||
endDate: DateTime.fromISO(end).toJSDate()
|
||||
startDate: DateTime.fromISO(start, { zone: tz }).toJSDate(),
|
||||
endDate: DateTime.fromISO(end, { zone: tz }).toJSDate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user