@@ -5,10 +5,11 @@ import {
55 ProgramSheetAccordionItem ,
66 ProgramSheetAccordionTrigger ,
77} from "@/ui/partners/program-sheet-accordion" ;
8- import { AmountInput } from "@/ui/shared/amount-input" ;
9- import { ToggleGroup } from "@dub/ui" ;
10- import { cn } from "@dub/utils" ;
11- import { Controller } from "react-hook-form" ;
8+ import { RewardIconSquare } from "@/ui/partners/rewards/reward-icon-square" ;
9+ import { InlineBadgePopover } from "@/ui/shared/inline-badge-popover" ;
10+ import { CircleCheckFill , MoneyBills2 , ToggleGroup } from "@dub/ui" ;
11+ import { cn , currencyFormatter } from "@dub/utils" ;
12+ import { BountyAmountInput } from "./bounty-amount-input" ;
1213import { useAddEditBountyForm } from "./bounty-form-context" ;
1314import { BountyLogic } from "./bounty-logic" ;
1415
@@ -29,23 +30,27 @@ export function BountyCriteriaSection({
2930 setRewardType,
3031} : BountyCriteriaSectionProps ) {
3132 const {
32- control,
3333 register,
3434 watch,
3535 formState : { errors } ,
3636 } = useAddEditBountyForm ( ) ;
3737
38- const [ type , rewardDescription ] = watch ( [ "type" , "rewardDescription" ] ) ;
38+ const [ type , rewardDescription , rewardAmount ] = watch ( [
39+ "type" ,
40+ "rewardDescription" ,
41+ "rewardAmount" ,
42+ ] ) ;
43+
44+ const showWhenThenCards =
45+ ( rewardType === "flat" || type === "performance" ) &&
46+ ( type === "performance" ||
47+ ( type === "submission" && rewardType === "flat" ) ) ;
3948
4049 return (
4150 < ProgramSheetAccordionItem value = "bounty-criteria" >
4251 < ProgramSheetAccordionTrigger > Criteria</ ProgramSheetAccordionTrigger >
4352 < ProgramSheetAccordionContent >
4453 < div className = "space-y-6" >
45- < p className = "text-content-default text-sm" >
46- Set the reward and completion criteria.
47- </ p >
48-
4954 { type === "submission" && (
5055 < ToggleGroup
5156 className = "flex w-full items-center gap-1 rounded-md border border-neutral-200 bg-neutral-100 p-1"
@@ -57,42 +62,48 @@ export function BountyCriteriaSection({
5762 />
5863 ) }
5964
60- { ( rewardType === "flat" || type === "performance" ) && (
61- < div >
62- < label
63- htmlFor = "rewardAmount"
64- className = "text-sm font-medium text-neutral-800"
65- >
66- Reward
67- </ label >
68- < div className = "mt-2" >
69- < Controller
70- name = "rewardAmount"
71- control = { control }
72- rules = { {
73- required : true ,
74- min : 0 ,
75- } }
76- render = { ( { field } ) => (
77- < AmountInput
78- { ...field }
79- id = "rewardAmount"
80- amountType = "flat"
81- placeholder = "200"
82- error = { errors . rewardAmount ?. message }
83- value = {
84- field . value == null || isNaN ( field . value )
85- ? ""
86- : field . value
87- }
88- onChange = { ( e ) => {
89- const val = e . target . value ;
90-
91- field . onChange ( val === "" ? null : parseFloat ( val ) ) ;
92- } }
93- />
65+ { showWhenThenCards && (
66+ < div className = "flex flex-col gap-0" >
67+ < div className = "border-border-subtle rounded-xl border bg-white shadow-sm" >
68+ < div className = "flex items-center gap-2.5 p-2.5" >
69+ { type === "performance" ? (
70+ < BountyLogic />
71+ ) : (
72+ < >
73+ < RewardIconSquare icon = { CircleCheckFill } />
74+ < span className = "text-content-emphasis text-sm font-medium leading-relaxed" >
75+ When partner submits
76+ </ span >
77+ </ >
9478 ) }
95- />
79+ </ div >
80+ </ div >
81+
82+ < div className = "bg-border-subtle ml-6 h-4 w-px shrink-0" />
83+
84+ < div className = "border-border-subtle rounded-xl border bg-white shadow-sm" >
85+ < div className = "flex items-center gap-2.5 p-2.5" >
86+ < RewardIconSquare icon = { MoneyBills2 } />
87+ < span className = "text-content-emphasis text-sm font-medium leading-relaxed" >
88+ Then pay{ " " }
89+ < InlineBadgePopover
90+ text = {
91+ rewardAmount != null && ! isNaN ( rewardAmount )
92+ ? currencyFormatter ( rewardAmount * 100 , {
93+ trailingZeroDisplay : "stripIfInteger" ,
94+ } )
95+ : "$0"
96+ }
97+ invalid = {
98+ rewardAmount == null ||
99+ isNaN ( rewardAmount ) ||
100+ rewardAmount < 0
101+ }
102+ >
103+ < BountyAmountInput name = "rewardAmount" />
104+ </ InlineBadgePopover >
105+ </ span >
106+ </ div >
96107 </ div >
97108 </ div >
98109 ) }
@@ -129,15 +140,6 @@ export function BountyCriteriaSection({
129140 </ div >
130141 ) }
131142
132- { type === "performance" && (
133- < div >
134- < span className = "text-sm font-medium text-neutral-800" >
135- Logic
136- </ span >
137- < BountyLogic className = "mt-2" />
138- </ div >
139- ) }
140-
141143 { rewardType === "custom" && type === "submission" && (
142144 < div className = "gap-4 rounded-lg bg-orange-50 px-4 py-2.5 text-center" >
143145 < span className = "text-sm font-medium text-orange-800" >
0 commit comments