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.

improve bounty logic UI

Steven Tey3e5af5d6003a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
index 1e73ff202a..10c6ef1856 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
@@ -256,7 +256,6 @@ function BountySheetContent({ setIsOpen, bounty }: BountySheetProps) {
</div>
<BountyDuration
- isEditing={!!bounty}
value={bountyTimingValue}
onChange={handleTimingChange}
/>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-duration.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-duration.tsx
index d547ffaa38..113e2f751e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-duration.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-duration.tsx
@@ -23,6 +23,7 @@ import {
import { cn, formatDate } from "@dub/utils";
import { BountyStartMode } from "@prisma/client";
import { addDays, addMonths, addWeeks } from "date-fns";
+import { useParams } from "next/navigation";
import { ReactNode, useContext, useEffect, useState } from "react";
type PresetOption<T extends string> = { value: T; label: string };
@@ -388,14 +389,11 @@ function BountyDatePicker<T extends string>({
interface BountyDurationProps {
value: BountyTimingInput;
onChange: (value: BountyTimingInput) => void;
- isEditing?: boolean;
}
-export function BountyDuration({
- value,
- onChange,
- isEditing = false,
-}: BountyDurationProps) {
+export function BountyDuration({ value, onChange }: BountyDurationProps) {
+ const { bountyId } = useParams();
+ const isEditing = !!bountyId;
const initialPresets = parsePresetsFromValue(value, isEditing);
const [startPreset, setStartPreset] = useState<StartPreset>(
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-logic.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-logic.tsx
index 7c16729f27..b4daf32fec 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-logic.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-logic.tsx
@@ -10,9 +10,11 @@ import {
InlineBadgePopover,
InlineBadgePopoverMenu,
} from "@/ui/shared/inline-badge-popover";
+import { DynamicTooltipWrapper } from "@dub/ui";
import { Trophy } from "@dub/ui/icons";
import { cn, currencyFormatter, nFormatter } from "@dub/utils";
import { BountyStartMode } from "@prisma/client";
+import { useParams } from "next/navigation";
import { Controller } from "react-hook-form";
import { BountyAmountInput } from "./bounty-amount-input";
import { useBountyFormContext } from "./bounty-form-context";
@@ -23,6 +25,9 @@ const PERFORMANCE_SCOPE_DESCRIPTIONS = {
} as const;
export function BountyLogic({ className }: { className?: string }) {
+ const { bountyId } = useParams();
+ const isEditing = !!bountyId;
+
const { control, watch } = useBountyFormContext();
const [attribute, value, startMode] = watch([
@@ -45,31 +50,45 @@ export function BountyLogic({ className }: { className?: string }) {
control={control}
name="performanceScope"
render={({ field }) => (
- <InlineBadgePopover
- text={field.value}
- invalid={!field.value}
- align="center"
+ <DynamicTooltipWrapper
+ tooltipProps={
+ isEditing
+ ? {
+ content:
+ "Performance scope cannot be changed after bounty creation.",
+ }
+ : undefined
+ }
>
- <InlineBadgePopoverMenu
- selectedValue={field.value}
- onSelect={field.onChange}
- items={[
- {
- text: "new",
- value: "new",
- description: PERFORMANCE_SCOPE_DESCRIPTIONS.new,
- },
- {
- text: isRelative
- ? "lifetime (not available)"
- : "lifetime",
- value: "lifetime",
- description: `${PERFORMANCE_SCOPE_DESCRIPTIONS.lifetime}${isRelative ? " (not available for relative start dates)" : ""}`,
- disabled: isRelative,
- },
- ]}
- />
- </InlineBadgePopover>
+ <span>
+ <InlineBadgePopover
+ text={field.value}
+ invalid={!field.value}
+ align="center"
+ disabled={isEditing}
+ >
+ <InlineBadgePopoverMenu
+ selectedValue={field.value}
+ onSelect={field.onChange}
+ items={[
+ {
+ text: "new",
+ value: "new",
+ description: PERFORMANCE_SCOPE_DESCRIPTIONS.new,
+ },
+ {
+ text: isRelative
+ ? "lifetime (not available)"
+ : "lifetime",
+ value: "lifetime",
+ description: `${PERFORMANCE_SCOPE_DESCRIPTIONS.lifetime}${isRelative ? " (not available for relative start dates)" : ""}`,
+ disabled: isRelative,
+ },
+ ]}
+ />
+ </InlineBadgePopover>
+ </span>
+ </DynamicTooltipWrapper>
)}
/>
<Controller