add badge

This commit is contained in:
2026-01-02 15:32:04 -03:00
parent 1abfd0e93e
commit 57b23d7cd2
9 changed files with 146 additions and 69 deletions

View File

@@ -19,5 +19,3 @@ export const labels: Record<string, string> = {
PENDING: 'Em aberto',
CLOSED: 'Fechado'
}
export const tz = 'America/Sao_Paulo'

View File

@@ -3,13 +3,13 @@ import { ChevronRightIcon, ChevronLeftIcon } from 'lucide-react'
import { subMonths, addMonths } from 'date-fns'
import { DateTime as LuxonDateTime } from 'luxon'
import { TZ } from '@/conf'
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 { DateTime } from '@repo/ui/components/datetime'
import { formatDate, billingPeriod } from './util'
import { tz } from './data'
type RangePeriodProps = {
startDate: Date
@@ -28,7 +28,7 @@ export function RangePeriod({
endDate,
billingDay
}: RangePeriodProps) {
const today = LuxonDateTime.now().setZone(tz).toJSDate()
const today = LuxonDateTime.now().setZone(TZ).toJSDate()
const [, setSearchParams] = useSearchParams()
const prevPeriod = billingPeriod(billingDay, subMonths(startDate, 1))
const nextPeriod = billingPeriod(billingDay, addMonths(startDate, 1))

View File

@@ -33,9 +33,10 @@ import { Kbd } from '@repo/ui/components/ui/kbd'
import { Currency } from '@repo/ui/components/currency'
import { DateTime } from '@repo/ui/components/datetime'
import { TZ } from '@/conf'
import { billingPeriod, formatDate } from './util'
import { RangePeriod } from './range-period'
import { tz, statuses } from './data'
import { statuses } from './data'
export function meta({}) {
return [{ title: 'Resumo de cobranças' }]
@@ -55,7 +56,7 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
const [startDate, endDate] = billingPeriod(
billing_day,
LuxonDateTime.now().setZone(tz).toJSDate()
LuxonDateTime.now().setZone(TZ).toJSDate()
)
const start = searchParams.get('start') || formatDate(startDate)
const end = searchParams.get('end') || formatDate(endDate)
@@ -69,8 +70,8 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
return {
billing_day,
billing,
startDate: LuxonDateTime.fromISO(start, { zone: tz }).toJSDate(),
endDate: LuxonDateTime.fromISO(end, { zone: tz }).toJSDate()
startDate: LuxonDateTime.fromISO(start, { zone: TZ }).toJSDate(),
endDate: LuxonDateTime.fromISO(end, { zone: TZ }).toJSDate()
}
}