The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add create group sheet
Kiran K897fe6011a95
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-button.tsxnew file mode 100644index 0000000000..17a8089a5e--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-button.tsx@@ -0,0 +1,25 @@+"use client";++import { Button, useKeyboardShortcut } from "@dub/ui";+import { useCreateGroupSheet } from "./create-group-sheet";++export function CreateGroupButton() {+ const { createGroupSheet, setIsOpen: setShowCreateGroupSheet } =+ useCreateGroupSheet({+ nested: false,+ });++ useKeyboardShortcut("c", () => setShowCreateGroupSheet(true));++ return (+ <>+ {createGroupSheet}+ <Button+ type="button"+ onClick={() => setShowCreateGroupSheet(true)}+ text="Create group"+ shortcut="C"+ />+ </>+ );+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-sheet.tsxnew file mode 100644index 0000000000..5516d20bc4--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/create-group-sheet.tsx@@ -0,0 +1,144 @@+import useWorkspace from "@/lib/swr/use-workspace";+import { createGroupSchema } from "@/lib/zod/schemas/groups";+import { X } from "@/ui/shared/icons";+import { Button, Sheet } from "@dub/ui";+import { cn } from "@dub/utils";+import { Dispatch, SetStateAction, useState } from "react";+import { useForm } from "react-hook-form";+import { toast } from "sonner";+import { z } from "zod";++interface CreateGroupSheetProps {+ setIsOpen: Dispatch<SetStateAction<boolean>>;+}++type FormData = z.input<typeof createGroupSchema>;++function CreateGroupSheetContent({ setIsOpen }: CreateGroupSheetProps) {+ const { id: workspaceId } = useWorkspace();+ const [isSubmitting, setIsSubmitting] = useState(false);++ const {+ register,+ handleSubmit,+ watch,+ formState: { errors },+ } = useForm<FormData>();++ const [name] = watch(["name"]);++ const onSubmit = async (data: FormData) => {+ if (!workspaceId) {+ return;+ }++ setIsSubmitting(true);++ console.log(data);++ toast.success("Group created successfully!");+ setIsOpen(false);+ setIsSubmitting(false);+ };++ return (+ <form onSubmit={handleSubmit(onSubmit)} className="flex h-full flex-col">+ <div className="sticky top-0 z-10 border-b border-neutral-200 bg-white">+ <div className="flex h-16 items-center justify-between px-6 py-4">+ <Sheet.Title className="text-lg font-semibold">+ Create group+ </Sheet.Title>+ <Sheet.Close asChild>+ <Button+ variant="outline"+ icon={<X className="size-5" />}+ className="h-auto w-fit p-1"+ />+ </Sheet.Close>+ </div>+ </div>++ <div className="flex-1 overflow-y-auto">+ <div className="space-y-6 p-6">+ <div>+ <label+ htmlFor="name"+ className="text-sm font-medium text-neutral-800"+ >+ Group name+ </label>+ <div className="mt-2">+ <input+ type="text"+ id="name"+ className={cn(+ "block w-full rounded-md border-neutral-300 px-3 py-2 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",+ errors.name &&+ "border-red-600 focus:border-red-500 focus:ring-red-600",+ )}+ {...register("name", {+ required: "Group name is required",+ })}+ placeholder="Enter group name"+ />+ {errors.name && (+ <p className="mt-1 text-sm text-red-600">+ {errors.name.message}+ </p>+ )}+ </div>+ </div>+ </div>+ </div>++ <div className="sticky bottom-0 z-10 border-t border-neutral-200 bg-white">+ <div className="flex items-center justify-end gap-2 p-5">+ <Button+ type="button"+ variant="secondary"+ onClick={() => setIsOpen(false)}+ text="Cancel"+ className="w-fit"+ disabled={isSubmitting}+ />++ <Button+ type="submit"+ variant="primary"+ text="Create group"+ className="w-fit"+ loading={isSubmitting}+ />+ </div>+ </div>+ </form>+ );+}++export function CreateGroupSheet({+ isOpen,+ nested,+ ...rest+}: CreateGroupSheetProps & {+ isOpen: boolean;+ nested?: boolean;+}) {+ return (+ <Sheet open={isOpen} onOpenChange={rest.setIsOpen} nested={nested}>+ <CreateGroupSheetContent {...rest} />+ </Sheet>+ );+}++export function useCreateGroupSheet(+ props: { nested?: boolean } & Omit<CreateGroupSheetProps, "setIsOpen">,+) {+ const [isOpen, setIsOpen] = useState(false);++ return {+ createGroupSheet: (+ <CreateGroupSheet setIsOpen={setIsOpen} isOpen={isOpen} {...props} />+ ),+ setIsOpen,+ };+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page-client.tsxnew file mode 100644index 0000000000..7b401ca913--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page-client.tsx@@ -0,0 +1,3 @@+export function ProgramPartnersGroupsPageClient() {+ return <div>ProgramPartnersGroupsPageClient</div>;+}\ No newline at end of filediff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page.tsxnew file mode 100644index 0000000000..2223298847--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/groups/page.tsx@@ -0,0 +1,22 @@+import { PageContent } from "@/ui/layout/page-content";+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";+import { CreateGroupButton } from "./create-group-button";+import { ProgramPartnersGroupsPageClient } from "./page-client";++export default function ProgramPartnersGroups() {+ return (+ <PageContent+ title="Groups"+ titleInfo={{+ title:+ "Understand how all your partners are performing and contributing to the success of your partner program.",+ href: "https://dub.co/help/article/managing-program-partners",+ }}+ controls={<CreateGroupButton />}+ >+ <PageWidthWrapper>+ <ProgramPartnersGroupsPageClient />+ </PageWidthWrapper>+ </PageContent>+ );+}diff --git a/apps/web/lib/api/create-id.ts b/apps/web/lib/api/create-id.tsindex 006d651ea9..8a2c15f10a 100644--- a/apps/web/lib/api/create-id.ts+++ b/apps/web/lib/api/create-id.ts@@ -28,6 +28,7 @@ const prefixes = ["dub_embed_","audit_","import_",+ "grp_",] as const;// ULID uses base32 encodingdiff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 32828f8cca..2afb858344 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -512,4 +512,4 @@ export type RewardConditionsArray = z.infer<typeof rewardConditionsArraySchema>;export type ClickEventTB = z.infer<typeof clickEventSchemaTB>;-export type LeadEventTB = z.infer<typeof leadEventSchemaTB>;+export type LeadEventTB = z.infer<typeof leadEventSchemaTB>;\ No newline at end of filediff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex c81e8ef152..e4af999453 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -27,6 +27,7 @@ import {Sliders,Tag,UserCheck,+ Users,Users2,Users6,Webhook,@@ -220,6 +221,12 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {: applicationsCount: undefined,},+ {+ name: "Groups",+ icon: Users,+ href: `/${slug}/program/partners/groups`,+ exact: true,+ },],},{