Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

improve: updated org settings (#820)

Ameer Al Ashhabb54fab33aa1c
diff --git a/apps/web/actions/organization/update-details.ts b/apps/web/actions/organization/update-details.ts
index 9d04a6613..2480e8f14 100644
--- a/apps/web/actions/organization/update-details.ts
+++ b/apps/web/actions/organization/update-details.ts
@@ -1,4 +1,4 @@
-'use server';
+"use server";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
@@ -6,11 +6,15 @@ import { db } from "@cap/database";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
-export async function updateOrganizationDetails(
- organizationName: string,
- allowedEmailDomain: string,
- organizationId: string
-) {
+export async function updateOrganizationDetails({
+ organizationName,
+ allowedEmailDomain,
+ organizationId,
+}: {
+ organizationName?: string | null;
+ allowedEmailDomain?: string | null;
+ organizationId: string;
+}) {
const user = await getCurrentUser();
if (!user) {
@@ -30,15 +34,25 @@ export async function updateOrganizationDetails(
throw new Error("Only the owner can update organization details");
}
- await db()
- .update(organizations)
- .set({
- name: organizationName,
- allowedEmailDomain: allowedEmailDomain || null,
- })
- .where(eq(organizations.id, organizationId));
+ if (organizationName) {
+ await db()
+ .update(organizations)
+ .set({
+ name: organizationName,
+ })
+ .where(eq(organizations.id, organizationId));
+ }
+
+ if (allowedEmailDomain || allowedEmailDomain === "") {
+ await db()
+ .update(organizations)
+ .set({
+ allowedEmailDomain: allowedEmailDomain,
+ })
+ .where(eq(organizations.id, organizationId));
+ }
revalidatePath("/dashboard/settings/organization");
return { success: true };
-}
\ No newline at end of file
+}
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/CapAIBox.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/CapAIBox.tsx
index e73f3f59b..da5e3a6ec 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/CapAIBox.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/CapAIBox.tsx
@@ -54,7 +54,7 @@ const CapAIArt = memo(() => {
const { theme } = useTheme();
const { RiveComponent: CapAIArt } = useRive({
src: "/rive/bento.riv",
- artboard: theme === "light" ? "capai" : "capaidark",
+ artboard: theme === "dark" ? "capai" : "capaidark",
autoplay: true,
layout: new Layout({
fit: Fit.Contain,
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/CapAIDialog.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/CapAIDialog.tsx
index 2c7236c5b..0338d910c 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/CapAIDialog.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/CapAIDialog.tsx
@@ -19,7 +19,7 @@ const CapAIDialog = ({ setOpen }: { setOpen: (open: boolean) => void }) => {
const { RiveComponent: CapAIArt } = useRive({
src: "/rive/bento.riv",
- artboard: theme === "light" ? "capai" : "capaidark",
+ artboard: theme === "dark" ? "capai" : "capaidark",
animations: ["in"],
autoplay: true,
layout: new Layout({
diff --git a/apps/web/app/(org)/dashboard/settings/organization/Organization.tsx b/apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
index fa864cb4e..1f648a1d5 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
@@ -1,31 +1,27 @@
"use client";
import { manageBilling } from "@/actions/organization/manage-billing";
-import { updateOrganizationDetails } from "@/actions/organization/update-details";
import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";
-import { Card, CardDescription, CardTitle } from "@cap/ui";
import { useRouter } from "next/navigation";
import { Dispatch, SetStateAction, useCallback, useRef, useState } from "react";
import { toast } from "sonner";
import { BillingCard } from "./components/BillingCard";
-import { CustomDomainIconCard } from "./components/CustomDomainIconCard";
import { InviteDialog } from "./components/InviteDialog";
import { MembersCard } from "./components/MembersCard";
import { OrganizationDetailsCard } from "./components/OrganizationDetailsCard";
import { SeatsInfoCards } from "./components/SeatsInfoCards";
+import CapSettingsCard from "./components/CapSettingsCard";
export const
Organization = () => {
const { activeOrganization, user } = useDashboardContext();
- const organizationName = activeOrganization?.organization.name;
const router = useRouter();
const [loading, setLoading] = useState(false);
const [billingLoading, setBillingLoading] = useState(false);
const isOwner = user?.id === activeOrganization?.organization.ownerId;
const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);
const ownerToastShown = useRef(false);
- const [saveLoading, setSaveLoading] = useState(false);
const showOwnerToast = useCallback(() => {
if (!ownerToastShown.current) {
@@ -37,38 +33,6 @@ export const
}
}, []);
- const handleSubmit = useCallback(
- async (e: React.FormEvent<HTMLFormElement>) => {
- e.preventDefault();
-
- if (!isOwner) {
- showOwnerToast();
- return;
- }
-
- const formData = new FormData(e.currentTarget);
- const organizationName = formData.get("organizationName") as string;
- const allowedEmailDomain = formData.get("allowedEmailDomain") as string;
-
- try {
- setSaveLoading(true);
- await updateOrganizationDetails(
- organizationName,
- allowedEmailDomain,
- activeOrganization?.organization.id as string
- );
- toast.success("Settings updated successfully");
- router.refresh();
- } catch (error) {
- console.error("Error updating settings:", error);
- toast.error("An error occurred while updating settings");
- } finally {
- setSaveLoading(false);
- }
- },
- [isOwner, showOwnerToast, activeOrganization?.organization.id, router]
- );
-
const handleManageBilling = useCallback(
async (loadingDispatch: Dispatch<SetStateAction<boolean>>) => {
if (!isOwner) {
@@ -89,31 +53,16 @@ export const
);
return (
- <form className="flex flex-col gap-6" onSubmit={handleSubmit}>
- {isOwner === false && (
- <Card>
- <CardTitle>*Only the owner can make changes</CardTitle>
- <CardDescription>
- Only the owner can make changes to this organization.
- </CardDescription>
- </Card>
- )}
+ <form className="flex flex-col gap-6">
<SeatsInfoCards />
<div className="flex flex-col gap-6 justify-center items-stretch xl:flex-row">
- <OrganizationDetailsCard
- isOwner={isOwner}
- saveLoading={saveLoading}
- showOwnerToast={showOwnerToast}
- organizationName={organizationName}
- />
- <CustomDomainIconCard
- isOwner={isOwner}
- showOwnerToast={showOwnerToast}
- />
+ <OrganizationDetailsCard />
+ <CapSettingsCard />
</div>
+
<MembersCard
isOwner={isOwner}
loading={loading}
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/AccessEmailDomain.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/AccessEmailDomain.tsx
new file mode 100644
index 000000000..ad98f2f1a
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/AccessEmailDomain.tsx
@@ -0,0 +1,70 @@
+import { Button, Input, Label } from "@cap/ui";
+import { useDashboardContext } from "../../../Contexts";
+import { useState } from "react";
+import { toast } from "sonner";
+import { updateOrganizationDetails } from "@/actions/organization/update-details";
+import { useRouter } from "next/navigation";
+
+
+export const AccessEmailDomain = () => {
+ const { activeOrganization } = useDashboardContext();
+ const [emailDomain, setEmailDomain] = useState(activeOrganization?.organization.allowedEmailDomain || null);
+ const [saveLoading, setSaveLoading] = useState(false);
+ const router = useRouter();
+
+ const handleEmailDomainSave = async () => {
+ try {
+ setSaveLoading(true);
+ await updateOrganizationDetails({
+ allowedEmailDomain: emailDomain,
+ organizationId: activeOrganization?.organization.id as string,
+ });
+ toast.success("Settings updated successfully");
+ router.refresh();
+ } catch (error) {
+ console.error("Error updating settings:", error);
+ toast.error("An error occurred while updating settings");
+ } finally {
+ setSaveLoading(false);
+ }
+ };
+
+ return (
+ <div className="space-y-4">
+ <div className="space-y-1">
+ <Label htmlFor="allowedEmailDomain">Access email domain</Label>
+ <p className="text-sm text-gray-10">
+ Only emails from this domain can access shared videos.{" "}
+ <span className="font-medium text-sm text-gray-11 leading-[0px]">
+ Leave blank to allow everyone.
+ </span>
+ </p>
+ </div>
+ <div className="flex gap-3 items-center w-full h-fit">
+ <Input
+ type="text"
+ placeholder="e.g. company.com"
+ value={emailDomain || ""}
+ id="allowedEmailDomain"
+ name="allowedEmailDomain"
+ onChange={(e) => {
+ setEmailDomain(e.target.value);
+ }}
+ />
+ <Button
+ className="min-w-fit"
+ type="submit"
+ spinner={saveLoading}
+ size="sm"
+ variant="dark"
+ disabled={saveLoading || emailDomain === activeOrganization?.organization.allowedEmailDomain}
+ onClick={handleEmailDomainSave}
+ >
+ {saveLoading ? null : "Save"}
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+export default AccessEmailDomain;
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
new file mode 100644
index 000000000..026db7c9f
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
@@ -0,0 +1,122 @@
+
+import { Card, CardDescription, CardHeader, CardTitle, Switch } from "@cap/ui";
+
+import { AnimatePresence, motion } from "framer-motion";
+import clsx from "clsx";
+import { useState } from "react";
+
+const VideoTabSettings = [
+ {
+ label: "5 minutes video duration",
+ description: "Set the default video duration",
+ },
+ {
+ label: "1080p resolution",
+ description: "Set the default video resolution",
+ },
+ {
+ label: "10Mbps bitrate",
+ description: "Set the default video bitrate",
+ },
+]
+
+const NotificationTabSettings = [
+ {
+ label: "Notifications",
+ description: "Set the default notification settings",
+ },
+ {
+ label: "Setting 1",
+ description: "Set the default random settings",
+ },
+ {
+ label: "Setting 2",
+ description: "Set the default random settings",
+ },
+ {
+ label: "Setting 3",
+ description: "Set the default random settings",
+ },
+ {
+ label: "Setting 4",
+ description: "Set the default random settings",
+ },
+ {
+ label: "Setting 5",
+ description: "Set the default random settings",
+ },
+ {
+ label: "Setting 6",
+ description: "Set the default random settings",
+ }
+]
+
+
+const CapSettingsCard = () => {
+ const [activeTab, setActiveTab] = useState("Notifications");
+ return (
+ <Card className="flex relative flex-col flex-1 gap-6 w-full min-h-fit">
+ <CardHeader>
+ <CardTitle>Cap Settings</CardTitle>
+ <CardDescription>
+ Enable or disable specific settings for your organization. Notifications, videos, etc...
+ </CardDescription>
+ </CardHeader>
+
+ <div className="relative">
+ <div className="absolute top-0 left-0 z-[20] rounded-xl flex items-center justify-center w-full h-full backdrop-blur-md bg-zinc-900/20">
+ <p className="px-3 py-2 text-sm font-semibold rounded-full border text-gray-12 border-gray-3 bg-gray-3">Coming Soon</p>
+ </div>
+ <div className="flex gap-4 pb-4 mt-3 border-b border-gray-3">
+ {["Notifications", "Videos"].map((setting) => (
+ <motion.div key={setting} style={{
+ borderRadius: 12
+ }} onClick={() => setActiveTab(setting)} className={clsx("relative cursor-pointer")}>
+ <p className={clsx("relative z-10 text-[13px] px-2.5 py-1.5 font-medium transition-colors duration-200 text-gray-10 hover:text-gray-11", activeTab === setting && "text-gray-12 hover:text-gray-12")}>{setting}</p>
+ {/** Indicator */}
+ {activeTab === setting && (
+ <motion.div
+ layoutId="activeTabIndicator"
+ transition={{ damping: 25, stiffness: 250, type: "spring" }}
+ className="absolute top-0 left-0 w-full h-full rounded-xl bg-gray-3"
+ />
+ )}
+ </motion.div>
+ ))}
+ </div>
+ <div className="mt-4 space-y-3">
+ {activeTab === "Videos" ? (
+ <AnimatePresence initial={false}>
+ {VideoTabSettings.map((setting, index) => (
+ <motion.div
+ initial={{ opacity: 0, y: 10 }}
+ animate={{ opacity: 1, y: 0, transition: { delay: index * 0.05 } }}
+ exit={{ opacity: 0, y: -10, transition: { duration: 0.2 } }}
+ key={index.toString() + setting.label} className="flex justify-between items-center p-3 rounded-xl border border-gray-4">
+ <p className="text-[13px] text-gray-12">{setting.label}</p>
+ <Switch />
+ </motion.div>
+ ))}
+ </AnimatePresence>
+ ) : (
+ <AnimatePresence initial={false}>
+ {NotificationTabSettings.map((setting, index) => (
+ <motion.div
+ initial={{ opacity: 0, y: 10 }}
+ animate={{ opacity: 1, y: 0, transition: { delay: index * 0.05 } }}
+ exit={{ opacity: 0, y: -10, transition: { duration: 0.2 } }}
+ key={index.toString() + setting.label}
+ className="flex justify-between items-center p-3 rounded-xl border border-gray-4">
+ <p className="text-[13px] text-gray-12">{setting.label}</p>
+ <Switch />
+ </motion.div>
+ ))}
+ </AnimatePresence>
+ )}
+ </div>
+ </div>
+ </Card>
+ );
+};
+
+export default CapSettingsCard;
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomain.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomain.tsx
index ed7a52631..fe7b435ef 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomain.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomain.tsx
@@ -2,7 +2,7 @@ import { checkOrganizationDomain } from "@/actions/organization/check-domain";
import { removeOrganizationDomain } from "@/actions/organization/remove-domain";
import { updateDomain } from "@/actions/organization/update-domain";
import { UpgradeModal } from "@/components/UpgradeModal";
-import { Button, Input } from "@cap/ui";
+import { Button, Input, Label } from "@cap/ui";
import { faRefresh, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
@@ -30,12 +30,7 @@ type DomainConfig = {
requiredAValue?: string;
};
-interface CustomDomainProps {
- isOwner: boolean;
- showOwnerToast: () => void;
-}
-
-export function CustomDomain({ isOwner, showOwnerToast }: CustomDomainProps) {
+export function CustomDomain() {
const router = useRouter();
const { activeOrganization, isSubscribed } = useDashboardContext();
const [domain, setDomain] = useState(
@@ -233,74 +228,82 @@ export function CustomDomain({ isOwner, showOwnerToast }: CustomDomainProps) {
return (
- <div className="flex flex-wrap mt-4 space-y-6">
- <div className="flex-1">
- <div className="flex flex-col justify-between items-start">
+ <div className="space-y-4">
+ <div className="space-y-1">
+ <Label htmlFor="customDomain">Custom Domain</Label>
+ <p className="text-sm text-gray-10">
+ Set up a custom domain for your organization's shared caps and make
+ it unique.
+ </p>
+ </div>
+ <div className="flex flex-col gap-3 items-start">
+ <div className="flex gap-3 items-center w-full h-fit">
<Input
type="text"
id="customDomain"
- placeholder={isOwner ? "your-domain.com" : "Only the owner of the organization can change this"}
+ placeholder="your-domain.com"
value={domain}
onChange={(e) => setDomain(e.target.value)}
- disabled={!isOwner}
className="flex-1 min-h-[44px]"
/>
+ <Button
+ type="submit"
+ size="sm"
+ className="min-w-fit"
+ variant="dark"
+ onClick={handleSubmit}
+ spinner={loading}
+ disabled={loading || domain === activeOrganization?.organization.customDomain || domain === ""}
+ >
+ {loading ? "Saving..." : "Save"}
+ </Button>
+ </div>
+
+ {activeOrganization?.organization.customDomain &&
<div className="flex gap-2 justify-between items-center mt-4">
- {activeOrganization?.organization.customDomain &&
- (isVerified ? (
- <>
- <div className="flex items-center gap-1 text-white bg-green-600 px-2.5 py-1.5 rounded-full text-sm">
- <CheckCircle className="size-3" />
- <span className="text-xs font-medium text-white">
- Domain verified
- </span>
- </div>
- </>
- ) : (
- <>
- <div className="flex items-center gap-1 text-white bg-red-500 px-2.5 py-1.5 rounded-full text-sm">
- <XCircle className="size-3" />
- <span className="text-xs font-medium text-white">
- Domain not verified
- </span>
- </div>
- </>
- ))}
+ {isVerified ? (
+ <>
+ <div className="flex items-center gap-1 text-white bg-green-600 px-2.5 py-1.5 rounded-full text-sm">
+ <CheckCircle className="size-3" />
+ <span className="text-xs font-medium text-white">
+ Domain verified
+ </span>
+ </div>
+ </>
+ ) : (
+ <>
+ <div className="flex items-center gap-1 text-white bg-red-500 px-2.5 py-1.5 rounded-full text-sm">
+ <XCircle className="size-3" />
+ <span className="text-xs font-medium text-white">
+ Domain not verified
+ </span>
+ </div>
+ </>
+ )}
</div>
- <div className="flex gap-3 justify-between items-center mt-8 w-full">
- <Button
- type="submit"
- size="sm"
- className="px-[1.5rem]"
- variant="dark"
- className="px-[1.5rem]"
- onClick={handleSubmit}
- spinner={loading}
- disabled={loading}
- >
- {loading ? "Saving..." : "Save"}
- </Button>
+ }
+
+ {activeOrganization?.organization.customDomain && (
+ <div className="flex gap-3 justify-between items-center w-full">
<div className="flex gap-3 items-center">
- {activeOrganization?.organization.customDomain && (
- <Button
- type="button"
- variant="gray"
- size="sm"
- onClick={() => checkVerification(true)}
- disabled={verifying}
- className="w-[105px]"
- >
- {verifying ? (
- <FontAwesomeIcon
- className="animate-spin size-4 mr-0.5"
- icon={faRefresh}
- />
- ) : (
- <FontAwesomeIcon className="size-4 mr-0.5" icon={faRefresh} />
- )}
- Refresh
- </Button>
- )}
+ <Button
+ type="button"
+ variant="gray"
+ size="sm"
+ onClick={() => checkVerification(true)}
+ disabled={verifying}
+ className="w-[105px]"
+ >
+ {verifying ? (
+ <FontAwesomeIcon
+ className="animate-spin size-4 mr-0.5"
+ icon={faRefresh}
+ />
+ ) : (
+ <FontAwesomeIcon className="size-4 mr-0.5" icon={faRefresh} />
+ )}
+ Refresh
+ </Button>
{activeOrganization?.organization.customDomain && (
<Button
type="button"
@@ -315,72 +318,169 @@ export function CustomDomain({ isOwner, showOwnerToast }: CustomDomainProps) {
)}
</div>
</div>
- </div>
- {activeOrganization?.organization.customDomain && (
- <div className="mt-4 space-y-4">
- {!isVerified && domainConfig?.verification?.[0] && (
+ )}
+
+
+ </div>
+ {activeOrganization?.organization.customDomain && (
+ <div className="mt-4 space-y-4">
+ {!isVerified && domainConfig?.verification?.[0] && (
+ <div className="overflow-hidden rounded-lg border border-gray-4">
+ <div className="px-4 py-3 border-b bg-gray-2 border-gray-4">
+ <p className="font-medium text-md text-gray-12">
+ DNS Configuration Required
+ </p>
+ <p className="mt-1 text-sm text-gray-10">
+ To verify your domain ownership, add the following TXT
+ record to your DNS configuration:
+ </p>
+ </div>
+ <div className="px-4 py-3">
+ <dl className="grid gap-4">
+ <div className="grid grid-cols-[100px,1fr] items-center">
+ <dt className="text-sm font-medium text-gray-12">Type</dt>
+ <dd className="text-sm text-gray-10">
+ {domainConfig?.verification?.[0]?.type}
+ </dd>
+ </div>
+ <div className="grid grid-cols-[100px,1fr] items-center">
+ <dt className="text-sm font-medium text-gray-12">Name</dt>
+ <dd className="flex gap-2 items-center text-sm text-gray-10">
+ <div className="flex items-center justify-between gap-1.5
+ bg-gray-4 px-2 py-1 rounded-lg flex-1 min-w-0 border border-gray-6">
+ <code className="text-xs truncate">
+ {domainConfig?.verification?.[0]?.domain}
+ </code>
+ {domainConfig?.verification?.[0]?.domain && (
+ <button
+ type="button"
+ onClick={() => {
+ const domain =
+ domainConfig?.verification?.[0]?.domain;
+ if (domain) handleCopy(domain, "name");
+ }}
+ className="p-1 rounded-md transition-colors hover:bg-gray-1 shrink-0"
+ title="Copy to clipboard"
+ >
+ {copiedField === "name" ? (
+ <Check className="size-3.5 text-green-500" />
+ ) : (
+ <Copy className="size-3.5 text-gray-10" />
+ )}
+ </button>
+ )}
+ </div>
+ </dd>
+ </div>
+ <div className="grid grid-cols-[100px,1fr] items-center">
+ <dt className="text-sm font-medium text-gray-12">Value</dt>
+ <dd className="flex gap-2 items-center text-sm text-gray-10">
+ <div className="flex flex-1 gap-1 justify-between items-center px-2 py-1 min-w-0 rounded-lg border bg-gray-4 border-gray-6">
+ <code className="font-mono text-xs break-all">
+ {domainConfig?.verification?.[0]?.value}
+ </code>
+ {domainConfig?.verification?.[0]?.value && (
+ <button
+ type="button"
+ onClick={() => {
+ const value =
+ domainConfig?.verification?.[0]?.value;
+ if (value) handleCopy(value, "value");
+ }}
+ className="p-1 rounded-md transition-colors hover:bg-gray-1 shrink-0"
+ title="Copy to clipboard"
+ >
+ {copiedField === "value" ? (
+ <Check className="size-3.5 text-green-500" />
+ ) : (
+ <Copy className="size-3.5 text-gray-10" />
+ )}
+ </button>
+ )}
+ </div>
+ </dd>
+ </div>
+ </dl>
+ </div>
+ </div>
+ )}
+
+
+
+ {!isVerified &&
+ !domainConfig?.verification?.[0] &&
+ domainConfig?.requiredAValue && (
<div className="overflow-hidden rounded-lg border border-gray-4">
<div className="px-4 py-3 border-b bg-gray-2 border-gray-4">
<p className="font-medium text-md text-gray-12">
DNS Configuration Required
</p>
<p className="mt-1 text-sm text-gray-10">
- To verify your domain ownership, add the following TXT
+ To verify your domain ownership, add the following A
record to your DNS configuration:
</p>
</div>
<div className="px-4 py-3">
<dl className="grid gap-4">
+ {domainConfig.currentAValues &&
+ domainConfig.currentAValues.length > 0 && (
+ <div className="grid grid-cols-[100px,1fr] items-center">
+ <dt className="text-sm font-medium text-gray-12">
+ Current
+ </dt>
+ <dd className="space-y-1.5 text-sm text-gray-10">
+ {domainConfig.currentAValues.map(
+ (value, index) => (
+ <div
+ key={index}
+ className={clsx(
+ value === domainConfig.requiredAValue
+ ? "flex items-center gap-2 text-green-300"
+ : "flex items-center gap-2 text-red-200"
+ )}
+ >
+ <code
+ className={clsx(
+ value === domainConfig.requiredAValue
+ ? "px-2 py-1 rounded-lg bg-green-900"
+ : "px-2 py-1 rounded-lg bg-red-900",
+ "text-xs"
+ )
+ }
+ >
+ {value}
+ </code>
+ {value === domainConfig.requiredAValue && (
+ <span className="text-xs text-green-600">
+ (Correct)
+ </span>
+ )}
+ </div>
+ )
+ )}
+ </dd>
+ </div>
+ )}
<div className="grid grid-cols-[100px,1fr] items-center">
- <dt className="text-sm font-medium text-gray-12">Type</dt>
- <dd className="text-sm text-gray-10">
- {domainConfig?.verification?.[0]?.type}
- </dd>
- </div>
- <div className="grid grid-cols-[100px,1fr] items-center">
- <dt className="text-sm font-medium text-gray-12">Name</dt>
+ <dt className="text-sm font-medium text-gray-12">
+ Required
+ </dt>
<dd className="flex gap-2 items-center text-sm text-gray-10">
<div className="flex items-center justify-between gap-1.5
bg-gray-4 px-2 py-1 rounded-lg flex-1 min-w-0 border border-gray-6">
- <code className="text-xs truncate">
- {domainConfig?.verification?.[0]?.domain}
- </code>
- {domainConfig?.verification?.[0]?.domain && (
- <button
- type="button"
- onClick={() => {
- const domain =
- domainConfig?.verification?.[0]?.domain;
- if (domain) handleCopy(domain, "name");
- }}
- className="p-1 rounded-md transition-colors hover:bg-gray-1 shrink-0"
- title="Copy to clipboard"
- >
- {copiedField === "name" ? (
- <Check className="size-3.5 text-green-500" />
- ) : (
- <Copy className="size-3.5 text-gray-10" />
- )}
- </button>
- )}
- </div>
- </dd>
- </div>
- <div className="grid grid-cols-[100px,1fr] items-center">
- <dt className="text-sm font-medium text-gray-12">Value</dt>
- <dd className="flex gap-2 items-center text-sm text-gray-10">
- <div className="flex flex-1 gap-1 justify-between items-center px-2 py-1 min-w-0 rounded-lg border bg-gray-4 border-gray-6">
- <code className="font-mono text-xs break-all">
- {domainConfig?.verification?.[0]?.value}
+ <code className="text-xs text-gray-10">
+ {domainConfig.requiredAValue || "Loading..."}
</code>
- {domainConfig?.verification?.[0]?.value && (
+ {domainConfig.requiredAValue && (
<button
type="button"
- onClick={() => {
- const value =
- domainConfig?.verification?.[0]?.value;
- if (value) handleCopy(value, "value");
- }}
+ onClick={() =>
+ domainConfig.requiredAValue &&
+ handleCopy(
+ domainConfig.requiredAValue,
+ "value"
+ )
+ }
className="p-1 rounded-md transition-colors hover:bg-gray-1 shrink-0"
title="Copy to clipboard"
>
@@ -398,103 +498,8 @@ export function CustomDomain({ isOwner, showOwnerToast }: CustomDomainProps) {
</div>
</div>
)}
-
-
-
- {!isVerified &&
- !domainConfig?.verification?.[0] &&
- domainConfig?.requiredAValue && (
- <div className="overflow-hidden rounded-lg border border-gray-4">
- <div className="px-4 py-3 border-b bg-gray-2 border-gray-4">
- <p className="font-medium text-md text-gray-12">
- DNS Configuration Required
- </p>
- <p className="mt-1 text-sm text-gray-10">
- To verify your domain ownership, add the following A
- record to your DNS configuration:
- </p>
- </div>
- <div className="px-4 py-3">
- <dl className="grid gap-4">
- {domainConfig.currentAValues &&
- domainConfig.currentAValues.length > 0 && (
- <div className="grid grid-cols-[100px,1fr] items-center">
- <dt className="text-sm font-medium text-gray-12">
- Current
- </dt>
- <dd className="space-y-1.5 text-sm text-gray-10">
- {domainConfig.currentAValues.map(
- (value, index) => (
- <div
- key={index}
- className={clsx(
- value === domainConfig.requiredAValue
- ? "flex items-center gap-2 text-green-300"
- : "flex items-center gap-2 text-red-200"
- )}
- >
- <code
- className={clsx(
- value === domainConfig.requiredAValue
- ? "px-2 py-1 rounded-lg bg-green-900"
- : "px-2 py-1 rounded-lg bg-red-900",
- "text-xs"
- )
- }
- >
- {value}
- </code>
- {value === domainConfig.requiredAValue && (
- <span className="text-xs text-green-600">
- (Correct)
- </span>
- )}
- </div>
- )
- )}
- </dd>
- </div>
- )}
- <div className="grid grid-cols-[100px,1fr] items-center">
- <dt className="text-sm font-medium text-gray-12">
- Required
- </dt>
- <dd className="flex gap-2 items-center text-sm text-gray-10">
- <div className="flex items-center justify-between gap-1.5
- bg-gray-4 px-2 py-1 rounded-lg flex-1 min-w-0 border border-gray-6">
- <code className="text-xs text-gray-10">
- {domainConfig.requiredAValue || "Loading..."}
- </code>
- {domainConfig.requiredAValue && (
- <button
- type="button"
- onClick={() =>
- domainConfig.requiredAValue &&
- handleCopy(
- domainConfig.requiredAValue,
- "value"
- )
- }
- className="p-1 rounded-md transition-colors hover:bg-gray-1 shrink-0"
- title="Copy to clipboard"
- >
- {copiedField === "value" ? (
- <Check className="size-3.5 text-green-500" />
- ) : (
- <Copy className="size-3.5 text-gray-10" />
- )}
- </button>
- )}
- </div>
- </dd>
- </div>
- </dl>
- </div>
- </div>
- )}
- </div>
- )}
- </div>
+ </div>
+ )}
{showUpgradeModal && (
<UpgradeModal
open={showUpgradeModal}
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/OrgName.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/OrgName.tsx
new file mode 100644
index 000000000..6d78f787a
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/OrgName.tsx
@@ -0,0 +1,69 @@
+"use client";
+
+import { useDashboardContext } from "../../../Contexts";
+import { Button, Input, Label } from "@cap/ui";
+import { useState } from "react";
+import { toast } from "sonner";
+import { updateOrganizationDetails } from "@/actions/organization/update-details";
+import { useRouter } from "next/navigation";
+
+const OrgName = () => {
+ const { activeOrganization } = useDashboardContext();
+ const [orgName, setOrgName] = useState(activeOrganization?.organization.name);
+ const [saveLoading, setSaveLoading] = useState(false);
+ const router = useRouter();
+
+ const handleOrgNameChange = async () => {
+ try {
+ if (!orgName) return;
+ setSaveLoading(true);
+ await updateOrganizationDetails({
+ organizationName: orgName,
+ organizationId: activeOrganization?.organization.id as string,
+ });
+ toast.success("Settings updated successfully");
+ router.refresh();
+ } catch (error) {
+ console.error("Error updating settings:", error);
+ toast.error("An error occurred while updating settings");
+ } finally {
+ setSaveLoading(false);
+ }
+ };
+
+ return (
+ <div className="space-y-4">
+ <div className="space-y-1">
+ <Label htmlFor="organizationName">Name</Label>
+ <p className="text-sm text-gray-10">
+ Changing the name will update how your organization appears to
+ others members.
+ </p>
+ </div>
+ <div className="flex gap-3 items-center">
+ <Input
+ type="text"
+ value={orgName}
+ id="organizationName"
+ name="organizationName"
+ onChange={(e) => {
+ setOrgName(e.target.value);
+ }}
+ />
+ <Button
+ type="submit"
+ size="sm"
+ className="min-w-fit"
+ variant="dark"
+ spinner={saveLoading}
+ onClick={handleOrgNameChange}
+ disabled={saveLoading || orgName === activeOrganization?.organization.name || !orgName}
+ >
+ {saveLoading ? null : "Save"}
+ </Button>
+ </div>
+ </div>
+ );
+};
+
+export default OrgName;
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationDetailsCard.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationDetailsCard.tsx
index d89d85709..13e6f73f8 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationDetailsCard.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationDetailsCard.tsx
@@ -1,85 +1,26 @@
"use client";
-import { Button, Card, Input, Label } from "@cap/ui";
-import { useDashboardContext } from "../../../Contexts";
+import { Card, CardDescription, CardHeader, CardTitle } from "@cap/ui";
+import { CustomDomain } from "./CustomDomain";
+import { OrganizationIcon } from "./OrganizationIcon";
+import OrgName from "./OrgName";
+import AccessEmailDomain from "./AccessEmailDomain";
-interface OrganizationDetailsCardProps {
- isOwner: boolean;
- saveLoading: boolean;
- showOwnerToast: () => void;
- organizationName: string | undefined;
-}
-
-export const OrganizationDetailsCard = ({
- isOwner,
- saveLoading,
- showOwnerToast,
- organizationName,
-}: OrganizationDetailsCardProps) => {
- const { activeOrganization } = useDashboardContext();
+export const OrganizationDetailsCard = () => {
return (
- <Card className="flex flex-col flex-1 justify-between w-full">
- <div className="flex flex-col gap-6 justify-center lg:flex-row">
- <div className="flex-1 w-full">
- <div className="space-y-1">
- <Label htmlFor="organizationName">Name</Label>
- <p className="text-sm text-gray-10">
- Changing the name will update how your organization appears to
- others members.
- </p>
- </div>
- <Input
- className="mt-4"
- type="text"
- defaultValue={organizationName as string}
- id="organizationName"
- name="organizationName"
- disabled={!isOwner}
- onChange={() => {
- if (!isOwner) showOwnerToast();
- }}
- />
- </div>
- <div className="flex-1 w-full">
- <div className="space-y-1">
- <Label htmlFor="allowedEmailDomain">Access email domain</Label>
- <p className="text-sm text-gray-10">
- Only emails from this domain can access shared videos.{" "}
- <span className="font-medium text-sm text-gray-11 leading-[0px]">
- Leave blank to allow everyone.
- </span>
- </p>
- </div>
- <Input
- type="text"
- placeholder="e.g. company.com"
- defaultValue={
- activeOrganization?.organization.allowedEmailDomain || ""
- }
- id="allowedEmailDomain"
- name="allowedEmailDomain"
- disabled={!isOwner}
- className="mt-4"
- onChange={() => {
- if (!isOwner) showOwnerToast();
- }}
- />
- </div>
- </div>
- <Button
- className="mt-8 px-[1.5rem] w-fit"
- type="submit"
- spinner={saveLoading}
- size="sm"
- variant="dark"
- disabled={!isOwner || saveLoading}
- onClick={() => {
- if (!isOwner) showOwnerToast();
- }}
- >
- {saveLoading ? "Saving..." : "Save"}
- </Button>
+ <Card className="flex flex-col flex-1 gap-6 w-full min-h-fit">
+ <CardHeader>
+ <CardTitle>Settings</CardTitle>
+ <CardDescription>
+ Set the organization name, access email domain, custom domain, and organization icon.
+ </CardDescription>
+ </CardHeader>
+ <OrgName />
+ <AccessEmailDomain />
+ <CustomDomain />
+ <OrganizationIcon />
</Card>
);
};
+
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx
index add18fe9c..dcff8401e 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx
@@ -8,15 +8,7 @@ import { useState } from "react";
import { toast } from "sonner";
import { useDashboardContext } from "../../../Contexts";
-interface OrganizationIconProps {
- isOwner: boolean;
- showOwnerToast: () => void;
-}
-
-export const OrganizationIcon = ({
- isOwner,
- showOwnerToast,
-}: OrganizationIconProps) => {
+export const OrganizationIcon = () => {
const { activeOrganization } = useDashboardContext();
const organizationId = activeOrganization?.organization.id;
const existingIconUrl = activeOrganization?.organization.iconUrl;
@@ -24,11 +16,6 @@ export const OrganizationIcon = ({
const [isUploading, setIsUploading] = useState(false);
const handleFileChange = async (file: File | null) => {
- if (!isOwner) {
- showOwnerToast();
- return;
- }
-
// If file is null, it means the user removed the file
if (!file || !organizationId) return;
@@ -54,7 +41,7 @@ export const OrganizationIcon = ({
};
const handleRemoveIcon = async () => {
- if (!isOwner || !organizationId) return;
+ if (!organizationId) return;
try {
const result = await removeOrganizationIcon(organizationId);
@@ -71,24 +58,24 @@ export const OrganizationIcon = ({
};
return (
- <div className="flex-1">
+ <div className="space-y-4">
<div className="space-y-1">
<Label htmlFor="icon">Organization Icon</Label>
- <CardDescription className="w-full max-w-[400px]">
+ <CardDescription className="w-full">
Upload a custom logo or icon for your organization and make it unique.
</CardDescription>
</div>
- <div className="relative mt-4">
- <FileInput
- id="icon"
- name="icon"
- onChange={handleFileChange}
- disabled={!isOwner || isUploading}
- isLoading={isUploading}
- initialPreviewUrl={existingIconUrl || null}
- onRemove={handleRemoveIcon}
- />
- </div>
+ <FileInput
+ height={62}
+ previewIconSize={32}
+ id="icon"
+ name="icon"
+ onChange={handleFileChange}
+ disabled={isUploading}
+ isLoading={isUploading}
+ initialPreviewUrl={existingIconUrl || null}
+ onRemove={handleRemoveIcon}
+ />
</div>
);
};
diff --git a/apps/web/app/(org)/dashboard/settings/organization/loading.tsx b/apps/web/app/(org)/dashboard/settings/organization/loading.tsx
index eecbeafec..511b06146 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/loading.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/loading.tsx
@@ -64,301 +64,250 @@ export default function Loading() {
</span>
</div>
</div>
+
</div>
- <div className="flex flex-col gap-6 items-stretch xl:flex-row">
- {/* Organization details card */}
- <div className="flex flex-col flex-1 justify-between p-5 rounded-2xl border bg-gray-3 border-gray-4">
- <div className="flex flex-col gap-6 lg:flex-row">
- {/* Name field */}
- <div className="flex-1 space-y-2">
- <div>
+ {/* Main content cards - Organization Details and Cap Settings side by side */}
+ <div className="flex flex-col gap-6 justify-center items-stretch xl:flex-row">
+ {/* Organization Details Card */}
+ <div className="flex flex-col flex-1 gap-6 p-6 w-full rounded-2xl border min-h-fit bg-gray-3 border-gray-4">
+ {/* Card Header */}
+ <div className="space-y-2">
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[24px] w-[100px]"
+ />
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[16px] w-[280px]"
+ />
+ </div>
+
+ {Array(5).fill(0).map((_, index) => (
+ <div key={index} className="grid grid-cols-4 w-full">
+ <div className="col-span-3">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={60}
- height={16}
- className="mb-1"
+ className="h-[16px] w-[320px]"
/>
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={200}
- height={12}
+ className="h-[14px] w-[320px]"
/>
</div>
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- height={48}
- className="mt-4 rounded-xl"
- />
- </div>
-
- {/* Email domain field */}
- <div className="flex-1 space-y-2">
- <div>
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={120}
- height={16}
- className="mb-1"
- />
+ <div className="flex justify-end w-full">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={200}
- height={12}
+ className="!h-[40px] !w-[60px] !rounded-full"
/>
</div>
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- height={48}
- className="mt-4 rounded-xl"
- />
</div>
- </div>
-
- {/* Save button */}
- <div className="mt-8 mb-2">
+ ))}
+ {/* Upload Icon */}
+ <div className="flex justify-center items-center w-full h-[100px] border border-gray-5 rounded-xl">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={80}
- height={36}
- className="rounded-xl"
+ className="!h-[40px] !w-[60px] !rounded-full"
/>
</div>
</div>
- {/* Custom domain card */}
- <div className="flex-1 p-5 rounded-2xl border bg-gray-3 border-gray-4">
+
+ {/* Cap Settings Card */}
+ <div className="flex relative flex-col flex-1 gap-6 p-6 w-full rounded-2xl border min-h-fit bg-gray-3 border-gray-4">
+ {/* Card Header */}
<div className="space-y-2">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={100}
- height={16}
- className="mb-1"
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={300}
- height={12}
+ className="h-[24px] w-[120px]"
/>
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={280}
- height={12}
+ className="h-[16px] w-[250px]"
/>
</div>
- <div className="mt-4 space-y-4">
- {/* Domain input */}
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- height={48}
- className="rounded-xl"
- />
-
- {/* Status and buttons */}
- <div className="flex justify-between items-center">
+ {/* Coming Soon Overlay */}
+ <div className="relative">
+ <div className="absolute top-0 left-0 z-[20] rounded-xl flex items-center justify-center w-full h-full backdrop-blur-md bg-zinc-900/20">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={150}
- height={24}
- className="rounded-md"
+ className="!h-[32px] !w-[120px] !rounded-full"
/>
</div>
- <div className="flex flex-wrap justify-between mt-4">
+ {/* Tabs */}
+ <div className="flex gap-4 pb-4 mt-3 border-b border-gray-4">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={80}
- height={36}
- className="rounded-xl"
+ className="!h-[32px] !w-[100px] !rounded-xl"
/>
- <div className="flex gap-3">
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={100}
- height={36}
- className="rounded-xl"
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={100}
- height={36}
- className="rounded-xl"
- />
- </div>
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="!h-[32px] !w-[80px] !rounded-xl"
+ />
+ </div>
+
+ {/* Settings Items */}
+ <div className="mt-4 space-y-3">
+ {Array(6)
+ .fill(0)
+ .map((_, index) => (
+ <div
+ key={index}
+ className="flex justify-between items-center p-3 rounded-xl border border-gray-4"
+ >
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[16px] w-[150px]"
+ />
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="!h-[24px] !w-[44px] !rounded-full"
+ />
+ </div>
+ ))}
</div>
</div>
</div>
</div>
- {/* Members table */}
- <div className="p-5 rounded-2xl border bg-gray-3 border-gray-4">
- <div className="flex flex-wrap justify-between items-center mb-6">
- <div>
+ {/* Members Card */}
+ <div className="p-6 rounded-2xl border bg-gray-3 border-gray-4">
+ {/* Card Header */}
+ <div className="flex justify-between items-start mb-6">
+ <div className="space-y-2">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={80}
- height={20}
- className="mb-2"
+ className="h-[24px] w-[80px]"
/>
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={180}
- height={12}
+ className="h-[16px] w-[200px]"
/>
</div>
- <div className="flex gap-3">
+ <div className="flex flex-wrap gap-2">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={140}
- height={36}
- className="rounded-xl"
+ className="!h-[40px] !w-[150px] !rounded-full"
/>
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width={100}
- height={36}
- className="rounded-xl"
+ className="!h-[40px] !w-[120px] !rounded-full"
/>
</div>
</div>
- {/* Table */}
- <div className="mt-5">
- {/* Header */}
- <div className="py-3 border-b border-gray-5">
- <div className="flex gap-2">
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
+ {/* Members List */}
+ <div className="space-y-4">
+ {Array(3)
+ .fill(0)
+ .map((_, index) => (
+ <div key={index} className="flex justify-between items-center p-4 rounded-xl border border-gray-4">
+ <div className="flex gap-3 items-center">
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ circle
+ width={40}
+ height={40}
+ />
+ <div className="space-y-1">
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[16px] w-[120px]"
+ />
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[14px] w-[160px]"
+ />
+ </div>
+ </div>
+ <div className="flex gap-2 items-center">
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="!h-[32px] !w-[80px] !rounded-full"
+ />
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="!h-[32px] !w-[32px] !rounded-md"
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+
+ {/* Billing Card */}
+ <div className="p-6 rounded-2xl border bg-gray-3 border-gray-4">
+ {/* Card Header */}
+ <div className="flex justify-between items-start mb-6">
+ <div className="space-y-2">
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[24px] w-[80px]"
+ />
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[16px] w-[180px]"
+ />
+ </div>
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="!h-[40px] !w-[140px] !rounded-full"
+ />
+ </div>
+
+ {/* Billing Info */}
+ <div className="space-y-4">
+ <div className="flex justify-between items-center p-4 rounded-xl border border-gray-4">
+ <div className="space-y-1">
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width="16%"
- height={16}
+ className="h-[16px] w-[100px]"
/>
<Skeleton
baseColor="var(--gray-4)"
highlightColor="var(--gray-5)"
- width="16%"
- height={16}
+ className="h-[14px] w-[140px]"
/>
</div>
+ <Skeleton
+ baseColor="var(--gray-4)"
+ highlightColor="var(--gray-5)"
+ className="h-[20px] w-[60px]"
+ />
</div>
-
- {/* Rows */}
- {[1, 2, 3].map((i) => (
- <div key={i} className="py-4 border-b border-gray-5">
- <div className="flex gap-2">
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width="16%"
- height={16}
- />
- </div>
- </div>
- ))}
- </div>
- </div>
-
- {/* Billing section */}
- <div className="flex flex-wrap justify-between items-center p-5 rounded-2xl border bg-gray-3 border-gray-4">
- <div>
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={220}
- height={20}
- className="mb-2"
- />
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={300}
- height={12}
- />
</div>
- <Skeleton
- baseColor="var(--gray-4)"
- highlightColor="var(--gray-5)"
- width={120}
- height={36}
- className="rounded-xl"
- />
</div>
- </div>
- )}
+ </div >
+ )
+ }
/>
);
}
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index 569b5698a..88f28d334 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -67,8 +67,13 @@ html {
border-radius: 10px;
}
+.dark ::selection {
+ background: #ffffff;
+ color: #000000;
+}
+
::selection {
- background: black;
+ background: #000000;
color: #ffffff;
}
diff --git a/apps/web/components/FileInput.tsx b/apps/web/components/FileInput.tsx
index d3f3e0498..247accbbc 100644
--- a/apps/web/components/FileInput.tsx
+++ b/apps/web/components/FileInput.tsx
@@ -1,12 +1,13 @@
"use client";
import { Button, Input } from "@cap/ui";
-import { faCloudUpload, faSpinner } from "@fortawesome/free-solid-svg-icons";
+import { faCloudUpload, faSpinner, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import Image from "next/image";
import React, { useEffect, useRef, useState } from "react";
import { toast } from "sonner";
+import { Tooltip } from "./Tooltip";
export interface FileInputProps {
onChange?: (file: File | null) => void;
@@ -18,6 +19,8 @@ export interface FileInputProps {
initialPreviewUrl?: string | null;
onRemove?: () => void;
isLoading?: boolean;
+ height?: string | number;
+ previewIconSize?: string | number;
}
export const FileInput: React.FC<FileInputProps> = ({
@@ -30,6 +33,8 @@ export const FileInput: React.FC<FileInputProps> = ({
initialPreviewUrl = null,
onRemove,
isLoading = false,
+ height = "44px",
+ previewIconSize = 20,
}) => {
const fileInputRef = useRef<HTMLInputElement>(null);
const [isDragging, setIsDragging] = useState(false);
@@ -176,11 +181,13 @@ export const FileInput: React.FC<FileInputProps> = ({
return (
<div className={`relative ${className}`}>
- <div className="h-[44px]">
+ <div style={{
+ height: height,
+ }}>
{" "}
{/* Fixed height container to prevent resizing */}
{selectedFile || previewUrl ? (
- <div className="flex gap-2 items-center p-1.5 rounded-xl border bg-gray-1 border-gray-4 h-full">
+ <div className="flex gap-2 items-center p-1.5 rounded-xl border border-dashed bg-gray-1 border-gray-4 h-full">
<div className="flex flex-1 gap-1.5 items-center">
<div className="flex flex-1 gap-1 items-center">
{selectedFile ? (
@@ -193,17 +200,21 @@ export const FileInput: React.FC<FileInputProps> = ({
</p>
</>
) : (
- <div className="flex gap-2 items-center">
+ <div className="flex gap-2 items-center px-2">
<p className="text-xs font-medium text-gray-12">
Current icon:{" "}
</p>
- <div className="overflow-hidden relative flex-shrink-0 rounded-md size-5">
+ <div style={{
+ width: previewIconSize,
+ height: previewIconSize,
+ }} className="overflow-hidden relative flex-shrink-0 rounded-md">
{previewUrl && (
<Image
src={previewUrl}
+ width={36}
+ height={36}
alt="File preview"
- fill
- className="object-contain rounded-full"
+ className="object-cover rounded-full"
/>
)}
</div>
@@ -211,19 +222,19 @@ export const FileInput: React.FC<FileInputProps> = ({
)}
</div>
</div>
- <Button
- variant="destructive"
- size="xs"
- disabled={isLoading || disabled}
- onClick={handleRemove}
- style={
- {
- "--gradient-border-radius": "8px",
- } as React.CSSProperties
- }
+ <Tooltip
+ content="Remove icon"
>
- Remove
- </Button>
+ <Button
+ variant="outline"
+ size="xs"
+ className="!p-0 size-8 group mr-2"
+ disabled={isLoading || disabled}
+ onClick={handleRemove}
+ >
+ <FontAwesomeIcon className="size-2.5 text-gray-12 group-hover:text-gray-1" icon={faTrash} />
+ </Button>
+ </Tooltip>
</div>
) : (
<div