Skip to content

Commit 6fc58cc

Browse files
committed
rearrange some stuff
1 parent 6c3800d commit 6fc58cc

File tree

2 files changed

+30
-61
lines changed

2 files changed

+30
-61
lines changed

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { deleteProgramInviteAction } from "@/lib/actions/partners/delete-program
44
import { resendProgramInviteAction } from "@/lib/actions/partners/resend-program-invite";
55
import { mutatePrefix } from "@/lib/swr/mutate";
66
import useGroups from "@/lib/swr/use-groups";
7-
import usePartner from "@/lib/swr/use-partner";
87
import usePartnersCount from "@/lib/swr/use-partners-count";
98
import useWorkspace from "@/lib/swr/use-workspace";
109
import { EnrolledPartnerProps } from "@/lib/types";
@@ -704,31 +703,3 @@ function MenuItem({
704703
</Command.Item>
705704
);
706705
}
707-
708-
/** Gets the current partner from the loaded partners array if available, or a separate fetch if not */
709-
function useCurrentPartner({
710-
partners,
711-
partnerId,
712-
}: {
713-
partners?: EnrolledPartnerProps[];
714-
partnerId: string | null;
715-
}) {
716-
let currentPartner = partnerId
717-
? partners?.find(({ id }) => id === partnerId)
718-
: null;
719-
720-
const { partner: fetchedPartner, loading: isLoading } = usePartner(
721-
{
722-
partnerId: partners && partnerId && !currentPartner ? partnerId : null,
723-
},
724-
{
725-
keepPreviousData: true,
726-
},
727-
);
728-
729-
if (!currentPartner && fetchedPartner?.id === partnerId) {
730-
currentPartner = fetchedPartner;
731-
}
732-
733-
return { currentPartner, isLoading };
734-
}

apps/web/ui/modals/add-discount-code-modal.tsx

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { mutatePrefix } from "@/lib/swr/mutate";
22
import { useApiMutation } from "@/lib/swr/use-api-mutation";
3-
import useWorkspace from "@/lib/swr/use-workspace";
43
import { DiscountCodeProps, EnrolledPartnerProps } from "@/lib/types";
54
import { createDiscountCodeSchema } from "@/lib/zod/schemas/discount";
65
import {
@@ -10,7 +9,6 @@ import {
109
ComboboxOption,
1110
Modal,
1211
useCopyToClipboard,
13-
useMediaQuery,
1412
} from "@dub/ui";
1513
import { cn, getPrettyUrl } from "@dub/utils";
1614
import { Tag } from "lucide-react";
@@ -36,11 +34,9 @@ const AddDiscountCodeModal = ({
3634
setShowModal,
3735
partner,
3836
}: AddDiscountCodeModalProps) => {
39-
const { stripeConnectId } = useWorkspace();
4037
const [search, setSearch] = useState("");
4138
const [isOpen, setIsOpen] = useState(false);
4239

43-
const { isMobile } = useMediaQuery();
4440
const formRef = useRef<HTMLFormElement>(null);
4541
const [debouncedSearch] = useDebounce(search, 500);
4642
const [, copyToClipboard] = useCopyToClipboard();
@@ -138,34 +134,6 @@ const AddDiscountCodeModal = ({
138134
</div>
139135

140136
<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-
169137
<div className="flex flex-col gap-2">
170138
<div className="flex items-center gap-2">
171139
<label
@@ -209,6 +177,36 @@ const AddDiscountCodeModal = ({
209177
onOpenChange={setIsOpen}
210178
onSearchChange={setSearch}
211179
/>
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>
212210
</div>
213211
</div>
214212
</div>

0 commit comments

Comments
 (0)