The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
WIP edit bounties
Tim Wilson934cf3aa93c2
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsxindex ec19afdb9d..c87f0d5beb 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx@@ -1,6 +1,10 @@import { mutatePrefix } from "@/lib/swr/mutate";import useWorkspace from "@/lib/swr/use-workspace";-import { BountyPerformanceLogic, BountyProps } from "@/lib/types";+import {+ BountyExtendedProps,+ BountyPerformanceLogic,+ BountyProps,+} from "@/lib/types";import {bountyPerformanceLogicSchema,createBountySchema,@@ -26,6 +30,7 @@ import {Sheet,SmartDateTimePicker,Switch,+ useRouterStuff,} from "@dub/ui";import { cn, currencyFormatter } from "@dub/utils";import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";@@ -40,6 +45,7 @@ import { z } from "zod";type BountySheetProps = {setIsOpen: Dispatch<SetStateAction<boolean>>;+ bounty?: BountyExtendedProps;};type FormData = z.infer<typeof createBountySchema>;@@ -68,7 +74,7 @@ const ACCORDION_ITEMS = ["groups",];-function BountySheetContent({ setIsOpen }: BountySheetProps) {+function BountySheetContent({ setIsOpen, bounty }: BountySheetProps) {const { id: workspaceId } = useWorkspace();const [hasEndDate, setHasEndDate] = useState(false);const [requireImage, setRequireImage] = useState(false);@@ -535,8 +541,15 @@ export function BountySheet({isOpen: boolean;nested?: boolean;}) {+ const { queryParams } = useRouterStuff();+return (- <Sheet open={isOpen} onOpenChange={rest.setIsOpen} nested={nested}>+ <Sheet+ open={isOpen}+ onOpenChange={rest.setIsOpen}+ onClose={() => queryParams({ del: "bountyId", scroll: false })}+ nested={nested}+ ><BountySheetContent {...rest} /></Sheet>);diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsxindex 019318dfd2..d32f872970 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx@@ -1,14 +1,15 @@import { BountyExtendedProps } from "@/lib/types";import { ProgramOverviewCard } from "@/ui/partners/overview/program-overview-card";-import { Button, MenuItem, Popover } from "@dub/ui";+import { Button, MenuItem, Popover, useRouterStuff } from "@dub/ui";import { CalendarDays, Dots, PenWriting, Users } from "@dub/ui/icons";import { formatDate } from "@dub/utils";import { Command } from "cmdk";import Link from "next/link";import { useState } from "react";-import { toast } from "sonner";export function BountyCard({ bounty }: { bounty: BountyExtendedProps }) {+ const { queryParams, searchParams } = useRouterStuff();+const [isMenuOpen, setIsMenuOpen] = useState(false);return (@@ -76,7 +77,7 @@ export function BountyCard({ bounty }: { bounty: BountyExtendedProps }) {icon={PenWriting}variant="default"onSelect={() => {- toast.info("WIP");+ queryParams({ set: { bountyId: bounty.id } });setIsMenuOpen(false);}}>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsxindex ca4edfb0ed..88fa31ad79 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx@@ -3,22 +3,34 @@import useWorkspace from "@/lib/swr/use-workspace";import { BountyExtendedProps } from "@/lib/types";import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";-import { Button } from "@dub/ui";+import { Button, useRouterStuff } from "@dub/ui";import { fetcher } from "@dub/utils";import { Trophy } from "lucide-react";+import { useEffect, useState } from "react";import useSWR from "swr";-import { useBountySheet } from "./add-edit-bounty-sheet";+import { BountySheet } from "./add-edit-bounty-sheet";import { BountyCard, BountyCardSkeleton } from "./bounty-card";// TODO:// Fix error stateexport function BountyList() {+ const { searchParams } = useRouterStuff();+const { id: workspaceId, defaultProgramId } = useWorkspace();- const { BountySheet, setShowCreateBountySheet } = useBountySheet({- nested: false,- });+ const [bountySheetState, setBountySheetState] = useState<+ { open: false; bountyId: string | null } | { open: true; bountyId: string }+ >({ open: false, bountyId: null });++ // Open/close edit bounty sheet+ useEffect(() => {+ const bountyId = searchParams.get("bountyId");+ console.log("bountyId", bountyId);+ setBountySheetState(+ bountyId ? { open: true, bountyId } : { open: false, bountyId: null },+ );+ }, [searchParams.get("bountyId")]);const {data: bounties,@@ -38,8 +50,22 @@ export function BountyList() {return <></>;}+ const currentBounty = bountySheetState.bountyId+ ? bounties?.find((b) => b?.id === bountySheetState.bountyId)+ : undefined;+return bounties?.length !== 0 || isLoading ? (<div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">+ {bountySheetState.open &&+ (!bountySheetState.bountyId || currentBounty) && (+ <BountySheet+ isOpen={bountySheetState.open}+ setIsOpen={(open) =>+ setBountySheetState((s) => ({ ...s, open }) as any)+ }+ bounty={currentBounty}+ />+ )}{isLoading? Array.from({ length: 3 }, (_, index) => (<BountyCardSkeleton key={index} />@@ -50,7 +76,6 @@ export function BountyList() {</div>) : (<>- {BountySheet}<AnimatedEmptyStatetitle="No bounties active"description={@@ -76,7 +101,11 @@ export function BountyList() {<Buttontext="Create bounty"variant="primary"- onClick={() => setShowCreateBountySheet(true)}+ onClick={() =>+ setBountySheetState(+ (s) => ({ bountyId: null, open: true }) as any,+ )+ }/>}/>