11"use client" ;
22
33import type { ThirdwebClient } from "thirdweb" ;
4+ import { DistributionBarChart } from "@/components/blocks/distribution-chart" ;
45import { FormFieldSetup } from "@/components/blocks/FormFieldSetup" ;
56import { TokenSelector } from "@/components/blocks/TokenSelector" ;
67import { DynamicHeight } from "@/components/ui/DynamicHeight" ;
@@ -21,6 +22,11 @@ export function DropERC20_TokenSaleSection(props: {
2122 ) ;
2223
2324 const isEnabled = props . form . watch ( "saleEnabled" ) ;
25+
26+ const protocolFee = 2 ;
27+ const convenienceFee = 0.5 ;
28+ const recipientFee = 100 - protocolFee - convenienceFee ;
29+
2430 return (
2531 < DynamicHeight >
2632 < div className = "relative border-t border-dashed p-6" >
@@ -56,76 +62,113 @@ export function DropERC20_TokenSaleSection(props: {
5662 </ div >
5763
5864 { isEnabled && (
59- < div className = "mt-4 flex flex-col lg:flex-row gap-5 lg:max-w-2xl fade-in-0 duration-300 animate-in" >
60- < FormFieldSetup
61- errorMessage = {
62- props . form . formState . errors . dropERC20Mode
63- ?. saleAllocationPercentage ?. message
64- }
65- helperText = { `${ sellSupply } tokens` }
66- isRequired
67- label = "Sell % of Total Supply"
68- >
69- < div className = "relative lg:w-64" >
70- < DecimalInput
71- maxValue = { 100 }
72- onChange = { ( value ) => {
73- props . form . setValue (
65+ < div >
66+ < div className = "mt-4 flex flex-col lg:flex-row gap-5 lg:max-w-2xl fade-in-0 duration-300 animate-in" >
67+ < FormFieldSetup
68+ errorMessage = {
69+ props . form . formState . errors . dropERC20Mode
70+ ?. saleAllocationPercentage ?. message
71+ }
72+ helperText = { `${ sellSupply } tokens` }
73+ isRequired
74+ label = "Sell % of Total Supply"
75+ >
76+ < div className = "relative lg:w-64" >
77+ < DecimalInput
78+ maxValue = { 100 }
79+ onChange = { ( value ) => {
80+ props . form . setValue (
81+ "dropERC20Mode.saleAllocationPercentage" ,
82+ value ,
83+ ) ;
84+ } }
85+ value = { props . form . watch (
7486 "dropERC20Mode.saleAllocationPercentage" ,
75- value ,
76- ) ;
77- } }
78- value = { props . form . watch (
79- "dropERC20Mode.saleAllocationPercentage" ,
80- ) }
81- />
82- < span className = "-translate-y-1/2 absolute top-1/2 right-3 text-muted-foreground text-sm" >
83- %
84- </ span >
85- </ div >
86- </ FormFieldSetup >
87+ ) }
88+ />
89+ < span className = "-translate-y-1/2 absolute top-1/2 right-3 text-muted-foreground text-sm" >
90+ %
91+ </ span >
92+ </ div >
93+ </ FormFieldSetup >
8794
88- < FormFieldSetup
89- className = "grow"
90- errorMessage = {
91- props . form . formState . errors . dropERC20Mode ?. pricePerToken
92- ?. message ||
93- props . form . formState . errors . dropERC20Mode ?. saleTokenAddress
94- ?. message
95- }
96- isRequired
97- label = "Price per Token"
98- >
99- < div className = "relative flex items-center" >
100- < DecimalInput
101- onChange = { ( value ) => {
102- props . form . setValue ( "dropERC20Mode.pricePerToken" , value ) ;
103- } }
104- value = { props . form . watch ( "dropERC20Mode.pricePerToken" ) }
105- className = "rounded-r-none w-42"
106- />
95+ < FormFieldSetup
96+ className = "grow"
97+ errorMessage = {
98+ props . form . formState . errors . dropERC20Mode ?. pricePerToken
99+ ?. message ||
100+ props . form . formState . errors . dropERC20Mode ?. saleTokenAddress
101+ ?. message
102+ }
103+ isRequired
104+ label = "Price per Token"
105+ >
106+ < div className = "relative flex items-center" >
107+ < DecimalInput
108+ onChange = { ( value ) => {
109+ props . form . setValue ( "dropERC20Mode.pricePerToken" , value ) ;
110+ } }
111+ value = { props . form . watch ( "dropERC20Mode.pricePerToken" ) }
112+ className = "rounded-r-none w-42"
113+ />
114+
115+ < TokenSelector
116+ addNativeTokenIfMissing = { true }
117+ chainId = { Number ( props . chainId ) }
118+ className = "bg-background border-l-0 rounded-l-none"
119+ client = { props . client }
120+ disableAddress = { true }
121+ popoverContentClassName = "!w-[320px]"
122+ onChange = { ( value ) => {
123+ props . form . setValue (
124+ "dropERC20Mode.saleTokenAddress" ,
125+ value . address ,
126+ ) ;
127+ } }
128+ selectedToken = { {
129+ address : props . form . watch (
130+ "dropERC20Mode.saleTokenAddress" ,
131+ ) ,
132+ chainId : Number ( props . chainId ) ,
133+ } }
134+ showCheck = { true }
135+ />
136+ </ div >
137+ </ FormFieldSetup >
138+ </ div >
139+
140+ < div className = "mt-5 relative border-t border-dashed pt-5" >
141+ < p className = "text-muted-foreground text-sm mb-3" >
142+ All primary sales are subjected to{ " " }
143+ < em className = "text-foreground font-medium not-italic" > 2.5%</ em > { " " }
144+ fee
145+ </ p >
107146
108- < TokenSelector
109- addNativeTokenIfMissing = { true }
110- chainId = { Number ( props . chainId ) }
111- className = "bg-background border-l-0 rounded-l-none"
112- client = { props . client }
113- disableAddress = { true }
114- popoverContentClassName = "!w-[320px]"
115- onChange = { ( value ) => {
116- props . form . setValue (
117- "dropERC20Mode.saleTokenAddress" ,
118- value . address ,
119- ) ;
120- } }
121- selectedToken = { {
122- address : props . form . watch ( "dropERC20Mode.saleTokenAddress" ) ,
123- chainId : Number ( props . chainId ) ,
124- } }
125- showCheck = { true }
147+ < div className = "relative" >
148+ < DistributionBarChart
149+ segments = { [
150+ {
151+ label : "Your Wallet" ,
152+ percent : recipientFee ,
153+ color : "hsl(var(--chart-1))" ,
154+ value : `${ recipientFee } %` ,
155+ } ,
156+ {
157+ label : "Protocol" ,
158+ percent : protocolFee ,
159+ color : "hsl(var(--chart-2))" ,
160+ value : `${ protocolFee } %` ,
161+ } ,
162+ {
163+ label : "Convenience Fee" ,
164+ percent : convenienceFee ,
165+ color : "hsl(var(--chart-3))" ,
166+ value : `${ convenienceFee } %` ,
167+ } ,
168+ ] }
126169 />
127170 </ div >
128- </ FormFieldSetup >
171+ </ div >
129172 </ div >
130173 ) }
131174 </ div >
0 commit comments