Skip to content

Commit 2dfdd89

Browse files
committed
chore: button label discount form
1 parent 55f0446 commit 2dfdd89

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/components/GrossToNetDiscountForm.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface CommonDiscountFormProps {
4040

4141
type GrossToNetProps = CommonDiscountFormProps & {
4242
gross: CurrencyAmount
43+
submitButtonText?: string
4344
}
4445

4546
interface FormResult {
@@ -59,7 +60,7 @@ const INPUT_DAYS_MAX_VALUE = 360
5960

6061
type GrossToNetFormValues = FormValues
6162

62-
const GrossToNetDiscountForm = ({ startDate, endDate, gross, onSubmit }: GrossToNetProps) => {
63+
const GrossToNetDiscountForm = ({ startDate, endDate, gross, onSubmit, submitButtonText = "Submit" }: GrossToNetProps) => {
6364
const {
6465
watch,
6566
register,
@@ -94,7 +95,7 @@ const GrossToNetDiscountForm = ({ startDate, endDate, gross, onSubmit }: GrossTo
9495

9596
useEffect(() => {
9697
if (startDate === undefined) return
97-
setValue("daysInput", String(Math.min(daysBetween(startDate, endDate), INPUT_DAYS_MAX_VALUE)), {
98+
setValue("daysInput", String(Math.min(Math.max(1, daysBetween(startDate, endDate)), INPUT_DAYS_MAX_VALUE)), {
9899
shouldValidate: true,
99100
shouldDirty: true,
100101
shouldTouch: true,
@@ -208,7 +209,7 @@ const GrossToNetDiscountForm = ({ startDate, endDate, gross, onSubmit }: GrossTo
208209
</div>
209210

210211
<Button type="submit" size="sm" className="my-[16px]" disabled={!isValid}>
211-
Confirm
212+
{submitButtonText}
212213
</Button>
213214
</form>
214215
)

src/pages/quotes/QuotePage.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,26 @@ function OfferForm({ onSubmit, discount }: OfferFormProps) {
4848
{...discount}
4949
startDate={discount.startDate ?? new Date(Date.now())}
5050
onSubmit={onSubmit}
51+
submitButtonText="Next"
5152
/>
5253
</>
5354
)
5455
}
5556

5657
type OfferFormDrawerProps = Parameters<typeof BaseDrawer>[0] & {
58+
value: InfoReply
5759
onSubmit: OfferFormProps["onSubmit"]
5860
}
5961

60-
function OfferFormDrawer({ onSubmit, children, ...drawerProps }: OfferFormDrawerProps) {
62+
function OfferFormDrawer({ value, onSubmit, children, ...drawerProps }: OfferFormDrawerProps) {
6163
return (
6264
<BaseDrawer {...drawerProps} trigger={children}>
6365
<div className="px-4 py-12">
6466
<OfferForm
6567
discount={{
66-
endDate: new Date(Date.now() + 1_000_000_000),
68+
endDate: new Date(Date.parse(value.bill.maturity_date)),
6769
gross: {
68-
value: new Big(21_000),
70+
value: new Big(value.bill.sum),
6971
currency: "sat",
7072
},
7173
}}
@@ -197,7 +199,6 @@ function QuoteActions({ value, isFetching }: { value: InfoReply; isFetching: boo
197199
}
198200

199201
return (
200-
<>
201202
<div className="flex items-center gap-2">
202203
<DenyConfirmDrawer
203204
title="Confirm denying quote"
@@ -219,6 +220,7 @@ function QuoteActions({ value, isFetching }: { value: InfoReply; isFetching: boo
219220
<OfferFormDrawer
220221
title="Offer quote"
221222
description="Make an offer to the current holder of this bill"
223+
value={value}
222224
open={offerFormDrawerOpen}
223225
onOpenChange={setOfferFormDrawerOpen}
224226
onSubmit={(data) => {
@@ -258,7 +260,6 @@ function QuoteActions({ value, isFetching }: { value: InfoReply; isFetching: boo
258260
</div>
259261
</OfferConfirmDrawer>
260262
</div>
261-
</>
262263
)
263264
}
264265

0 commit comments

Comments
 (0)