Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Refactor organization and cleanups (#517)
Ameer Al Ashhab197dcbeb3d92
diff --git a/apps/web/app/dashboard/caps/Caps.tsx b/apps/web/app/dashboard/caps/Caps.tsxindex f29f35c14..7a2086be0 100644--- a/apps/web/app/dashboard/caps/Caps.tsx+++ b/apps/web/app/dashboard/caps/Caps.tsx@@ -1,19 +1,16 @@"use client";+import { deleteVideo } from "@/actions/videos/delete";import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";import { useApiClient } from "@/utils/web-api";import { VideoMetadata } from "@cap/database/types";-import { AnimatePresence, motion } from "framer-motion";import { useRouter, useSearchParams } from "next/navigation";import { useEffect, useRef, useState } from "react";import { toast } from "sonner";import { CapCard } from "./components/CapCard";import { CapPagination } from "./components/CapPagination";import { EmptyCapState } from "./components/EmptyCapState";-import { Button } from "@cap/ui";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { faTrash } from "@fortawesome/free-solid-svg-icons";-import { deleteVideo } from "@/actions/videos/delete";-import NumberFlow from "@number-flow/react";+import { SelectedCapsBar } from "./components/SelectedCapsBar";+type VideoData = {id: string;@@ -24,7 +21,7 @@ type VideoData = {totalReactions: number;sharedOrganizations: { id: string; name: string }[];ownerName: string;- metadata?: VideoMetadata;+ metadata?: VideoMetadata}[];export const Caps = ({@@ -45,7 +42,7 @@ export const Caps = ({const totalPages = Math.ceil(count / limit);const [selectedCaps, setSelectedCaps] = useState<string[]>([]);const previousCountRef = useRef<number>(0);- const [animateDirection, setAnimateDirection] = useState<"up" | "down">("up");+ const [, setAnimateDirection] = useState<"up" | "down">("up");const [isDeleting, setIsDeleting] = useState(false);const anyCapSelected = selectedCaps.length > 0;@@ -236,55 +233,12 @@ export const Caps = ({)}- <AnimatePresence>- {selectedCaps.length > 0 && (- <motion.div- className="flex fixed right-0 left-0 bottom-4 z-50 justify-between items-center px-6 py-3 mx-auto w-full max-w-xl rounded-xl border shadow-lg border-gray-3 bg-gray-2"- initial={{ opacity: 0, y: 10, scale: 0.9 }}- animate={{ opacity: 1, y: 0, scale: 1 }}- exit={{- opacity: 0,- y: 10,- scale: 0.9,- transition: { duration: 0.2 },- }}- transition={{- type: "spring",- damping: 15,- stiffness: 200,- }}- >- <div className="flex gap-1 text-sm font-medium text-gray-10">- <NumberFlow- value={selectedCaps.length}- className="tabular-nums text-md text-gray-12"- />- cap{selectedCaps.length !== 1 ? "s" : ""} selected- </div>- <div className="flex gap-2 ml-4">- <Button- variant="dark"- onClick={() => setSelectedCaps([])}- className="text-sm"- size="sm"- >- Cancel- </Button>- <Button- style={{ minWidth: "auto" }}- variant="destructive"- onClick={deleteSelectedCaps}- disabled={isDeleting}- className="text-sm w-[40px]"- spinner={isDeleting}- size="sm"- >- <FontAwesomeIcon icon={faTrash} />- </Button>- </div>- </motion.div>- )}- </AnimatePresence>+ <SelectedCapsBar+ selectedCaps={selectedCaps}+ setSelectedCaps={setSelectedCaps}+ deleteSelectedCaps={deleteSelectedCaps}+ isDeleting={isDeleting}+ /></div>);};diff --git a/apps/web/app/dashboard/caps/components/SelectedCapsBar.tsx b/apps/web/app/dashboard/caps/components/SelectedCapsBar.tsxnew file mode 100644index 000000000..6b74a12b8--- /dev/null+++ b/apps/web/app/dashboard/caps/components/SelectedCapsBar.tsx@@ -0,0 +1,73 @@+"use client";++import { Button } from "@cap/ui";+import { faTrash } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { AnimatePresence, motion } from "framer-motion";+import NumberFlow from "@number-flow/react";++interface SelectedCapsBarProps {+ selectedCaps: string[];+ setSelectedCaps: (caps: string[]) => void;+ deleteSelectedCaps: () => void;+ isDeleting: boolean;+}++export const SelectedCapsBar = ({+ selectedCaps,+ setSelectedCaps,+ deleteSelectedCaps,+ isDeleting+}: SelectedCapsBarProps) => {+ return (+ <AnimatePresence>+ {selectedCaps.length > 0 && (+ <motion.div+ className="flex fixed right-0 left-0 bottom-4 z-50 justify-between items-center px-6 py-3 mx-auto w-full max-w-xl rounded-xl border shadow-lg border-gray-3 bg-gray-2"+ initial={{ opacity: 0, y: 10, scale: 0.9 }}+ animate={{ opacity: 1, y: 0, scale: 1 }}+ exit={{+ opacity: 0,+ y: 10,+ scale: 0.9,+ transition: { duration: 0.2 },+ }}+ transition={{+ type: "spring",+ damping: 15,+ stiffness: 200,+ }}+ >+ <div className="flex gap-1 text-sm font-medium text-gray-10">+ <NumberFlow+ value={selectedCaps.length}+ className="tabular-nums text-md text-gray-12"+ />+ cap{selectedCaps.length !== 1 ? "s" : ""} selected+ </div>+ <div className="flex gap-2 ml-4">+ <Button+ variant="dark"+ onClick={() => setSelectedCaps([])}+ className="text-sm"+ size="sm"+ >+ Cancel+ </Button>+ <Button+ style={{ minWidth: "auto" }}+ variant="destructive"+ onClick={deleteSelectedCaps}+ disabled={isDeleting}+ className="text-sm w-[40px]"+ spinner={isDeleting}+ size="sm"+ >+ <FontAwesomeIcon icon={faTrash} />+ </Button>+ </div>+ </motion.div>+ )}+ </AnimatePresence>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/Organization.tsx b/apps/web/app/dashboard/settings/organization/Organization.tsxindex 4f0f71ba6..4be5e3718 100644--- a/apps/web/app/dashboard/settings/organization/Organization.tsx+++ b/apps/web/app/dashboard/settings/organization/Organization.tsx@@ -1,38 +1,22 @@"use client";import { manageBilling } from "@/actions/organization/manage-billing";-import { removeOrganizationInvite } from "@/actions/organization/remove-invite";-import { sendOrganizationInvites } from "@/actions/organization/send-invites";import { updateOrganizationDetails } from "@/actions/organization/update-details";import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";-import { Tooltip } from "@/components/Tooltip";import {- Button,Card,CardDescription,- CardHeader,- CardTitle,- Dialog,- DialogContent,- DialogFooter,- DialogHeader,- DialogTitle,- Input,- Label,- Table,- TableBody,- TableCell,- TableHead,- TableHeader,- TableRow+ CardTitle} from "@cap/ui";-import { faChair, faUserGroup } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { format } from "date-fns";import { useRouter } from "next/navigation";-import { useRef, useState } from "react";+import { useCallback, useRef, useState } from "react";import { toast } from "sonner";-import { CustomDomain } from "./components/CustomDomain";+import { BillingCard } from "./components/BillingCard";+import { CustomDomainCard } from "./components/CustomDomainCard";+import { InviteDialog } from "./components/InviteDialog";+import { MembersCard } from "./components/MembersCard";+import { OrganizationDetailsCard } from "./components/OrganizationDetailsCard";+import { SeatsInfoCards } from "./components/SeatsInfoCards";export const Organization = () => {const { activeOrganization, user } = useSharedContext();@@ -41,12 +25,10 @@ export const Organization = () => {const [loading, setLoading] = useState(false);const isOwner = user?.id === activeOrganization?.organization.ownerId;const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);- const [inviteEmails, setInviteEmails] = useState<string[]>([]);- const [emailInput, setEmailInput] = useState("");const ownerToastShown = useRef(false);- const [inviteLoading, setInviteLoading] = useState(false);+ const [saveLoading, setSaveLoading] = useState(false);- const showOwnerToast = () => {+ const showOwnerToast = useCallback(() => {if (!ownerToastShown.current) {toast.error("Only the owner can make changes");ownerToastShown.current = true;@@ -54,9 +36,9 @@ export const Organization = () => {ownerToastShown.current = false;}, 3000);}- };+ }, []);- const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {+ const handleSubmit = useCallback(async (e: React.FormEvent<HTMLFormElement>) => {e.preventDefault();if (!isOwner) {@@ -69,6 +51,7 @@ export const Organization = () => {const allowedEmailDomain = formData.get("allowedEmailDomain") as string;try {+ setSaveLoading(true);await updateOrganizationDetails(organizationName,allowedEmailDomain,@@ -79,66 +62,14 @@ export const Organization = () => {} catch (error) {console.error("Error updating settings:", error);toast.error("An error occurred while updating settings");- }- };-- const handleAddEmails = () => {- const newEmails = emailInput- .split(",")- .map((email) => email.trim())- .filter((email) => email !== "");- setInviteEmails([...new Set([...inviteEmails, ...newEmails])]);- setEmailInput("");- };-- const handleRemoveEmail = (email: string) => {- setInviteEmails(inviteEmails.filter((e) => e !== email));- };-- const handleSendInvites = async () => {- if (!isOwner) {- showOwnerToast();- return;- }-- try {- setInviteLoading(true);- await sendOrganizationInvites(- inviteEmails,- activeOrganization?.organization.id as string- );- toast.success("Invites sent successfully");- setInviteEmails([]);- setIsInviteDialogOpen(false);- router.refresh();- } catch (error) {- console.error("Error sending invites:", error);- toast.error("An error occurred while sending invites");} finally {- setInviteLoading(false);+ setSaveLoading(false);}- };+ }, [isOwner, showOwnerToast, activeOrganization?.organization.id, router]);- const handleDeleteInvite = async (inviteId: string) => {- if (!isOwner) {- showOwnerToast();- return;- }- try {- await removeOrganizationInvite(- inviteId,- activeOrganization?.organization.id as string- );- toast.success("Invite deleted successfully");- router.refresh();- } catch (error) {- console.error("Error deleting invite:", error);- toast.error("An error occurred while deleting invite");- }- };- const handleManageBilling = async () => {+ const handleManageBilling = useCallback(async () => {if (!isOwner) {showOwnerToast();return;@@ -153,7 +84,7 @@ export const Organization = () => {toast.error("An error occurred while managing billing");setLoading(false);}- };+ }, [isOwner, showOwnerToast, router]);return (<form className="flex flex-col gap-6" onSubmit={handleSubmit}>@@ -166,332 +97,38 @@ export const Organization = () => {</Card>)}- <div className="flex flex-col flex-1 gap-6 justify-center lg:flex-row">- <Card className="flex flex-col flex-1 gap-3 justify-center items-center">- <FontAwesomeIcon className="text-gray-10 size-5" icon={faChair} />- <p className="text-gray-12">- Seats Remaining- <span className="ml-2 font-bold text-gray-12">- {(activeOrganization?.inviteQuota ?? 1) -- (activeOrganization?.totalInvites ?? 0)}- </span>- </p>- </Card>- <Card className="flex flex-col flex-1 gap-3 justify-center items-center">- <FontAwesomeIcon className="text-gray-10 size-5" icon={faUserGroup} />- <p className="text-gray-12">- Seats Capacity- <span className="ml-2 font-bold text-gray-12">- {activeOrganization?.inviteQuota}- </span>- </p>- </Card>- </div>+ <SeatsInfoCards /><div className="flex flex-col flex-1 gap-6 justify-center items-stretch xl:flex-row">- <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="mt-1 text-sm text-gray-10">- Only emails from this domain can access shared videos.{" "}- <b>Leave blank to allow everyone.</b>- </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 w-fit"- type="submit"- size="sm"- variant="dark"- disabled={!isOwner}- onClick={() => {- if (!isOwner) showOwnerToast();- }}- >- Save- </Button>- </Card>- <Card className="flex flex-col flex-1 gap-6 w-full lg:flex-row">- <div className="flex-1">- <div className="space-y-1">- <Label htmlFor="customDomain">Custom Domain</Label>- <CardDescription className="w-full max-w-[400px]">- Set up a custom domain for your organization's shared caps and- make it unique.- </CardDescription>- </div>- <div className="mt-4">- <CustomDomain />- </div>- </div>- {/* <div className="flex-1"> */}- {/* <div className="space-y-1">- <Label htmlFor="icon">Icon</Label>- <CardDescription className="w-full max-w-[400px]">- Upload a custom logo or icon for your workspace and make it- unique.- </CardDescription>- </div> */}- {/* <div- onClick={() => fileInputRef.current?.click()}- className="w-full hover:bg-gray-1 transition-all duration-300 gap-3 border-gray-300 mt-4 border px-4 flex items-center justify-center py-[14px] border-dashed rounded-2xl"- >- <FontAwesomeIcon- className="text-gray-10 size-5"- icon={faCloudUpload}- />- <p className="text-xs truncate text-gray-10">- Choose a file or drag & drop it here- </p>- </div> */}- {/* <Input- className="hidden"- type="file"- ref={fileInputRef}- id="icon"- disabled={!isOwner}- onChange={() => {- if (!isOwner) showOwnerToast();- }}- name="icon"- />- </div> */}- </Card>+ <OrganizationDetailsCard+ isOwner={isOwner}+ saveLoading={saveLoading}+ showOwnerToast={showOwnerToast}+ organizationName={organizationName}+ />+ <CustomDomainCard /></div>- <Card>- <div className="flex flex-wrap gap-6 justify-between items-center w-full">- <CardHeader>- <CardTitle>Members</CardTitle>- <CardDescription>Manage your organization members.</CardDescription>- </CardHeader>- <div className="flex flex-wrap gap-3">- <Tooltip- position="top"- content="Once inside the Stripe dashboard, click 'Manage Plan', then increase quantity of subscriptions to purchase more seats"- >- <Button- type="button"- size="sm"- variant="primary"- disabled={!isOwner || loading}- onClick={handleManageBilling}- >- {loading ? "Loading..." : "+ Purchase more seats"}- </Button>- </Tooltip>- <Button- type="button"- size="sm"- variant="dark"- onClick={() => {- if (!isOwner) {- showOwnerToast();- } else if (- activeOrganization &&- activeOrganization.inviteQuota <=- activeOrganization.totalInvites- ) {- toast.error(- "Invite limit reached, please purchase more seats"- );- } else {- setIsInviteDialogOpen(true);- }- }}- disabled={!isOwner}- >- + Invite users- </Button>- </div>- </div>- <Table className="mt-5">- <TableHeader>- <TableRow>- <TableHead>{"Member"}</TableHead>- <TableHead>{"Email"}</TableHead>- <TableHead>{"Role"}</TableHead>- <TableHead>{"Joined"}</TableHead>- <TableHead>{"Status"}</TableHead>- <TableHead>{"Actions"}</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {activeOrganization?.members &&- activeOrganization.members.map((member) => (- <TableRow key={member.id}>- <TableCell>{member.user.name}</TableCell>- <TableCell>{member.user.email}</TableCell>- <TableCell>- {member.user.id === activeOrganization?.organization.ownerId- ? "Owner"- : "Member"}- </TableCell>- <TableCell>- {format(member.createdAt, "MMM d, yyyy")}- </TableCell>- <TableCell>Active</TableCell>- <TableCell>-</TableCell>- </TableRow>- ))}- {activeOrganization?.invites &&- activeOrganization.invites.map((invite) => (- <TableRow key={invite.id}>- <TableCell>{invite.id}</TableCell>- <TableCell>{invite.invitedEmail}</TableCell>- <TableCell>Member</TableCell>- <TableCell>-</TableCell>- <TableCell>Invited</TableCell>- <TableCell>- <Button- type="button"- size="xs"- variant="destructive"- onClick={() => {- if (isOwner) {- handleDeleteInvite(invite.id);- } else {- showOwnerToast();- }- }}- disabled={!isOwner}- >- Delete Invite- </Button>- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- </Card>- <Card className="flex flex-wrap gap-6 justify-between items-center w-full">- <CardHeader>- <CardTitle>View and manage your billing details</CardTitle>- <CardDescription>- View and edit your billing details, as well as manage your- subscription.- </CardDescription>- </CardHeader>- <Button- type="button"- size="sm"- variant="dark"- onClick={handleManageBilling}- disabled={!isOwner}- >- {loading ? "Loading..." : "Manage Billing"}- </Button>- </Card>-- <Dialog open={isInviteDialogOpen} onOpenChange={setIsInviteDialogOpen}>- <DialogContent className="p-0 w-full max-w-md rounded-xl border bg-gray-2 border-gray-4">- <DialogHeader- icon={<FontAwesomeIcon icon={faUserGroup} className="size-3.5" />}- description="Invite your teammates to join the organization"- >- <DialogTitle>- Invite to{" "}- <span className="font-bold text-gray-12">- {activeOrganization?.organization.name}- </span>- </DialogTitle>- </DialogHeader>- <div className="p-5">- <Input- id="emails"- value={emailInput}- onChange={(e) => setEmailInput(e.target.value)}- placeholder="[email protected]"- onBlur={handleAddEmails}- onKeyDown={(e) => {- if (e.key === "Enter" || e.key === ",") {- e.preventDefault();- handleAddEmails();- }- }}- />- <div className="flex overflow-y-auto flex-col gap-2.5 mt-4 max-h-60">- {inviteEmails.map((email) => (- <div- key={email}- className="flex justify-between items-center p-3 rounded-xl border transition-colors duration-200 cursor-pointer border-gray-3"- >- <span className="text-sm text-gray-12">{email}</span>- <Button- style={{- "--gradient-border-radius": "8px",- } as React.CSSProperties}- type="button"- variant="destructive"- size="xs"- onClick={() => handleRemoveEmail(email)}- disabled={!isOwner}- >- Remove- </Button>- </div>- ))}- </div>- </div>- <DialogFooter className="p-5 border-t border-gray-4">- <Button- type="button"- size="sm"- variant="gray"- onClick={() => setIsInviteDialogOpen(false)}- >- Cancel- </Button>- <Button- type="button"- size="sm"- variant="dark"- spinner={inviteLoading}- disabled={inviteLoading || inviteEmails.length === 0}- onClick={handleSendInvites}- >- Send Invites- </Button>- </DialogFooter>- </DialogContent>- </Dialog>+ <MembersCard+ isOwner={isOwner}+ loading={loading}+ handleManageBilling={handleManageBilling}+ showOwnerToast={showOwnerToast}+ setIsInviteDialogOpen={setIsInviteDialogOpen}+ />++ <BillingCard+ isOwner={isOwner}+ loading={loading}+ handleManageBilling={handleManageBilling}+ />++ <InviteDialog+ isOpen={isInviteDialogOpen}+ setIsOpen={setIsInviteDialogOpen}+ isOwner={isOwner}+ showOwnerToast={showOwnerToast}+ /></form>);};diff --git a/apps/web/app/dashboard/settings/organization/components/BillingCard.tsx b/apps/web/app/dashboard/settings/organization/components/BillingCard.tsxnew file mode 100644index 000000000..614a1e889--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/BillingCard.tsx@@ -0,0 +1,43 @@+"use client";++import {+ Button,+ Card,+ CardDescription,+ CardHeader,+ CardTitle+} from "@cap/ui";+++interface BillingCardProps {+ isOwner: boolean;+ loading: boolean;+ handleManageBilling: () => Promise<void>;+}++export const BillingCard = ({+ isOwner,+ loading,+ handleManageBilling+}: BillingCardProps) => {+ return (+ <Card className="flex flex-wrap gap-6 justify-between items-center w-full">+ <CardHeader>+ <CardTitle>View and manage your billing details</CardTitle>+ <CardDescription>+ View and edit your billing details, as well as manage your+ subscription.+ </CardDescription>+ </CardHeader>+ <Button+ type="button"+ size="sm"+ variant="dark"+ onClick={handleManageBilling}+ disabled={!isOwner}+ >+ {loading ? "Loading..." : "Manage Billing"}+ </Button>+ </Card>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/components/CustomDomain.tsx b/apps/web/app/dashboard/settings/organization/components/CustomDomain.tsxindex 12320082b..cc29a23e8 100644--- a/apps/web/app/dashboard/settings/organization/components/CustomDomain.tsx+++ b/apps/web/app/dashboard/settings/organization/components/CustomDomain.tsx@@ -5,6 +5,7 @@ import { checkOrganizationDomain } from "@/actions/organization/check-domain";import { removeOrganizationDomain } from "@/actions/organization/remove-domain";import { updateDomain } from "@/actions/organization/update-domain";import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import { UpgradeModal } from "@/components/UpgradeModal";import { Button, Input } from "@cap/ui";import { faRefresh, faTrash } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";@@ -12,7 +13,6 @@ import { Check, CheckCircle, Copy, XCircle } from "lucide-react";import { useRouter } from "next/navigation";import { useEffect, useRef, useState } from "react";import { toast } from "sonner";-import { UpgradeModal } from "@/components/UpgradeModal";type DomainVerification = {type: string;@@ -32,15 +32,6 @@ type DomainConfig = {requiredAValue?: string;};-type VerificationResponse = {- verified: boolean;- config: DomainConfig;- status: any;- aRecordConfig?: {- current: string;- required: string;- };-};export function CustomDomain() {const router = useRouter();@@ -276,6 +267,7 @@ export function CustomDomain() {size="sm"variant="dark"onClick={handleSubmit}+ spinner={loading}disabled={loading}>{loading ? "Saving..." : "Save"}diff --git a/apps/web/app/dashboard/settings/organization/components/CustomDomainCard.tsx b/apps/web/app/dashboard/settings/organization/components/CustomDomainCard.tsxnew file mode 100644index 000000000..f8ac85efe--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/CustomDomainCard.tsx@@ -0,0 +1,23 @@+"use client";++import { Card, CardDescription, Label } from "@cap/ui";+import { CustomDomain } from "./CustomDomain";++export const CustomDomainCard = () => {+ return (+ <Card className="flex flex-col flex-1 gap-6 w-full lg:flex-row">+ <div className="flex-1">+ <div className="space-y-1">+ <Label htmlFor="customDomain">Custom Domain</Label>+ <CardDescription className="w-full max-w-[400px]">+ Set up a custom domain for your organization's shared caps and+ make it unique.+ </CardDescription>+ </div>+ <div className="mt-4">+ <CustomDomain />+ </div>+ </div>+ </Card>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/components/InviteDialog.tsx b/apps/web/app/dashboard/settings/organization/components/InviteDialog.tsxnew file mode 100644index 000000000..0939d2022--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/InviteDialog.tsx@@ -0,0 +1,150 @@+"use client";++import { sendOrganizationInvites } from "@/actions/organization/send-invites";+import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import {+ Button,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Input+} from "@cap/ui";+import { faUserGroup } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { useRouter } from "next/navigation";+import { useState } from "react";+import { toast } from "sonner";++interface InviteDialogProps {+ isOpen: boolean;+ setIsOpen: (isOpen: boolean) => void;+ isOwner: boolean;+ showOwnerToast: () => void;+}++export const InviteDialog = ({+ isOpen,+ setIsOpen,+ isOwner,+ showOwnerToast+}: InviteDialogProps) => {+ const router = useRouter();+ const { activeOrganization } = useSharedContext();+ const [inviteEmails, setInviteEmails] = useState<string[]>([]);+ const [emailInput, setEmailInput] = useState("");+ const [inviteLoading, setInviteLoading] = useState(false);++ const handleAddEmails = () => {+ const newEmails = emailInput+ .split(",")+ .map((email) => email.trim())+ .filter((email) => email !== "");+ setInviteEmails([...new Set([...inviteEmails, ...newEmails])]);+ setEmailInput("");+ };++ const handleRemoveEmail = (email: string) => {+ setInviteEmails(inviteEmails.filter((e) => e !== email));+ };++ const handleSendInvites = async () => {+ if (!isOwner) {+ showOwnerToast();+ return;+ }++ try {+ setInviteLoading(true);+ await sendOrganizationInvites(+ inviteEmails,+ activeOrganization?.organization.id as string+ );+ toast.success("Invites sent successfully");+ setInviteEmails([]);+ setIsOpen(false);+ router.refresh();+ } catch (error) {+ console.error("Error sending invites:", error);+ toast.error("An error occurred while sending invites");+ } finally {+ setInviteLoading(false);+ }+ };++ return (+ <Dialog open={isOpen} onOpenChange={setIsOpen}>+ <DialogContent className="p-0 w-full max-w-md rounded-xl border bg-gray-2 border-gray-4">+ <DialogHeader+ icon={<FontAwesomeIcon icon={faUserGroup} className="size-3.5" />}+ description="Invite your teammates to join the organization"+ >+ <DialogTitle>+ Invite to{" "}+ <span className="font-bold text-gray-12">+ {activeOrganization?.organization.name}+ </span>+ </DialogTitle>+ </DialogHeader>+ <div className="p-5">+ <Input+ id="emails"+ value={emailInput}+ onChange={(e) => setEmailInput(e.target.value)}+ placeholder="[email protected]"+ onBlur={handleAddEmails}+ onKeyDown={(e) => {+ if (e.key === "Enter" || e.key === ",") {+ e.preventDefault();+ handleAddEmails();+ }+ }}+ />+ <div className="flex overflow-y-auto flex-col gap-2.5 mt-4 max-h-60">+ {inviteEmails.map((email) => (+ <div+ key={email}+ className="flex justify-between items-center p-3 rounded-xl border transition-colors duration-200 cursor-pointer border-gray-3"+ >+ <span className="text-sm text-gray-12">{email}</span>+ <Button+ style={{+ "--gradient-border-radius": "8px",+ } as React.CSSProperties}+ type="button"+ variant="destructive"+ size="xs"+ onClick={() => handleRemoveEmail(email)}+ disabled={!isOwner}+ >+ Remove+ </Button>+ </div>+ ))}+ </div>+ </div>+ <DialogFooter className="p-5 border-t border-gray-4">+ <Button+ type="button"+ size="sm"+ variant="gray"+ onClick={() => setIsOpen(false)}+ >+ Cancel+ </Button>+ <Button+ type="button"+ size="sm"+ variant="dark"+ spinner={inviteLoading}+ disabled={inviteLoading || inviteEmails.length === 0}+ onClick={handleSendInvites}+ >+ Send Invites+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/components/MembersCard.tsx b/apps/web/app/dashboard/settings/organization/components/MembersCard.tsxnew file mode 100644index 000000000..52cc42feb--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/MembersCard.tsx@@ -0,0 +1,168 @@+"use client";++import { removeOrganizationInvite } from "@/actions/organization/remove-invite";+import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import { Tooltip } from "@/components/Tooltip";+import {+ Button,+ Card,+ CardDescription,+ CardHeader,+ CardTitle,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow+} from "@cap/ui";+import { format } from "date-fns";+import { useRouter } from "next/navigation";++import { toast } from "sonner";++interface MembersCardProps {+ isOwner: boolean;+ loading: boolean;+ handleManageBilling: () => Promise<void>;+ showOwnerToast: () => void;+ setIsInviteDialogOpen: (isOpen: boolean) => void;+}++export const MembersCard = ({+ isOwner,+ loading,+ handleManageBilling,+ showOwnerToast,+ setIsInviteDialogOpen+}: MembersCardProps) => {+ const router = useRouter();+ const { activeOrganization } = useSharedContext();++ const handleDeleteInvite = async (inviteId: string) => {+ if (!isOwner) {+ showOwnerToast();+ return;+ }++ try {+ await removeOrganizationInvite(+ inviteId,+ activeOrganization?.organization.id as string+ );+ toast.success("Invite deleted successfully");+ router.refresh();+ } catch (error) {+ console.error("Error deleting invite:", error);+ toast.error("An error occurred while deleting invite");+ }+ };++ return (+ <Card>+ <div className="flex flex-wrap gap-6 justify-between items-center w-full">+ <CardHeader>+ <CardTitle>Members</CardTitle>+ <CardDescription>Manage your organization members.</CardDescription>+ </CardHeader>+ <div className="flex flex-wrap gap-3">+ <Tooltip+ position="top"+ content="Once inside the Stripe dashboard, click 'Manage Plan', then increase quantity of subscriptions to purchase more seats"+ >+ <Button+ type="button"+ size="sm"+ variant="primary"+ disabled={!isOwner || loading}+ onClick={handleManageBilling}+ >+ {loading ? "Loading..." : "+ Purchase more seats"}+ </Button>+ </Tooltip>+ <Button+ type="button"+ size="sm"+ variant="dark"+ onClick={() => {+ if (!isOwner) {+ showOwnerToast();+ } else if (+ activeOrganization &&+ activeOrganization.inviteQuota <=+ activeOrganization.totalInvites+ ) {+ toast.error(+ "Invite limit reached, please purchase more seats"+ );+ } else {+ setIsInviteDialogOpen(true);+ }+ }}+ disabled={!isOwner}+ >+ + Invite users+ </Button>+ </div>+ </div>+ <Table className="mt-5">+ <TableHeader>+ <TableRow>+ <TableHead>{"Member"}</TableHead>+ <TableHead>{"Email"}</TableHead>+ <TableHead>{"Role"}</TableHead>+ <TableHead>{"Joined"}</TableHead>+ <TableHead>{"Status"}</TableHead>+ <TableHead>{"Actions"}</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {activeOrganization?.members &&+ activeOrganization.members.map((member) => (+ <TableRow key={member.id}>+ <TableCell>{member.user.name}</TableCell>+ <TableCell>{member.user.email}</TableCell>+ <TableCell>+ {member.user.id === activeOrganization?.organization.ownerId+ ? "Owner"+ : "Member"}+ </TableCell>+ <TableCell>+ {format(member.createdAt, "MMM d, yyyy")}+ </TableCell>+ <TableCell>Active</TableCell>+ <TableCell>-</TableCell>+ </TableRow>+ ))}+ {activeOrganization?.invites &&+ activeOrganization.invites.map((invite) => (+ <TableRow key={invite.id}>+ <TableCell>{invite.id}</TableCell>+ <TableCell>{invite.invitedEmail}</TableCell>+ <TableCell>Member</TableCell>+ <TableCell>-</TableCell>+ <TableCell>Invited</TableCell>+ <TableCell>+ <Button+ type="button"+ size="xs"+ variant="destructive"+ onClick={() => {+ if (isOwner) {+ handleDeleteInvite(invite.id);+ } else {+ showOwnerToast();+ }+ }}+ disabled={!isOwner}+ >+ Delete Invite+ </Button>+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </Card>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/components/OrganizationDetailsCard.tsx b/apps/web/app/dashboard/settings/organization/components/OrganizationDetailsCard.tsxnew file mode 100644index 000000000..6bdd65a3a--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/OrganizationDetailsCard.tsx@@ -0,0 +1,88 @@+"use client";++import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import {+ Button,+ Card,+ Input,+ Label+} from "@cap/ui";++interface OrganizationDetailsCardProps {+ isOwner: boolean;+ saveLoading: boolean;+ showOwnerToast: () => void;+ organizationName: string | undefined;+}++export const OrganizationDetailsCard = ({+ isOwner,+ saveLoading,+ showOwnerToast,+ organizationName+}: OrganizationDetailsCardProps) => {+ const { activeOrganization } = useSharedContext();++ 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="mt-1 text-sm text-gray-10">+ Only emails from this domain can access shared videos.{" "}+ <b>Leave blank to allow everyone.</b>+ </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 w-fit"+ type="submit"+ spinner={saveLoading}+ size="sm"+ variant="dark"+ disabled={!isOwner || saveLoading}+ onClick={() => {+ if (!isOwner) showOwnerToast();+ }}+ >+ {saveLoading ? "Saving..." : "Save"}+ </Button>+ </Card>+ );+};diff --git a/apps/web/app/dashboard/settings/organization/components/SeatsInfoCards.tsx b/apps/web/app/dashboard/settings/organization/components/SeatsInfoCards.tsxnew file mode 100644index 000000000..a5c5c1c92--- /dev/null+++ b/apps/web/app/dashboard/settings/organization/components/SeatsInfoCards.tsx@@ -0,0 +1,34 @@+"use client";++import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import { Card } from "@cap/ui";+import { faChair, faUserGroup } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++export const SeatsInfoCards = () => {+ const { activeOrganization } = useSharedContext();++ return (+ <div className="flex flex-col flex-1 gap-6 justify-center lg:flex-row">+ <Card className="flex flex-col flex-1 gap-3 justify-center items-center">+ <FontAwesomeIcon className="text-gray-10 size-5" icon={faChair} />+ <p className="text-gray-12">+ Seats Remaining+ <span className="ml-2 font-bold text-gray-12">+ {(activeOrganization?.inviteQuota ?? 1) -+ (activeOrganization?.totalInvites ?? 0)}+ </span>+ </p>+ </Card>+ <Card className="flex flex-col flex-1 gap-3 justify-center items-center">+ <FontAwesomeIcon className="text-gray-10 size-5" icon={faUserGroup} />+ <p className="text-gray-12">+ Seats Capacity+ <span className="ml-2 font-bold text-gray-12">+ {activeOrganization?.inviteQuota}+ </span>+ </p>+ </Card>+ </div>+ );+};diff --git a/apps/web/app/dashboard/shared-caps/SharedCaps.tsx b/apps/web/app/dashboard/shared-caps/SharedCaps.tsxindex db005ec11..f188d0dbb 100644--- a/apps/web/app/dashboard/shared-caps/SharedCaps.tsx+++ b/apps/web/app/dashboard/shared-caps/SharedCaps.tsx@@ -22,11 +22,9 @@ type SharedVideoData = {export const SharedCaps = ({data,count,- activeOrganizationId,}: {data: SharedVideoData;count: number;- activeOrganizationId: string;}) => {const params = useSearchParams();const page = Number(params.get("page")) || 1;diff --git a/apps/web/app/dashboard/shared-caps/page.tsx b/apps/web/app/dashboard/shared-caps/page.tsxindex 28e397ab0..28ed6a724 100644--- a/apps/web/app/dashboard/shared-caps/page.tsx+++ b/apps/web/app/dashboard/shared-caps/page.tsx@@ -2,9 +2,9 @@ import { db } from "@cap/database";import { getCurrentUser } from "@cap/database/auth/session";import {comments,- sharedVideos,organizationMembers,organizations,+ sharedVideos,users,videos,} from "@cap/database/schema";