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.

Update ab-testing-modal.tsx

Tim Wilsond471b788b714
diff --git a/apps/web/ui/modals/link-builder/ab-testing-modal.tsx b/apps/web/ui/modals/link-builder/ab-testing-modal.tsx
index 891aa1f02a..7866cdb76d 100644
--- a/apps/web/ui/modals/link-builder/ab-testing-modal.tsx
+++ b/apps/web/ui/modals/link-builder/ab-testing-modal.tsx
@@ -23,6 +23,7 @@ import {
isValidUrl,
parseDateTime,
} from "@dub/utils";
+import { differenceInDays } from "date-fns";
import {
Dispatch,
SetStateAction,
@@ -88,6 +89,7 @@ function ABTestingModal({
});
const tests = watch("tests") || [];
+ const testsCompleteAt = watch("testsCompleteAt");
const testsParent = watchParent("tests");
const addTestUrl = () => {
@@ -459,7 +461,16 @@ function ABTestingModal({
: "Start testing"
}
className="h-9 w-fit"
- disabled={!isDirty || !isValid}
+ disabled={
+ !isDirty ||
+ !isValid ||
+ Boolean(
+ testsCompleteAt &&
+ // Restrict competion date from -1 days to 6 weeks
+ (differenceInDays(testsCompleteAt, new Date()) > 6 * 7 ||
+ differenceInDays(testsCompleteAt, new Date()) < -1),
+ )
+ }
/>
</div>
</div>