mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-19 08:28:10 +02:00
* docs: design spec for lead-gen surfaces (Credits & Billing, Hire-an-Expert, Top-up, Enterprise)
Add brainstorming spec for: sidebar OBSERVE→MANAGE rename + Credits & Billing
link + Hire-an-Expert footer button; new /billing page with extracted Dograh
Model Credits card + CTAs; Top-up / Hire-an-Expert / Enterprise intake modals
with inline math captcha; and a workflow-builder Hire-an-Expert nudge. Frontend
only; submissions fire PostHog events via a submitLead() seam for a future
MongoDB endpoint. Also gitignore .superpowers/ brainstorm mockups.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: implementation plan for user-onboarding lead-gen surfaces
14 bite-sized tasks: PostHog events, shared helpers (field options,
work-email blocklist, submitLead seam, math captcha), three intake modals
(enterprise/hire/top-up), LeadFormsProvider context, AppLayout mount, sidebar
MANAGE rename + Credits & Billing link + footer Hire button, extracted
DograhCreditsCard, /billing page, credits removal from Agent Runs, builder
nudge, and a full verification/dogfood pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): register PostHog events for lead-gen surfaces
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): shared field options, work-email validation, and submit seam
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): inline math captcha field
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): enterprise intake modal
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): hire-an-expert modal with enterprise link
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): top-up modal with >20k volume-pricing gate
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): shared lead-forms context provider
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): mount LeadFormsProvider in app layout
Wrap the sidebar branch of AppLayout with LeadFormsProvider so the shared
lead modals are available to the sidebar, billing card, and builder nudge.
Includes eslint import-order auto-fixes in TopUpModal and LeadFormsContext.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): rename OBSERVE to MANAGE, add Credits & Billing link and Hire-an-Expert footer button
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): extract DograhCreditsCard with top-up + hire CTAs
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): add Credits & Billing page
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(lead-gen): move Dograh Model Credits card out of Agent Runs to /billing
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(lead-gen): delayed Hire-an-Expert nudge on the workflow builder
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* ci(ui): add lint:lead-flow guard script
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(ui): restructure lead forms, self-serve Buy Credits, dialog blur
Revised lead-capture surfaces and credits bar:
- Dialog overlay gains backdrop blur (bg-black/60 backdrop-blur-sm).
- Shared primitives: LeadModalShell (icon/eyebrow header, scrollable body,
sticky footer, trust-line slot), PhoneField (react-international-phone,
dark, E.164 out), FormTrustLine ("Average response: under 10 minutes...").
- HireExpertModal: Name, Company, Job title, agent goal, Phone (required),
monthly volume. EnterpriseModal: + work email (required logged-out),
conditional deployment (yes/no/maybe, source-gated), agent goal.
OnboardingModal: drop useCase. Phone mandatory except onboarding.
- Volume buckets match the backend qualifier (0-5k/5k-100k/100k+/not-sure).
- Delete TopUpModal; DograhCreditsCard now self-serve Buy Credits (amount
chips $5/$10/$25/$50/$100 + custom min $5 → startTopUp seam) + Hire an
Expert + dashed custom-pricing link opening Enterprise (billing_custom_pricing).
- PostHog events: drop topup_*, add buy_credits_clicked,
buy_credits_amount_selected, custom_pricing_clicked. LeadFormsContext
drops topup; LeadKind/LeadSource updated.
- Introduce a single --cta warm accent token (CTAs + focus rings only).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(ui): split-screen auth + enterprise CTA + dark theme default
- AuthShell: dark two-column auth layout (brand/value panel with CSS-only
waveform motif + proof points + Bland-style enterprise CTA block on the
left, zinc-900 form card on the right; single-column on mobile).
- AuthEnterpriseCTA: "Talk to our team" → dograh.com/contact?intent=enterprise.
- stack-theme: dark StackTheme token overrides synced to globals.css.
- page.tsx: wrap StackHandler (non-fullPage) in AuthShell + StackTheme;
local-auth fallback preserved inside the shell. BackButton slimmed for the card.
- Dark locked as default: <html className="dark">, next-themes ThemeProvider
(defaultTheme="dark", enableSystem=false); inline no-FOUC script defaults dark.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* ui rezig, onboarding, billing, hire us & on prem cues
* ui changes
* chore: update comment
* chore: untrack docs/superpowers and gitignore it
* feat: refactor user configuration table
* feat(ui): 'check your email' confirmation on lead forms
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* added email and country in form submissions
* chore: update leads api
* fix: wrap dograh model config in card
---------
Co-authored-by: Pritesh <pritesh@dograh.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
255 lines
10 KiB
TypeScript
255 lines
10 KiB
TypeScript
'use client';
|
||
|
||
import {
|
||
Archive,
|
||
ChevronRight,
|
||
Folder as FolderIcon,
|
||
FolderOpen,
|
||
Inbox,
|
||
MoreVertical,
|
||
Pencil,
|
||
Trash2,
|
||
} from 'lucide-react';
|
||
import { useRouter } from 'next/navigation';
|
||
import { useState } from 'react';
|
||
import { toast } from 'sonner';
|
||
|
||
import {
|
||
deleteFolderApiV1FolderFolderIdDelete,
|
||
renameFolderApiV1FolderFolderIdPut,
|
||
} from '@/client/sdk.gen';
|
||
import type { FolderResponse, WorkflowListResponse } from '@/client/types.gen';
|
||
import {
|
||
AlertDialog,
|
||
AlertDialogAction,
|
||
AlertDialogCancel,
|
||
AlertDialogContent,
|
||
AlertDialogDescription,
|
||
AlertDialogFooter,
|
||
AlertDialogHeader,
|
||
AlertDialogTitle,
|
||
} from '@/components/ui/alert-dialog';
|
||
import { Badge } from '@/components/ui/badge';
|
||
import { Button } from '@/components/ui/button';
|
||
import {
|
||
Collapsible,
|
||
CollapsibleContent,
|
||
CollapsibleTrigger,
|
||
} from '@/components/ui/collapsible';
|
||
import {
|
||
DropdownMenu,
|
||
DropdownMenuContent,
|
||
DropdownMenuItem,
|
||
DropdownMenuTrigger,
|
||
} from '@/components/ui/dropdown-menu';
|
||
import logger from '@/lib/logger';
|
||
import { cn } from '@/lib/utils';
|
||
|
||
import { WorkflowTable } from '../WorkflowTable';
|
||
import { FolderFormDialog } from './FolderFormDialog';
|
||
|
||
/**
|
||
* - `folder` — a real, renameable/deletable folder of active agents
|
||
* - `uncategorized` — active agents with no folder
|
||
* - `archived` — archived agents (restore-only; not a move target)
|
||
*/
|
||
type SectionKind = 'folder' | 'uncategorized' | 'archived';
|
||
|
||
interface FolderSectionProps {
|
||
kind: SectionKind;
|
||
/** Required when kind === 'folder'; ignored otherwise. */
|
||
folder?: FolderResponse | null;
|
||
workflows: WorkflowListResponse[];
|
||
/** All folders, passed through so each row's "Move to folder" menu has targets. */
|
||
allFolders?: FolderResponse[];
|
||
/** Defaults to open only for Uncategorized; folders and Archived start collapsed. */
|
||
defaultOpen?: boolean;
|
||
}
|
||
|
||
export function FolderSection({
|
||
kind,
|
||
folder = null,
|
||
workflows,
|
||
allFolders = [],
|
||
defaultOpen,
|
||
}: FolderSectionProps) {
|
||
const router = useRouter();
|
||
const [open, setOpen] = useState(defaultOpen ?? kind === 'uncategorized');
|
||
const [isRenaming, setIsRenaming] = useState(false);
|
||
const [confirmDelete, setConfirmDelete] = useState(false);
|
||
const [isDeleting, setIsDeleting] = useState(false);
|
||
|
||
const isFolder = kind === 'folder';
|
||
const isArchived = kind === 'archived';
|
||
const count = workflows.length;
|
||
const title = isFolder ? (folder?.name ?? '') : isArchived ? 'Archived' : 'Uncategorized';
|
||
|
||
const handleRename = async (name: string) => {
|
||
if (!folder) return;
|
||
const response = await renameFolderApiV1FolderFolderIdPut({
|
||
path: { folder_id: folder.id },
|
||
body: { name },
|
||
});
|
||
if (response.error) {
|
||
const detail =
|
||
(response.error as { detail?: string })?.detail ??
|
||
'Failed to rename folder';
|
||
toast.error(detail);
|
||
throw new Error(detail);
|
||
}
|
||
toast.success('Folder renamed');
|
||
router.refresh();
|
||
};
|
||
|
||
const handleDelete = async () => {
|
||
if (!folder) return;
|
||
setIsDeleting(true);
|
||
try {
|
||
const response = await deleteFolderApiV1FolderFolderIdDelete({
|
||
path: { folder_id: folder.id },
|
||
});
|
||
if (response.error) {
|
||
throw new Error('Failed to delete folder');
|
||
}
|
||
toast.success(`Folder "${folder.name}" deleted`);
|
||
setConfirmDelete(false);
|
||
router.refresh();
|
||
} catch (err) {
|
||
logger.error(`Error deleting folder: ${err}`);
|
||
toast.error('Failed to delete folder');
|
||
} finally {
|
||
setIsDeleting(false);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<div className="mb-3">
|
||
<Collapsible open={open} onOpenChange={setOpen}>
|
||
<div className="flex items-center gap-1">
|
||
<CollapsibleTrigger asChild>
|
||
<button
|
||
className="group flex flex-1 items-center gap-2.5 rounded-md px-2 py-2 text-left transition-colors hover:bg-accent"
|
||
aria-label={`Toggle ${title}`}
|
||
>
|
||
<ChevronRight
|
||
size={16}
|
||
className={cn(
|
||
'shrink-0 text-muted-foreground transition-transform duration-200',
|
||
open && 'rotate-90',
|
||
)}
|
||
/>
|
||
{isFolder ? (
|
||
open ? (
|
||
<FolderOpen size={17} className="shrink-0 text-amber-500" />
|
||
) : (
|
||
<FolderIcon size={17} className="shrink-0 text-amber-500" />
|
||
)
|
||
) : isArchived ? (
|
||
<Archive size={16} className="shrink-0 text-muted-foreground" />
|
||
) : (
|
||
<Inbox size={17} className="shrink-0 text-muted-foreground" />
|
||
)}
|
||
<span
|
||
className={cn('font-medium', !isFolder && 'text-muted-foreground')}
|
||
>
|
||
{title}
|
||
</span>
|
||
<Badge variant="secondary" className="ml-1 font-normal">
|
||
{count}
|
||
</Badge>
|
||
</button>
|
||
</CollapsibleTrigger>
|
||
|
||
{isFolder && (
|
||
<DropdownMenu>
|
||
<DropdownMenuTrigger asChild>
|
||
<Button
|
||
variant="ghost"
|
||
size="icon"
|
||
className="h-8 w-8 text-muted-foreground"
|
||
aria-label="Folder actions"
|
||
>
|
||
<MoreVertical size={16} />
|
||
</Button>
|
||
</DropdownMenuTrigger>
|
||
<DropdownMenuContent align="end">
|
||
<DropdownMenuItem onClick={() => setIsRenaming(true)}>
|
||
<Pencil size={14} className="mr-2" />
|
||
Rename
|
||
</DropdownMenuItem>
|
||
<DropdownMenuItem
|
||
onClick={() => setConfirmDelete(true)}
|
||
className="text-destructive focus:text-destructive"
|
||
>
|
||
<Trash2 size={14} className="mr-2" />
|
||
Delete
|
||
</DropdownMenuItem>
|
||
</DropdownMenuContent>
|
||
</DropdownMenu>
|
||
)}
|
||
</div>
|
||
|
||
<CollapsibleContent className="data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-top-1">
|
||
<div className="pl-7 pt-2">
|
||
{count > 0 ? (
|
||
<WorkflowTable
|
||
workflows={workflows}
|
||
showArchived={isArchived}
|
||
// Archived agents are restore-only — not a move target.
|
||
folders={isArchived ? undefined : allFolders}
|
||
currentFolderId={folder?.id ?? null}
|
||
/>
|
||
) : (
|
||
<div className="rounded-lg border border-dashed bg-muted/30 p-6 text-center text-sm text-muted-foreground">
|
||
{isArchived
|
||
? 'No archived agents.'
|
||
: isFolder
|
||
? 'This folder is empty. Use “Move to folder” on an agent to add it here.'
|
||
: 'No uncategorized agents.'}
|
||
</div>
|
||
)}
|
||
</div>
|
||
</CollapsibleContent>
|
||
</Collapsible>
|
||
|
||
{isFolder && folder && (
|
||
<>
|
||
<FolderFormDialog
|
||
open={isRenaming}
|
||
onOpenChange={setIsRenaming}
|
||
title="Rename folder"
|
||
initialName={folder.name}
|
||
submitLabel="Rename"
|
||
onSubmit={handleRename}
|
||
/>
|
||
<AlertDialog open={confirmDelete} onOpenChange={setConfirmDelete}>
|
||
<AlertDialogContent>
|
||
<AlertDialogHeader>
|
||
<AlertDialogTitle>Delete “{folder.name}”?</AlertDialogTitle>
|
||
<AlertDialogDescription>
|
||
The {count} agent{count === 1 ? '' : 's'} in this folder
|
||
won’t be deleted - they’ll move to Uncategorized.
|
||
</AlertDialogDescription>
|
||
</AlertDialogHeader>
|
||
<AlertDialogFooter>
|
||
<AlertDialogCancel disabled={isDeleting}>
|
||
Cancel
|
||
</AlertDialogCancel>
|
||
<AlertDialogAction
|
||
onClick={(e) => {
|
||
e.preventDefault();
|
||
handleDelete();
|
||
}}
|
||
disabled={isDeleting}
|
||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||
>
|
||
{isDeleting ? 'Deleting...' : 'Delete folder'}
|
||
</AlertDialogAction>
|
||
</AlertDialogFooter>
|
||
</AlertDialogContent>
|
||
</AlertDialog>
|
||
</>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|