Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix loading state layout shift, revert old pr

Steven Tey99a5ae03418f
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
index 9e426f1274..84e9f33a8e 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
@@ -135,6 +135,7 @@ export function OnboardingForm({
<Controller
control={control}
name="image"
+ rules={{ required: true }}
render={({ field }) => (
<FileUpload
accept="images"
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx
index 641c20fb0a..85647fa28a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx
@@ -293,13 +293,13 @@ export function ProgramPartnerNetworkPageClient() {
}}
/>
))
- : [...Array(8)].map((_, idx) => <PartnerCard key={idx} />)}
+ : [...Array(12)].map((_, idx) => <PartnerCard key={idx} />)}
</div>
<div className="sticky bottom-0 mt-4 rounded-b-[inherit] border-t border-neutral-200 bg-white px-3.5 py-2">
<PaginationControls
pagination={pagination}
setPagination={setPagination}
- totalCount={partnerCounts?.[status] || 0}
+ totalCount={partnerCounts?.[status]}
unit={(p) => `partner${p ? "s" : ""}`}
/>
</div>
@@ -379,13 +379,16 @@ function PartnerCard({
? partner.categories.map((category) => ({
label: category.replace(/_/g, " "),
}))
- : null,
+ : undefined,
[partner],
);
return (
<div
- className={cn(partner?.id && "cursor-pointer hover:drop-shadow-sm")}
+ className={cn(
+ partner?.id &&
+ "hover:drop-shadow-card-hover cursor-pointer transition-[filter]",
+ )}
onClick={(e) => {
if (!partner?.id || isClickOnInteractiveChild(e)) return;
@@ -532,9 +535,7 @@ function PartnerCard({
</div>
{/* Categories */}
- {categoriesData && categoriesData.length > 0 && (
- <ListRow items={categoriesData} />
- )}
+ <ListRow items={categoriesData} />
</div>
</div>
</div>
diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.ts
index a00a9dc06f..e5a737d243 100644
--- a/apps/web/lib/actions/partners/onboard-partner.ts
+++ b/apps/web/lib/actions/partners/onboard-partner.ts
@@ -17,8 +17,7 @@ export const onboardPartnerAction = authUserActionClient
.schema(onboardPartnerSchema)
.action(async ({ ctx, parsedInput }) => {
const { user } = ctx;
- const { name, image, country, description, profileType, companyName } =
- parsedInput;
+ const { name, image, country, description, profileType } = parsedInput;
const existingPartner = await prisma.partner.findUnique({
where: {
@@ -30,14 +29,12 @@ export const onboardPartnerAction = authUserActionClient
? existingPartner.id
: createId({ prefix: "pn_" });
- const imageUrl = image
- ? await storage
- .upload({
- key: `partners/${partnerId}/image_${nanoid(7)}`,
- body: image,
- })
- .then(({ url }) => url)
- : null;
+ const imageUrl = await storage
+ .upload({
+ key: `partners/${partnerId}/image_${nanoid(7)}`,
+ body: image,
+ })
+ .then(({ url }) => url);
// country, profileType, and companyName cannot be changed once set
const payload: Prisma.PartnerCreateInput = {
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 416fd6c5c1..07a5e15fd8 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -520,19 +520,23 @@ export const createPartnerSchema = z.object({
// This is a temporary fix to allow arbitrary image URL
// TODO: Fix this by using file-type
-const partnerImageSchema = z.union([
- base64ImageSchema,
- storedR2ImageUrlSchema,
- publicHostedImageSchema,
- z
- .string()
- .url()
- .trim()
- .refine((url) => url.startsWith(GOOGLE_FAVICON_URL), {
- message: `Image URL must start with ${GOOGLE_FAVICON_URL}`,
- }),
- z.string().nullish(), // make image optional
-]);
+const partnerImageSchema = z
+ .union([
+ base64ImageSchema,
+ storedR2ImageUrlSchema,
+ publicHostedImageSchema,
+ z
+ .string()
+ .url()
+ .trim()
+ .refine((url) => url.startsWith(GOOGLE_FAVICON_URL), {
+ message: `Image URL must start with ${GOOGLE_FAVICON_URL}`,
+ }),
+ ])
+ .transform((v) => v || "")
+ .refine((v) => v !== "", {
+ message: "Image is required",
+ });
export const onboardPartnerSchema = createPartnerSchema
.omit({
diff --git a/packages/ui/src/filter/filter-select.tsx b/packages/ui/src/filter/filter-select.tsx
index 356abe9441..692bc9ab3d 100644
--- a/packages/ui/src/filter/filter-select.tsx
+++ b/packages/ui/src/filter/filter-select.tsx
@@ -189,7 +189,7 @@ export function FilterSelect({
selectedFilterKey ? reset() : setIsOpen(false);
}
}}
- emptySubmit={(e) => {
+ emptysubmit={(e) => {
e.preventDefault();
e.stopPropagation();
if (askAI) {
@@ -326,7 +326,7 @@ function isEmptyStateObject(
const CommandInput = (
props: React.ComponentProps<typeof Command.Input> & {
- emptySubmit?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
+ emptysubmit?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
},
) => {
const isEmpty = useCommandState((state) => state.filtered.count === 0);
@@ -339,7 +339,7 @@ const CommandInput = (
props.onKeyDown?.(e);
if (e.key === "Enter" && isEmpty) {
- props.emptySubmit?.(e);
+ props.emptysubmit?.(e);
}
}}
autoCapitalize="none"
diff --git a/packages/ui/src/pagination-controls.tsx b/packages/ui/src/pagination-controls.tsx
index a54fd57d7c..611775e7c1 100644
--- a/packages/ui/src/pagination-controls.tsx
+++ b/packages/ui/src/pagination-controls.tsx
@@ -19,7 +19,7 @@ export function PaginationControls({
}: PropsWithChildren<{
pagination: PaginationState;
setPagination: (pagination: PaginationState) => void;
- totalCount: number;
+ totalCount?: number;
unit?: string | ((plural: boolean) => string);
className?: string;
showTotalCount?: boolean;
@@ -33,28 +33,36 @@ export function PaginationControls({
>
<div className="flex items-center gap-2">
<div>
- <span className="hidden sm:inline-block">Viewing</span>{" "}
- {totalCount > 0 && (
+ {totalCount === undefined ? (
+ <div className="h-5 w-24 animate-pulse rounded-lg bg-neutral-200" />
+ ) : (
<>
- <span className="font-medium">
- {(
- (pagination.pageIndex - 1) * pagination.pageSize +
- 1
- ).toLocaleString()}
- -
- {Math.min(
- (pagination.pageIndex - 1) * pagination.pageSize +
- pagination.pageSize,
- totalCount,
- ).toLocaleString()}
- </span>{" "}
- {showTotalCount && "of "}
+ <span className="hidden sm:inline-block">Viewing</span>{" "}
+ {totalCount > 0 && (
+ <>
+ <span className="font-medium">
+ {(
+ (pagination.pageIndex - 1) * pagination.pageSize +
+ 1
+ ).toLocaleString()}
+ -
+ {Math.min(
+ (pagination.pageIndex - 1) * pagination.pageSize +
+ pagination.pageSize,
+ totalCount,
+ ).toLocaleString()}
+ </span>{" "}
+ {showTotalCount && "of "}
+ </>
+ )}
+ {showTotalCount && (
+ <span className="font-medium">
+ {totalCount.toLocaleString()}
+ </span>
+ )}{" "}
+ {typeof unit === "function" ? unit(totalCount !== 1) : unit}
</>
)}
- {showTotalCount && (
- <span className="font-medium">{totalCount.toLocaleString()}</span>
- )}{" "}
- {typeof unit === "function" ? unit(totalCount !== 1) : unit}
</div>
{children}
</div>
@@ -82,9 +90,10 @@ export function PaginationControls({
})
}
disabled={
+ !totalCount ||
(pagination.pageIndex - 1) * pagination.pageSize +
pagination.pageSize >=
- totalCount
+ totalCount
}
>
Next