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.

final changes

Steven Tey988f885db586
diff --git a/apps/web/lib/swr/use-payouts-count.ts b/apps/web/lib/swr/use-payouts-count.ts
index 1856428310..3e745a297a 100644
--- a/apps/web/lib/swr/use-payouts-count.ts
+++ b/apps/web/lib/swr/use-payouts-count.ts
@@ -7,7 +7,9 @@ import { payoutsCountQuerySchema } from "../zod/schemas/payouts";
import useWorkspace from "./use-workspace";
export default function usePayoutsCount<T>(
- opts?: z.input<typeof payoutsCountQuerySchema>,
+ opts: z.input<typeof payoutsCountQuerySchema> & { enabled?: boolean } = {
+ enabled: true,
+ },
) {
const { id: workspaceId, defaultProgramId } = useWorkspace();
const { getQueryString } = useRouterStuff();
@@ -15,6 +17,7 @@ export default function usePayoutsCount<T>(
const { data: payoutsCount, error } = useSWR<PayoutsCount[]>(
workspaceId &&
defaultProgramId &&
+ opts.enabled &&
`/api/programs/${defaultProgramId}/payouts/count${getQueryString(
{
...opts,
diff --git a/apps/web/lib/zod/schemas/domains.ts b/apps/web/lib/zod/schemas/domains.ts
index 1e2fd5a0c6..fff3d623fa 100644
--- a/apps/web/lib/zod/schemas/domains.ts
+++ b/apps/web/lib/zod/schemas/domains.ts
@@ -5,7 +5,7 @@ import {
getPaginationQuerySchema,
uploadedImageSchema,
} from "./misc";
-import { parseJsonSchema, parseUrlSchemaAllowEmpty } from "./utils";
+import { parseUrlSchemaAllowEmpty } from "./utils";
export const RegisteredDomainSchema = z.object({
id: z.string().describe("The ID of the registered domain record."),
@@ -154,19 +154,19 @@ export const createDomainBodySchema = z.object({
.openapi({ example: "https://dub.co/help/article/what-is-dub" }),
logo: uploadedImageSchema.nullish().describe("The logo of the domain."),
assetLinks: z
- .preprocess(parseJsonSchema, z.string())
+ .string()
.nullish()
.describe(
"assetLinks.json configuration file (for deep link support on Android).",
),
appleAppSiteAssociation: z
- .preprocess(parseJsonSchema, z.string())
+ .string()
.nullish()
.describe(
"apple-app-site-association configuration file (for deep link support on iOS).",
),
deepviewData: z
- .preprocess(parseJsonSchema, z.string())
+ .string()
.nullish()
.describe("The deepview data of the domain."),
});
diff --git a/apps/web/lib/zod/schemas/utils.ts b/apps/web/lib/zod/schemas/utils.ts
index 69f1489484..f8d783dec5 100644
--- a/apps/web/lib/zod/schemas/utils.ts
+++ b/apps/web/lib/zod/schemas/utils.ts
@@ -1,6 +1,5 @@
import z from "@/lib/zod";
import { getUrlFromString, isValidUrl, parseDateTime } from "@dub/utils";
-import { ZodIssueCode } from "zod";
export const parseUrlSchema = z
.string()
@@ -33,18 +32,3 @@ export const parseDateSchema = z
.string()
.transform((v) => parseDateTime(v))
.refine((v) => !!v, { message: "Invalid date" });
-
-export const parseJsonSchema = (value: any, ctx: z.RefinementCtx) => {
- if (typeof value === "string") {
- try {
- return JSON.parse(value);
- } catch (e) {
- ctx.addIssue({
- code: ZodIssueCode.custom,
- message: (e as Error).message,
- });
- }
- }
-
- return value;
-};
diff --git a/apps/web/tests/domains/index.test.ts b/apps/web/tests/domains/index.test.ts
index a5178359f7..52645490de 100644
--- a/apps/web/tests/domains/index.test.ts
+++ b/apps/web/tests/domains/index.test.ts
@@ -29,6 +29,7 @@ const expectedDomain = {
logo: null,
appleAppSiteAssociation: null,
assetLinks: null,
+ deepviewData: "{}",
};
describe.sequential("/domains/**", async () => {
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index ca3dcbac29..f10c13d439 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -464,6 +464,7 @@ export function AppSidebarNav({
>({
eligibility: "eligible",
status: "pending",
+ enabled: Boolean(currentArea === "program" && defaultProgramId),
});
const applicationsCount = useProgramApplicationsCount({