Skip to content

Commit be2952d

Browse files
committed
cleanup dialogs
1 parent 5df4148 commit be2952d

File tree

11 files changed

+110
-191
lines changed

11 files changed

+110
-191
lines changed

apps/dashboard/app/(main)/organizations/components/general-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function GeneralSettings({
105105
/>
106106
<p className="text-muted-foreground text-xs">
107107
Used in URLs:{" "}
108-
<code className="rounded bg-muted px-1 py-0.5 text-xs">
108+
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-foreground text-xs">
109109
/{slug}
110110
</code>
111111
</p>

apps/dashboard/app/(main)/organizations/invitations/invitation-list.tsx

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@ import { EnvelopeIcon, TrashIcon } from "@phosphor-icons/react";
44
import dayjs from "dayjs";
55
import relativeTime from "dayjs/plugin/relativeTime";
66
import { useState } from "react";
7-
import {
8-
AlertDialog,
9-
AlertDialogAction,
10-
AlertDialogCancel,
11-
AlertDialogContent,
12-
AlertDialogDescription,
13-
AlertDialogFooter,
14-
AlertDialogHeader,
15-
AlertDialogTitle,
16-
} from "@/components/ui/alert-dialog";
177
import { Badge } from "@/components/ui/badge";
188
import { Button } from "@/components/ui/button";
9+
import { DeleteDialog } from "@/components/ui/delete-dialog";
1910
import type { CancelInvitation, Invitation } from "@/hooks/use-organizations";
11+
import { cn } from "@/lib/utils";
2012

2113
dayjs.extend(relativeTime);
2214

@@ -25,17 +17,21 @@ type InvitationToCancel = {
2517
email: string;
2618
};
2719

28-
interface InvitationRowProps {
20+
type InvitationRowProps = {
2921
invitation: Invitation;
3022
isCancellingInvitation: boolean;
3123
onConfirmCancel: (inv: InvitationToCancel) => void;
32-
}
24+
};
3325

3426
function InvitationRow({
3527
invitation,
3628
isCancellingInvitation,
3729
onConfirmCancel,
3830
}: InvitationRowProps) {
31+
const isExpired =
32+
invitation.status === "pending" &&
33+
dayjs(invitation.expiresAt).isBefore(dayjs());
34+
3935
const isPending =
4036
invitation.status === "pending" &&
4137
dayjs(invitation.expiresAt).isAfter(dayjs());
@@ -51,13 +47,15 @@ function InvitationRow({
5147
},
5248
expired: {
5349
label: "Expired",
54-
className: "border-muted bg-muted text-muted-foreground",
50+
className: "border-secondary bg-secondary text-secondary-foreground",
5551
},
5652
};
5753

58-
const status =
59-
statusConfig[invitation.status as keyof typeof statusConfig] ??
60-
statusConfig.expired;
54+
const actualStatus = isExpired
55+
? "expired"
56+
: ((invitation.status as keyof typeof statusConfig) ?? "expired");
57+
58+
const status = statusConfig[actualStatus] ?? statusConfig.expired;
6159

6260
return (
6361
<div className="grid grid-cols-[auto_1fr_auto_auto] items-center gap-4 px-5 py-4">
@@ -69,12 +67,12 @@ function InvitationRow({
6967
<p className="truncate font-medium">{invitation.email}</p>
7068
<p className="truncate text-muted-foreground text-sm">
7169
{invitation.role ?? "member"} ·{" "}
72-
{invitation.status === "pending" ? "Expires" : "Expired"}{" "}
70+
{isExpired ? "Expired" : isPending ? "Expires" : "Expired"}{" "}
7371
{dayjs(invitation.expiresAt).fromNow()}
7472
</p>
7573
</div>
7674

77-
<Badge className={status.className} variant="secondary">
75+
<Badge className={cn(status.className, "h-7")} variant="secondary">
7876
{status.label}
7977
</Badge>
8078

@@ -110,12 +108,16 @@ export function InvitationList({
110108
useState<InvitationToCancel | null>(null);
111109

112110
const handleCancel = async () => {
113-
if (!invitationToCancel) return;
111+
if (!invitationToCancel) {
112+
return;
113+
}
114114
await onCancelInvitationAction(invitationToCancel.id);
115115
setInvitationToCancel(null);
116116
};
117117

118-
if (invitations.length === 0) return null;
118+
if (invitations.length === 0) {
119+
return null;
120+
}
119121

120122
return (
121123
<>
@@ -130,30 +132,17 @@ export function InvitationList({
130132
))}
131133
</div>
132134

133-
<AlertDialog
134-
onOpenChange={(open) => !open && setInvitationToCancel(null)}
135-
open={!!invitationToCancel}
136-
>
137-
<AlertDialogContent>
138-
<AlertDialogHeader>
139-
<AlertDialogTitle>
140-
Cancel invitation for {invitationToCancel?.email}?
141-
</AlertDialogTitle>
142-
<AlertDialogDescription>
143-
This action cannot be undone. The invitation will be cancelled.
144-
</AlertDialogDescription>
145-
</AlertDialogHeader>
146-
<AlertDialogFooter>
147-
<AlertDialogCancel>Keep</AlertDialogCancel>
148-
<AlertDialogAction
149-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
150-
onClick={handleCancel}
151-
>
152-
Cancel Invitation
153-
</AlertDialogAction>
154-
</AlertDialogFooter>
155-
</AlertDialogContent>
156-
</AlertDialog>
135+
<DeleteDialog
136+
cancelLabel="Keep"
137+
confirmLabel="Cancel Invitation"
138+
description={`Are you sure you want to cancel the invitation for ${invitationToCancel?.email}? This action cannot be undone.`}
139+
isDeleting={isCancellingInvitation}
140+
isOpen={!!invitationToCancel}
141+
itemName={invitationToCancel?.email}
142+
onClose={() => setInvitationToCancel(null)}
143+
onConfirm={handleCancel}
144+
title="Cancel Invitation"
145+
/>
157146
</>
158147
);
159148
}

apps/dashboard/app/(main)/organizations/invitations/invitations-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export function InvitationsView({
196196
<XIcon className="size-3.5" weight="bold" />
197197
Expired
198198
{expiredCount > 0 && (
199-
<span className="rounded-full bg-muted px-1.5 py-0.5 text-muted-foreground text-xs">
199+
<span className="rounded-full bg-secondary px-1.5 py-0.5 text-secondary-foreground text-xs">
200200
{expiredCount}
201201
</span>
202202
)}

apps/dashboard/app/(main)/organizations/members/member-list.tsx

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@ import { CrownIcon, TrashIcon } from "@phosphor-icons/react";
44
import dayjs from "dayjs";
55
import relativeTime from "dayjs/plugin/relativeTime";
66
import { useState } from "react";
7-
import {
8-
AlertDialog,
9-
AlertDialogAction,
10-
AlertDialogCancel,
11-
AlertDialogContent,
12-
AlertDialogDescription,
13-
AlertDialogFooter,
14-
AlertDialogHeader,
15-
AlertDialogTitle,
16-
} from "@/components/ui/alert-dialog";
177
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
188
import { Badge } from "@/components/ui/badge";
199
import { Button } from "@/components/ui/button";
10+
import { DeleteDialog } from "@/components/ui/delete-dialog";
2011
import {
2112
Select,
2213
SelectContent,
@@ -31,26 +22,26 @@ import type {
3122

3223
dayjs.extend(relativeTime);
3324

34-
interface MemberToRemove {
25+
type MemberToRemove = {
3526
id: string;
3627
name: string;
37-
}
28+
};
3829

39-
interface MemberListProps {
30+
type MemberListProps = {
4031
members: OrganizationMember[];
4132
onRemoveMember: (memberId: string) => void;
4233
isRemovingMember: boolean;
4334
onUpdateRole: (member: UpdateMemberData) => void;
4435
isUpdatingMember: boolean;
4536
organizationId: string;
46-
}
37+
};
4738

48-
interface RoleSelectorProps {
39+
type RoleSelectorProps = {
4940
member: OrganizationMember;
5041
onUpdateRole: MemberListProps["onUpdateRole"];
5142
isUpdatingMember: boolean;
5243
organizationId: string;
53-
}
44+
};
5445

5546
function RoleSelector({
5647
member,
@@ -85,15 +76,15 @@ function RoleSelector({
8576
);
8677
}
8778

88-
interface MemberRowProps {
79+
type MemberRowProps = {
8980
member: OrganizationMember;
9081
onRemoveMember: MemberListProps["onRemoveMember"];
9182
isRemovingMember: boolean;
9283
onUpdateRole: MemberListProps["onUpdateRole"];
9384
isUpdatingMember: boolean;
9485
organizationId: string;
9586
onConfirmRemove: (member: MemberToRemove) => void;
96-
}
87+
};
9788

9889
function MemberRow({
9990
member,
@@ -169,7 +160,9 @@ export function MemberList({
169160
);
170161

171162
const handleRemove = async () => {
172-
if (!memberToRemove) return;
163+
if (!memberToRemove) {
164+
return;
165+
}
173166
await onRemoveMember(memberToRemove.id);
174167
setMemberToRemove(null);
175168
};
@@ -189,29 +182,16 @@ export function MemberList({
189182
/>
190183
))}
191184

192-
<AlertDialog
193-
onOpenChange={(open) => !open && setMemberToRemove(null)}
194-
open={!!memberToRemove}
195-
>
196-
<AlertDialogContent>
197-
<AlertDialogHeader>
198-
<AlertDialogTitle>Remove {memberToRemove?.name}?</AlertDialogTitle>
199-
<AlertDialogDescription>
200-
This action cannot be undone. This will permanently remove the
201-
member from the organization.
202-
</AlertDialogDescription>
203-
</AlertDialogHeader>
204-
<AlertDialogFooter>
205-
<AlertDialogCancel>Cancel</AlertDialogCancel>
206-
<AlertDialogAction
207-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
208-
onClick={handleRemove}
209-
>
210-
Remove
211-
</AlertDialogAction>
212-
</AlertDialogFooter>
213-
</AlertDialogContent>
214-
</AlertDialog>
185+
<DeleteDialog
186+
confirmLabel="Remove"
187+
description={`This action cannot be undone. This will permanently remove ${memberToRemove?.name} from the organization.`}
188+
isDeleting={isRemovingMember}
189+
isOpen={!!memberToRemove}
190+
itemName={memberToRemove?.name}
191+
onClose={() => setMemberToRemove(null)}
192+
onConfirm={handleRemove}
193+
title="Remove Member"
194+
/>
215195
</>
216196
);
217197
}

apps/dashboard/app/(main)/websites/[id]/_components/tabs/audience-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function WebsiteAudienceTab({
162162
<div className="flex items-center gap-3">
163163
<BrowserIcon
164164
fallback={
165-
<div className="flex h-5 w-5 items-center justify-center rounded bg-muted font-medium text-muted-foreground text-xs">
165+
<div className="flex h-5 w-5 items-center justify-center rounded bg-secondary font-medium text-secondary-foreground text-xs">
166166
{browserName.charAt(0).toUpperCase()}
167167
</div>
168168
}

apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-history-sheet.tsx

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@ import {
1111
import { useAtom } from "jotai";
1212
import type React from "react";
1313
import { useEffect, useState } from "react";
14-
import {
15-
AlertDialog,
16-
AlertDialogAction,
17-
AlertDialogCancel,
18-
AlertDialogContent,
19-
AlertDialogDescription,
20-
AlertDialogFooter,
21-
AlertDialogHeader,
22-
AlertDialogTitle,
23-
} from "@/components/ui/alert-dialog";
2414
import { Badge } from "@/components/ui/badge";
2515
import { Button } from "@/components/ui/button";
16+
import { DeleteDialog } from "@/components/ui/delete-dialog";
2617
import {
2718
DropdownMenu,
2819
DropdownMenuContent,
@@ -43,18 +34,18 @@ import { cn } from "@/lib/utils";
4334
import { websiteDataAtom, websiteIdAtom } from "@/stores/jotai/assistantAtoms";
4435
import { getChatDB } from "../lib/chat-db";
4536

46-
interface ChatHistoryItem {
37+
type ChatHistoryItem = {
4738
websiteId: string;
4839
websiteName?: string;
4940
lastUpdated: number;
5041
messageCount: number;
5142
lastMessage?: string;
52-
}
43+
};
5344

54-
interface ChatHistorySheetProps {
45+
type ChatHistorySheetProps = {
5546
isOpen: boolean;
5647
onClose: () => void;
57-
}
48+
};
5849

5950
function formatRelativeTime(timestamp: number): string {
6051
const now = Date.now();
@@ -339,29 +330,14 @@ export function ChatHistorySheet({ isOpen, onClose }: ChatHistorySheetProps) {
339330
</div>
340331
</SheetContent>
341332
</Sheet>
342-
<AlertDialog
343-
onOpenChange={() => setDeleteConfirm(null)}
344-
open={!!deleteConfirm}
345-
>
346-
<AlertDialogContent>
347-
<AlertDialogHeader>
348-
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
349-
<AlertDialogDescription>
350-
This will permanently delete this chat history. This action cannot
351-
be undone.
352-
</AlertDialogDescription>
353-
</AlertDialogHeader>
354-
<AlertDialogFooter>
355-
<AlertDialogCancel>Cancel</AlertDialogCancel>
356-
<AlertDialogAction
357-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
358-
onClick={() => deleteConfirm && handleDeleteChat(deleteConfirm)}
359-
>
360-
Delete
361-
</AlertDialogAction>
362-
</AlertDialogFooter>
363-
</AlertDialogContent>
364-
</AlertDialog>
333+
<DeleteDialog
334+
confirmLabel="Delete"
335+
description="This will permanently delete this chat history. This action cannot be undone."
336+
isOpen={!!deleteConfirm}
337+
onClose={() => setDeleteConfirm(null)}
338+
onConfirm={() => deleteConfirm && handleDeleteChat(deleteConfirm)}
339+
title="Delete Chat History"
340+
/>
365341
</>
366342
);
367343
}

apps/dashboard/app/(main)/websites/[id]/users/[userId]/_components/session-utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const getEventIconAndColor = (
4444
color: "text-muted-foreground",
4545
bgColor: "bg-muted/30",
4646
borderColor: "border-muted",
47-
badgeColor: "bg-muted text-muted-foreground border-muted",
47+
badgeColor: "bg-secondary text-secondary-foreground border-secondary",
4848
};
4949
}
5050
};

0 commit comments

Comments
 (0)