update payment details

This commit is contained in:
2026-01-15 14:21:11 -03:00
parent 906dde027c
commit 5f53ffb4a7
7 changed files with 241 additions and 129 deletions

View File

@@ -1,4 +1,5 @@
import { Fragment, useEffect } from 'react'
import { ErrorMessage } from '@hookform/error-message'
import { zodResolver } from '@hookform/resolvers/zod'
import {
ArrowRightIcon,
MinusIcon,
@@ -6,31 +7,30 @@ import {
Trash2Icon,
XIcon
} from 'lucide-react'
import { useForm, useFieldArray, Controller, useWatch } from 'react-hook-form'
import { ErrorMessage } from '@hookform/error-message'
import { zodResolver } from '@hookform/resolvers/zod'
import { Fragment, useEffect } from 'react'
import { Controller, useFieldArray, useForm, useWatch } from 'react-hook-form'
import { z } from 'zod'
import { Abbr } from '@repo/ui/components/abbr'
import { Button } from '@repo/ui/components/ui/button'
import { Form } from '@repo/ui/components/ui/form'
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput
} from '@repo/ui/components/ui/input-group'
import { Form } from '@repo/ui/components/ui/form'
import { Button } from '@repo/ui/components/ui/button'
import { Kbd } from '@repo/ui/components/ui/kbd'
import { Separator } from '@repo/ui/components/ui/separator'
import { Spinner } from '@repo/ui/components/ui/spinner'
import { Kbd } from '@repo/ui/components/ui/kbd'
import { Abbr } from '@repo/ui/components/abbr'
import { Cell } from '../_.$orgid.enrollments.add/route'
import { useWizard } from '@/components/wizard'
import { CoursePicker } from '../_.$orgid.enrollments.add/course-picker'
import { MAX_ITEMS, type Course } from '../_.$orgid.enrollments.add/data'
import { Discount, applyDiscount, type Coupon } from './discount'
import { currency } from './utils'
import { useWizard } from '@/components/wizard'
import { Cell } from '../_.$orgid.enrollments.add/route'
import { Discount } from './discount'
import { useWizardStore } from './store'
import { currency } from './utils'
const emptyRow = {
course: undefined as any,

View File

@@ -8,6 +8,8 @@ import { z } from 'zod'
import valid from 'card-validator'
import { Currency } from '@repo/ui/components/currency'
import { Kbd } from '@repo/ui/components/ui/kbd'
import { Abbr } from '@repo/ui/components/abbr'
import { Button } from '@repo/ui/components/ui/button'
import { Separator } from '@repo/ui/components/ui/separator'
import { Spinner } from '@repo/ui/components/ui/spinner'
@@ -73,7 +75,7 @@ type ReviewProps = {
export function Review({ onSubmit }: ReviewProps) {
const wizard = useWizard()
const { items, summary, address } = useWizardStore()
const { items, summary, address, coupon } = useWizardStore()
const { subtotal, discount, interest_amount, total } = summary()
const [loading, { set }] = useToggle()
@@ -127,8 +129,15 @@ export function Review({ onSubmit }: ReviewProps) {
</TableRow>
{/* Discount */}
<TableRow>
<TableCell className="text-right" colSpan={3}>
Descontos
<TableCell colSpan={3}>
<span className="flex gap-1 justify-end">
Descontos
{coupon && (
<Kbd>
<Abbr maxLen={8}>{coupon.code}</Abbr>
</Kbd>
)}
</span>
</TableCell>
<TableCell>
<Currency>{discount}</Currency>