fix status
This commit is contained in:
@@ -37,12 +37,12 @@ def billing(
|
|||||||
):
|
):
|
||||||
pk = f'BILLING#ORG#{org_id}'
|
pk = f'BILLING#ORG#{org_id}'
|
||||||
sk = f'START#{start_date}#END#{end_date}'
|
sk = f'START#{start_date}#END#{end_date}'
|
||||||
r = dyn.collection.get_item(
|
billing = dyn.collection.get_item(
|
||||||
KeyPair(pk, sk),
|
KeyPair(pk, sk),
|
||||||
exc_cls=BillingNotFoundError,
|
exc_cls=BillingNotFoundError,
|
||||||
)
|
)
|
||||||
|
|
||||||
return r | dyn.collection.query(
|
return billing | dyn.collection.query(
|
||||||
KeyPair(
|
KeyPair(
|
||||||
pk=pk,
|
pk=pk,
|
||||||
sk=f'{sk}#ENROLLMENT',
|
sk=f'{sk}#ENROLLMENT',
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { CheckCircle2Icon, ClockIcon, type LucideIcon } from 'lucide-react'
|
||||||
|
|
||||||
|
export const statuses: Record<
|
||||||
|
string,
|
||||||
|
{ icon: LucideIcon; color?: string; label: string }
|
||||||
|
> = {
|
||||||
|
PENDING: {
|
||||||
|
icon: ClockIcon,
|
||||||
|
label: 'Em aberto'
|
||||||
|
},
|
||||||
|
CLOSED: {
|
||||||
|
icon: CheckCircle2Icon,
|
||||||
|
label: 'Fechado',
|
||||||
|
color: 'text-green-400 [&_svg]:text-green-500'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const labels: Record<string, string> = {
|
||||||
|
PENDING: 'Em aberto',
|
||||||
|
CLOSED: 'Fechado'
|
||||||
|
}
|
||||||
@@ -19,9 +19,11 @@ import {
|
|||||||
TableRow
|
TableRow
|
||||||
} from '@repo/ui/components/ui/table'
|
} from '@repo/ui/components/ui/table'
|
||||||
import { Abbr } from '@repo/ui/components/abbr'
|
import { Abbr } from '@repo/ui/components/abbr'
|
||||||
|
import { Button } from '@repo/ui/components/ui/button'
|
||||||
|
|
||||||
import { RangePeriod } from './range-period'
|
import { RangePeriod } from './range-period'
|
||||||
import { Button } from '@repo/ui/components/ui/button'
|
import { statuses } from './data'
|
||||||
|
import { cn } from '@repo/ui/lib/utils'
|
||||||
|
|
||||||
export function meta({}) {
|
export function meta({}) {
|
||||||
return [{ title: 'Resumo de cobranças' }]
|
return [{ title: 'Resumo de cobranças' }]
|
||||||
@@ -36,7 +38,7 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
|
|||||||
}).then((r) => r.json())
|
}).then((r) => r.json())
|
||||||
|
|
||||||
const [startDate, endDate] = billingPeriod(
|
const [startDate, endDate] = billingPeriod(
|
||||||
subscription?.billing_day,
|
subscription?.billing_day || 1,
|
||||||
new Date()
|
new Date()
|
||||||
)
|
)
|
||||||
const start = searchParams.get('start') || formatDate(startDate)
|
const start = searchParams.get('start') || formatDate(startDate)
|
||||||
@@ -75,25 +77,30 @@ export default function Route({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Await resolve={billing}>
|
<Await resolve={billing}>
|
||||||
{({ items, ...billing }) => {
|
{({ items = [], ...billing }) => {
|
||||||
|
const {
|
||||||
|
icon: Icon,
|
||||||
|
label: status,
|
||||||
|
color
|
||||||
|
} = statuses?.[billing?.status || 'CLOSED']
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="space-y-2.5">
|
<CardContent className="space-y-2.5">
|
||||||
<div className="flex max-lg:flex-col gap-2.5">
|
<div className="flex max-lg:flex-col gap-2.5">
|
||||||
<Button
|
<Button
|
||||||
className="pointer-events-none"
|
className={cn('pointer-events-none', color)}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
asChild
|
asChild
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<ClockIcon className="size-3.5" /> {billing?.status}
|
<Icon className="size-3.5" /> {status}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<RangePeriod
|
<RangePeriod
|
||||||
startDate={startDate}
|
startDate={startDate}
|
||||||
endDate={endDate}
|
endDate={endDate}
|
||||||
billingDay={subscription.billing_day}
|
billingDay={subscription.billing_day || 1}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -142,6 +149,14 @@ export default function Route({
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{items.length === 0 && (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={5} className="h-24 text-center">
|
||||||
|
Nenhum resultado.
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -152,7 +167,7 @@ export default function Route({
|
|||||||
{currency.format(
|
{currency.format(
|
||||||
items
|
items
|
||||||
?.filter((item) => 'course' in item)
|
?.filter((item) => 'course' in item)
|
||||||
.reduce(
|
?.reduce(
|
||||||
(acc, { unit_price }) => acc + unit_price,
|
(acc, { unit_price }) => acc + unit_price,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import { Button } from '@repo/ui/components/ui/button'
|
|||||||
import { ExportMenu } from '@repo/ui/components/export-menu'
|
import { ExportMenu } from '@repo/ui/components/export-menu'
|
||||||
import { Kbd } from '@repo/ui/components/ui/kbd'
|
import { Kbd } from '@repo/ui/components/ui/kbd'
|
||||||
import { createSearch } from '@repo/util/meili'
|
import { createSearch } from '@repo/util/meili'
|
||||||
|
|
||||||
import { headers, sortings, statuses } from '@repo/ui/routes/enrollments/data'
|
import { headers, sortings, statuses } from '@repo/ui/routes/enrollments/data'
|
||||||
|
|
||||||
import { columns, type Enrollment } from './columns'
|
import { columns, type Enrollment } from './columns'
|
||||||
|
|
||||||
export function meta({}: Route.MetaArgs) {
|
export function meta({}: Route.MetaArgs) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
BanIcon,
|
BanIcon,
|
||||||
CircleCheckIcon,
|
CheckCircle2Icon,
|
||||||
CircleIcon,
|
CircleIcon,
|
||||||
CircleXIcon,
|
CircleXIcon,
|
||||||
TimerIcon,
|
TimerIcon,
|
||||||
@@ -41,8 +41,8 @@ export const statuses: Record<
|
|||||||
label: 'Em andamento'
|
label: 'Em andamento'
|
||||||
},
|
},
|
||||||
COMPLETED: {
|
COMPLETED: {
|
||||||
icon: CircleCheckIcon,
|
icon: CheckCircle2Icon,
|
||||||
color: 'text-green-400 [&_svg]:text-background [&_svg]:fill-green-500',
|
color: 'text-green-400 [&_svg]:text-green-500',
|
||||||
label: 'Concluído'
|
label: 'Concluído'
|
||||||
},
|
},
|
||||||
FAILED: {
|
FAILED: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
CheckCircleIcon,
|
CheckCircle2Icon,
|
||||||
ClockAlertIcon,
|
ClockAlertIcon,
|
||||||
RotateCcwIcon,
|
RotateCcwIcon,
|
||||||
CircleXIcon,
|
CircleXIcon,
|
||||||
@@ -29,7 +29,7 @@ export const statuses: Record<
|
|||||||
color: 'text-blue-400 [&_svg]:text-blue-500'
|
color: 'text-blue-400 [&_svg]:text-blue-500'
|
||||||
},
|
},
|
||||||
PAID: {
|
PAID: {
|
||||||
icon: CheckCircleIcon,
|
icon: CheckCircle2Icon,
|
||||||
color: 'text-green-400 [&_svg]:text-green-500',
|
color: 'text-green-400 [&_svg]:text-green-500',
|
||||||
label: 'Pago'
|
label: 'Pago'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user