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.

advanced settings

Pedro Ladeirad9d8c34ac720
diff --git a/apps/web/ui/partners/groups/design/lander/modals/earnings-calculator-block-modal.tsx b/apps/web/ui/partners/groups/design/lander/modals/earnings-calculator-block-modal.tsx
index cc62dd5eba..92d13eb6d3 100644
--- a/apps/web/ui/partners/groups/design/lander/modals/earnings-calculator-block-modal.tsx
+++ b/apps/web/ui/partners/groups/design/lander/modals/earnings-calculator-block-modal.tsx
@@ -4,6 +4,7 @@ import useGroup from "@/lib/swr/use-group";
import useWorkspace from "@/lib/swr/use-workspace";
import { programLanderEarningsCalculatorBlockSchema } from "@/lib/zod/schemas/program-lander";
import {
+ AnimatedSizeContainer,
Button,
Modal,
ToggleGroup,
@@ -11,8 +12,10 @@ import {
useScrollProgress,
} from "@dub/ui";
import { cn } from "@dub/utils";
+import { ChevronDown } from "lucide-react";
+import { motion } from "motion/react";
import Link from "next/link";
-import { Dispatch, SetStateAction, useId, useRef } from "react";
+import { Dispatch, SetStateAction, useId, useRef, useState } from "react";
import type { Control } from "react-hook-form";
import { Controller, useForm, useWatch } from "react-hook-form";
import * as z from "zod/v4";
@@ -51,6 +54,10 @@ function EarningsCalculatorBlockModalInner({
const { slug: workspaceSlug } = useWorkspace();
+ const [showAdvancedSettings, setShowAdvancedSettings] = useState(
+ () => defaultValues?.minSales != null || defaultValues?.maxSales != null,
+ );
+
const {
handleSubmit,
register,
@@ -158,96 +165,125 @@ function EarningsCalculatorBlockModalInner({
</div>
</div>
- <div>
- <label className="text-sm font-medium text-neutral-700">
- Sales range
- </label>
-
- <div className="mt-2 flex items-end gap-2">
- <div
- className={cn(
- "border-subtle flex h-10 min-w-0 flex-1 items-stretch overflow-hidden rounded-lg border bg-white",
- "transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none",
- "focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",
- errors.minSales &&
- "border-red-600 focus-within:border-red-500 focus-within:ring-red-200",
- )}
+ <div className="flex flex-col">
+ <button
+ type="button"
+ className="flex w-full items-center gap-2"
+ onClick={() =>
+ setShowAdvancedSettings(!showAdvancedSettings)
+ }
+ >
+ <p className="text-sm text-neutral-600">
+ {showAdvancedSettings ? "Hide" : "Show"} advanced settings
+ </p>
+ <motion.div
+ animate={{ rotate: showAdvancedSettings ? 180 : 0 }}
+ className="text-neutral-600"
>
- <input
- id={`${id}-min-sales`}
- type="text"
- inputMode="numeric"
- autoComplete="off"
- aria-label="Minimum sales"
- placeholder="No min"
- className="min-w-0 flex-1 border-0 bg-transparent px-3 py-1 text-sm text-neutral-900 outline-none placeholder:text-neutral-400 focus:ring-0"
- {...register("minSales", {
- setValueAs: (v) => {
- if (v === "" || v == null) return undefined;
- const n = Number.parseInt(
- String(v).replace(/\D/g, ""),
- 10,
- );
- return Number.isFinite(n) ? n : undefined;
- },
- min: 1,
- validate: (value, formValues) => {
- if (value == null || formValues.maxSales == null) {
- return true;
- }
- return (
- value <= formValues.maxSales ||
- "Must be less than or equal to max sales"
- );
- },
- })}
- />
- </div>
+ <ChevronDown className="size-4" />
+ </motion.div>
+ </button>
- <span className="shrink-0 pb-2.5 text-xs text-neutral-500">
- to
- </span>
+ <AnimatedSizeContainer height className="flex flex-col">
+ {showAdvancedSettings && (
+ <div className="mt-2">
+ <label className="text-sm font-medium text-neutral-700">
+ Sales range
+ </label>
+ <div className="mt-2 flex items-end gap-2">
+ <div
+ className={cn(
+ "border-subtle flex h-10 min-w-0 flex-1 items-stretch overflow-hidden rounded-lg border bg-white",
+ "transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none",
+ "focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",
+ errors.minSales &&
+ "border-red-600 focus-within:border-red-500 focus-within:ring-red-200",
+ )}
+ >
+ <input
+ id={`${id}-min-sales`}
+ type="text"
+ inputMode="numeric"
+ autoComplete="off"
+ aria-label="Minimum sales"
+ placeholder="No min"
+ className="min-w-0 flex-1 border-0 bg-transparent px-3 py-1 text-sm text-neutral-900 outline-none placeholder:text-neutral-400 focus:ring-0"
+ {...register("minSales", {
+ setValueAs: (v) => {
+ if (v === "" || v == null) return undefined;
+ const n = Number.parseInt(
+ String(v).replace(/\D/g, ""),
+ 10,
+ );
+ return Number.isFinite(n) ? n : undefined;
+ },
+ min: 1,
+ validate: (value, formValues) => {
+ if (
+ value == null ||
+ formValues.maxSales == null
+ ) {
+ return true;
+ }
+ return (
+ value <= formValues.maxSales ||
+ "Must be less than or equal to max sales"
+ );
+ },
+ })}
+ />
+ </div>
- <div
- className={cn(
- "border-subtle flex h-10 min-w-0 flex-1 items-stretch overflow-hidden rounded-lg border bg-white",
- "transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none",
- "focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",
- errors.maxSales &&
- "border-red-600 focus-within:border-red-500 focus-within:ring-red-200",
- )}
- >
- <input
- id={`${id}-max-sales`}
- type="text"
- inputMode="numeric"
- autoComplete="off"
- aria-label="Maximum sales"
- placeholder="No max"
- className="min-w-0 flex-1 border-0 bg-transparent px-3 py-1 text-sm text-neutral-900 outline-none placeholder:text-neutral-400 focus:ring-0"
- {...register("maxSales", {
- setValueAs: (v) => {
- if (v === "" || v == null) return undefined;
- const n = Number.parseInt(
- String(v).replace(/\D/g, ""),
- 10,
- );
- return Number.isFinite(n) ? n : undefined;
- },
- min: 1,
- validate: (value, formValues) => {
- if (value == null || formValues.minSales == null) {
- return true;
- }
- return (
- value >= formValues.minSales ||
- "Must be greater than or equal to min sales"
- );
- },
- })}
- />
- </div>
- </div>
+ <span className="shrink-0 pb-2.5 text-xs text-neutral-500">
+ to
+ </span>
+
+ <div
+ className={cn(
+ "border-subtle flex h-10 min-w-0 flex-1 items-stretch overflow-hidden rounded-lg border bg-white",
+ "transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none",
+ "focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",
+ errors.maxSales &&
+ "border-red-600 focus-within:border-red-500 focus-within:ring-red-200",
+ )}
+ >
+ <input
+ id={`${id}-max-sales`}
+ type="text"
+ inputMode="numeric"
+ autoComplete="off"
+ aria-label="Maximum sales"
+ placeholder="No max"
+ className="min-w-0 flex-1 border-0 bg-transparent px-3 py-1 text-sm text-neutral-900 outline-none placeholder:text-neutral-400 focus:ring-0"
+ {...register("maxSales", {
+ setValueAs: (v) => {
+ if (v === "" || v == null) return undefined;
+ const n = Number.parseInt(
+ String(v).replace(/\D/g, ""),
+ 10,
+ );
+ return Number.isFinite(n) ? n : undefined;
+ },
+ min: 1,
+ validate: (value, formValues) => {
+ if (
+ value == null ||
+ formValues.minSales == null
+ ) {
+ return true;
+ }
+ return (
+ value >= formValues.minSales ||
+ "Must be greater than or equal to min sales"
+ );
+ },
+ })}
+ />
+ </div>
+ </div>
+ </div>
+ )}
+ </AnimatedSizeContainer>
</div>
<div className="flex flex-col gap-2.5">