1
1
import { mutatePrefix } from "@/lib/swr/mutate" ;
2
2
import { useApiMutation } from "@/lib/swr/use-api-mutation" ;
3
- import useWorkspace from "@/lib/swr/use-workspace" ;
4
3
import { DiscountCodeProps , EnrolledPartnerProps } from "@/lib/types" ;
5
4
import { createDiscountCodeSchema } from "@/lib/zod/schemas/discount" ;
6
5
import {
@@ -10,7 +9,6 @@ import {
10
9
ComboboxOption ,
11
10
Modal ,
12
11
useCopyToClipboard ,
13
- useMediaQuery ,
14
12
} from "@dub/ui" ;
15
13
import { cn , getPrettyUrl } from "@dub/utils" ;
16
14
import { Tag } from "lucide-react" ;
@@ -36,11 +34,9 @@ const AddDiscountCodeModal = ({
36
34
setShowModal,
37
35
partner,
38
36
} : AddDiscountCodeModalProps ) => {
39
- const { stripeConnectId } = useWorkspace ( ) ;
40
37
const [ search , setSearch ] = useState ( "" ) ;
41
38
const [ isOpen , setIsOpen ] = useState ( false ) ;
42
39
43
- const { isMobile } = useMediaQuery ( ) ;
44
40
const formRef = useRef < HTMLFormElement > ( null ) ;
45
41
const [ debouncedSearch ] = useDebounce ( search , 500 ) ;
46
42
const [ , copyToClipboard ] = useCopyToClipboard ( ) ;
@@ -138,34 +134,6 @@ const AddDiscountCodeModal = ({
138
134
</ div >
139
135
140
136
< div className = "flex w-full flex-col gap-6" >
141
- < div className = "flex flex-col gap-2" >
142
- < div className = "flex items-center gap-2" >
143
- < label
144
- htmlFor = "code"
145
- className = "block text-sm font-medium text-neutral-700"
146
- >
147
- Discount code
148
- </ label >
149
- </ div >
150
-
151
- < div className = "relative" >
152
- < div className = "absolute inset-y-0 left-0 flex items-center pl-3" >
153
- < Tag className = "text-content-default h-4 w-4" />
154
- </ div >
155
- < input
156
- { ...register ( "code" ) }
157
- type = "text"
158
- id = "code"
159
- autoFocus = { ! isMobile }
160
- className = "block w-full rounded-md border-[1.5px] border-neutral-300 pl-10 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
161
- placeholder = "CODE"
162
- />
163
- </ div >
164
- < p className = "text-xs text-neutral-500" >
165
- Discount codes cannot be edited after creation
166
- </ p >
167
- </ div >
168
-
169
137
< div className = "flex flex-col gap-2" >
170
138
< div className = "flex items-center gap-2" >
171
139
< label
@@ -209,6 +177,36 @@ const AddDiscountCodeModal = ({
209
177
onOpenChange = { setIsOpen }
210
178
onSearchChange = { setSearch }
211
179
/>
180
+ < p className = "text-xs text-neutral-500" >
181
+ Choose a referral link to associate the discount code with
182
+ </ p >
183
+ </ div >
184
+
185
+ < div className = "flex flex-col gap-2" >
186
+ < div className = "flex items-center gap-2" >
187
+ < label
188
+ htmlFor = "code"
189
+ className = "block text-sm font-medium text-neutral-700"
190
+ >
191
+ Discount code
192
+ </ label >
193
+ </ div >
194
+
195
+ < div className = "relative" >
196
+ < div className = "absolute inset-y-0 left-0 flex items-center pl-3" >
197
+ < Tag className = "text-content-default h-4 w-4" />
198
+ </ div >
199
+ < input
200
+ { ...register ( "code" ) }
201
+ type = "text"
202
+ id = "code"
203
+ className = "block w-full rounded-md border-[1.5px] border-neutral-300 pl-10 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
204
+ placeholder = { partner . name . split ( " " ) [ 0 ] . toUpperCase ( ) }
205
+ />
206
+ </ div >
207
+ < p className = "text-xs text-neutral-500" >
208
+ Discount codes cannot be edited after creation
209
+ </ p >
212
210
</ div >
213
211
</ div >
214
212
</ div >
0 commit comments