Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Organization icons and content shift fix (#524)
Ameer Al Ashhab50d23685f35f
diff --git a/apps/web/actions/organization/remove-icon.ts b/apps/web/actions/organization/remove-icon.tsnew file mode 100644index 000000000..35219d226--- /dev/null+++ b/apps/web/actions/organization/remove-icon.ts@@ -0,0 +1,40 @@+'use server';++import { getCurrentUser } from "@cap/database/auth/session";+import { organizations } from "@cap/database/schema";+import { db } from "@cap/database";+import { eq } from "drizzle-orm";+import { revalidatePath } from "next/cache";++export async function removeOrganizationIcon(organizationId: string) {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Unauthorized");+ }++ const organization = await db()+ .select()+ .from(organizations)+ .where(eq(organizations.id, organizationId));++ if (!organization || organization.length === 0) {+ throw new Error("Organization not found");+ }++ if (organization[0]?.ownerId !== user.id) {+ throw new Error("Only the owner can remove the organization icon");+ }++ // Update organization to remove icon URL+ await db()+ .update(organizations)+ .set({+ iconUrl: null,+ })+ .where(eq(organizations.id, organizationId));++ revalidatePath("/dashboard/settings/organization");++ return { success: true };+}diff --git a/apps/web/actions/organization/upload-icon.ts b/apps/web/actions/organization/upload-icon.tsnew file mode 100644index 000000000..3eb63d5e4--- /dev/null+++ b/apps/web/actions/organization/upload-icon.ts@@ -0,0 +1,114 @@+'use server';++import { getCurrentUser } from "@cap/database/auth/session";+import { organizations } from "@cap/database/schema";+import { db } from "@cap/database";+import { eq } from "drizzle-orm";+import { revalidatePath } from "next/cache";+import { createS3Client, getS3Bucket } from "@/utils/s3";+import { createPresignedPost } from "@aws-sdk/s3-presigned-post";+import { serverEnv } from "@cap/env";++export async function uploadOrganizationIcon(+ formData: FormData,+ organizationId: string+) {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Unauthorized");+ }++ const organization = await db()+ .select()+ .from(organizations)+ .where(eq(organizations.id, organizationId));++ if (!organization || organization.length === 0) {+ throw new Error("Organization not found");+ }++ if (organization[0]?.ownerId !== user.id) {+ throw new Error("Only the owner can update organization icon");+ }++ const file = formData.get('file') as File;++ if (!file) {+ throw new Error("No file provided");+ }++ // Validate file type+ if (!file.type.startsWith('image/')) {+ throw new Error("File must be an image");+ }++ // Validate file size (limit to 2MB)+ if (file.size > 2 * 1024 * 1024) {+ throw new Error("File size must be less than 2MB");+ }++ // Create a unique file key+ const fileExtension = file.name.split('.').pop();+ const fileKey = `organizations/${organizationId}/icon-${Date.now()}.${fileExtension}`;++ try {+ // Get S3 client+ const [s3Client] = await createS3Client();+ const bucketName = await getS3Bucket();++ // Create presigned post+ const presignedPostData = await createPresignedPost(s3Client, {+ Bucket: bucketName,+ Key: fileKey,+ Fields: {+ 'Content-Type': file.type,+ },+ Expires: 600, // 10 minutes+ });++ // Upload file to S3+ const formDataForS3 = new FormData();+ Object.entries(presignedPostData.fields).forEach(([key, value]) => {+ formDataForS3.append(key, value as string);+ });+ formDataForS3.append('file', file);++ const uploadResponse = await fetch(presignedPostData.url, {+ method: 'POST',+ body: formDataForS3,+ });++ if (!uploadResponse.ok) {+ throw new Error("Failed to upload file to S3");+ }++ // Construct the icon URL+ let iconUrl;+ if (serverEnv().CAP_AWS_BUCKET_URL) {+ // If a custom bucket URL is defined, use it+ iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;+ } else if (serverEnv().CAP_AWS_ENDPOINT) {+ // For custom endpoints like MinIO+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;+ } else {+ // Default AWS S3 URL format+ iconUrl = `https://${bucketName}.s3.${serverEnv().CAP_AWS_REGION || 'us-east-1'}.amazonaws.com/${fileKey}`;+ }++ // Update organization with new icon URL+ await db()+ .update(organizations)+ .set({+ iconUrl,+ })+ .where(eq(organizations.id, organizationId));++ revalidatePath("/dashboard/settings/organization");++ return { success: true, iconUrl };+ } catch (error) {+ console.error("Error uploading organization icon:", error);+ throw new Error(error instanceof Error ? error.message : "Upload failed");+ }+}diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsxindex 3ead8f46b..7a1d34cbb 100644--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx@@ -37,6 +37,7 @@ import {import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import clsx from "clsx";import { motion } from "framer-motion";+import Image from "next/image";import { useRef, useState } from "react";import { updateActiveOrganization } from "./server";@@ -117,14 +118,25 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {><div className="flex justify-between items-center w-full text-left"><div className="flex items-center">- <Avatar- letterClass="text-gray-1 text-xs"- className="relative flex-shrink-0 size-5"- name={- activeOrg?.organization.name ??- "No organization found"- }- />+ {activeOrg?.organization.iconUrl ? (+ <div className="overflow-hidden relative flex-shrink-0 rounded-full size-5">+ <Image+ src={activeOrg.organization.iconUrl}+ alt={activeOrg.organization.name || "Organization icon"}+ fill+ className="object-cover"+ />+ </div>+ ) : (+ <Avatar+ letterClass="text-gray-1 text-xs"+ className="relative flex-shrink-0 size-5"+ name={+ activeOrg?.organization.name ??+ "No organization found"+ }+ />+ )}<p className="ml-2.5 text-sm text-gray-12 font-medium truncate">{activeOrg?.organization.name ??"No organization found"}@@ -152,9 +164,8 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {return (<CommandItemclassName={clsx(- "transition-colors duration-300",- isSelected ? "pointer-events-none text-gray-12"- : "!text-gray-10 hover:!text-gray-12"+ "rounded-lg transition-colors duration-300 group",+ isSelected ? "pointer-events-none":"text-gray-10 hover:text-gray-12 hover:bg-gray-6")}key={organization.organization.name + "-organization"}onSelect={async () => {@@ -164,11 +175,29 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {setOpen(false);}}>- {organization.organization.name}+ <div className="flex gap-2 items-center w-full">+ {organization.organization.iconUrl ? (+ <div className="overflow-hidden relative flex-shrink-0 rounded-full size-5">+ <Image+ src={organization.organization.iconUrl}+ alt={organization.organization.name || "Organization icon"}+ fill+ className="object-cover"+ />+ </div>+ ) : (+ <Avatar+ letterClass="text-gray-1 text-xs"+ className="relative flex-shrink-0 size-5"+ name={organization.organization.name}+ />+ )}+ <p className={clsx("flex-1 text-sm transition-colors duration-200 group-hover:text-gray-12", isSelected ? "text-gray-12":"text-gray-10")}>{organization.organization.name}</p>+ </div>{isSelected && (<Checksize={18}- className={"ml-auto"}+ className={"ml-auto text-gray-12"}/>)}</CommandItem>diff --git a/apps/web/app/dashboard/caps/components/CapCard.tsx b/apps/web/app/dashboard/caps/components/CapCard.tsxindex 8d3c5c064..9de3117fa 100644--- a/apps/web/app/dashboard/caps/components/CapCard.tsx+++ b/apps/web/app/dashboard/caps/components/CapCard.tsx@@ -31,14 +31,14 @@ interface Props extends PropsWithChildren {createdAt: Date;totalComments: number;totalReactions: number;- sharedOrganizations?: { id: string; name: string }[];+ sharedOrganizations?: { id: string; name: string; iconUrl: string }[];ownerName: string | null;metadata?: VideoMetadata;};analytics: number;onDelete?: (videoId: string) => Promise<void>;userId?: string;- userOrganizations?: { id: string; name: string }[];+ userOrganizations?: { id: string; name: string; iconUrl: string }[];sharedCapCard?: boolean;isSelected?: boolean;onSelectToggle?: () => void;@@ -413,9 +413,9 @@ export const CapCard = ({)}</div>{renderSharedStatus()}- <div className="mb-1">+ <div className="mb-1 h-[1.5rem]"> {/* Fixed height container */}{isDateEditing && !sharedCapCard ? (- <div className="flex items-center">+ <div className="flex items-center h-full"><inputtype="text"value={dateValue}@@ -423,14 +423,14 @@ export const CapCard = ({onBlur={handleDateBlur}onKeyDown={handleDateKeyDown}autoFocus- className="text-sm truncate mt-2 leading-[1.25rem] text-gray-10 bg-transparent focus:outline-none"+ className="text-sm w-full truncate text-gray-10 bg-transparent focus:outline-none h-full leading-[1.5rem]"placeholder="YYYY-MM-DD HH:mm:ss"/></div>) : (<Tooltip content={`Cap created at ${effectiveDate}`}><p- className="text-sm truncate mt-2 leading-[1.25rem] text-gray-10 cursor-pointer flex items-center"+ className="text-sm truncate text-gray-10 cursor-pointer flex items-center h-full leading-[1.5rem]"onClick={handleDateClick}>{showFullDatediff --git a/apps/web/app/dashboard/caps/components/SharingDialog.tsx b/apps/web/app/dashboard/caps/components/SharingDialog.tsxindex f4b9a6742..a965fac7c 100644--- a/apps/web/app/dashboard/caps/components/SharingDialog.tsx+++ b/apps/web/app/dashboard/caps/components/SharingDialog.tsx@@ -1,9 +1,19 @@-import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input } from "@cap/ui";+import { Avatar } from "@/app/s/[videoId]/_components/tabs/Activity";+import {+ Button,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Input,+} from "@cap/ui";import { faShareNodes } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import clsx from "clsx";import { motion } from "framer-motion";import { Check, Search } from "lucide-react";+import Image from "next/image";import { useEffect, useState } from "react";import { toast } from "sonner";@@ -12,8 +22,8 @@ interface SharingDialogProps {onClose: () => void;capId: string;capName: string;- sharedOrganizations: { id: string; name: string }[];- userOrganizations?: { id: string; name: string }[];+ sharedOrganizations: { id: string; name: string; iconUrl: string }[];+ userOrganizations?: { id: string; name: string; iconUrl: string }[];onSharingUpdated: (updatedSharedOrganizations: string[]) => void;}@@ -34,7 +44,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({useState<Set<string>>(new Set(sharedOrganizations.map((organization) => organization.id)));- const [loading, setLoading] = useState(false);+ const [loading, setLoading] = useState(false);useEffect(() => {if (isOpen) {@@ -138,7 +148,7 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({return (<Dialog open={isOpen} onOpenChange={onClose}><DialogContent className="p-0 w-full max-w-md rounded-xl border bg-gray-2 border-gray-4">- <DialogHeader+ <DialogHeadericon={<FontAwesomeIcon icon={faShareNodes} className="size-3.5" />}description="Select the organizations you would like to share with">@@ -181,7 +191,13 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({<Button size="sm" variant="gray" onClick={onClose}>Cancel</Button>- <Button spinner={loading} disabled={loading} size="sm" variant="dark" onClick={handleSave}>+ <Button+ spinner={loading}+ disabled={loading}+ size="sm"+ variant="dark"+ onClick={handleSave}+ >{loading ? "Saving..." : "Save"}</Button></DialogFooter>@@ -190,35 +206,72 @@ export const SharingDialog: React.FC<SharingDialogProps> = ({);};-const SpaceCard = ({ organization, selectedOrganizations, handleToggleOrganization }: { organization: { id: string; name: string }, selectedOrganizations: Set<string>, handleToggleOrganization: (organizationId: string) => void }) => {+const SpaceCard = ({+ organization,+ selectedOrganizations,+ handleToggleOrganization,+}: {+ organization: { id: string; name: string; iconUrl: string };+ selectedOrganizations: Set<string>;+ handleToggleOrganization: (organizationId: string) => void;+}) => {return (- <div className={clsx("flex items-center relative flex-col justify-center gap-2 border transition-colors duration-200 border-gray-3 w-full p-3 rounded-xl cursor-pointer", selectedOrganizations.has(organization.id) ? "bg-gray-3 border-gray-4" : "hover:bg-gray-3 hover:border-gray-4")} onClick={() => handleToggleOrganization(organization.id)}>- <div className="flex justify-center items-center text-xs font-semibold rounded-full size-6 text-gray-1 bg-gray-12">- {organization.name.charAt(0).toUpperCase()}- </div>+ <div+ className={clsx(+ "flex items-center relative flex-col justify-center gap-2 border transition-colors duration-200 border-gray-3 w-full p-3 rounded-xl cursor-pointer",+ selectedOrganizations.has(organization.id)+ ? "bg-gray-3 border-gray-4"+ : "hover:bg-gray-3 hover:border-gray-4"+ )}+ onClick={() => handleToggleOrganization(organization.id)}+ >+ {organization.iconUrl ? (+ <div className="overflow-hidden relative flex-shrink-0 rounded-full size-6">+ <Image+ src={organization.iconUrl}+ alt={organization.name}+ width={24}+ height={24}+ className="object-cover w-full h-full"+ />+ </div>+ ) : (+ <Avatar+ letterClass="text-gray-1 text-xs"+ className="relative flex-shrink-0 size-6"+ name={organization.name}+ />+ )}<span className="text-xs truncate transition-colors duration-200 text-gray-10">{organization.name}</span>- <motion.div- key={organization.id}- animate={{- scale: selectedOrganizations.has(organization.id) ? 1 : 0- }}- initial={{- scale: 0- }}- transition={{- type: selectedOrganizations.has(organization.id)- ? "spring"- : "tween",- stiffness: selectedOrganizations.has(organization.id) ? 300 : undefined,- damping: selectedOrganizations.has(organization.id) ? 20 : undefined,- duration: !selectedOrganizations.has(organization.id) ? 0.2 : undefined- }}- className={clsx("absolute top-[-6px] flex items-center justify-center right-[-5px] bg-gray-4 rounded-full border size-4", selectedOrganizations.has(organization.id) ? "bg-green-500 border-transparent" : "bg-gray-4 border-gray-5")}>+ <motion.div+ key={organization.id}+ animate={{+ scale: selectedOrganizations.has(organization.id) ? 1 : 0,+ }}+ initial={{+ scale: 0,+ }}+ transition={{+ type: selectedOrganizations.has(organization.id) ? "spring" : "tween",+ stiffness: selectedOrganizations.has(organization.id)+ ? 300+ : undefined,+ damping: selectedOrganizations.has(organization.id) ? 20 : undefined,+ duration: !selectedOrganizations.has(organization.id)+ ? 0.2+ : undefined,+ }}+ className={clsx(+ "absolute top-[-6px] flex items-center justify-center right-[-5px] bg-gray-4 rounded-full border size-4",+ selectedOrganizations.has(organization.id)+ ? "bg-green-500 border-transparent"+ : "bg-gray-4 border-gray-5"+ )}+ ><Check className="text-white" size={10} /></motion.div></div>);};-\ No newline at end of filediff --git a/apps/web/app/dashboard/caps/page.tsx b/apps/web/app/dashboard/caps/page.tsxindex 84ee627d4..a93ec8758 100644--- a/apps/web/app/dashboard/caps/page.tsx+++ b/apps/web/app/dashboard/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";@@ -55,12 +55,13 @@ export default async function CapsPage({metadata: videos.metadata,totalComments: sql<number>`COUNT(DISTINCT CASE WHEN ${comments.type} = 'text' THEN ${comments.id} END)`,totalReactions: sql<number>`COUNT(DISTINCT CASE WHEN ${comments.type} = 'emoji' THEN ${comments.id} END)`,- sharedOrganizations: sql<{ id: string; name: string }[]>`+ sharedOrganizations: sql<{ id: string; name: string; iconUrl: string }[]>`COALESCE(JSON_ARRAYAGG(JSON_OBJECT('id', ${organizations.id},- 'name', ${organizations.name}+ 'name', ${organizations.name},+ 'iconUrl', ${organizations.iconUrl})),JSON_ARRAY()@@ -101,6 +102,7 @@ export default async function CapsPage({.select({id: organizations.id,name: organizations.name,+ iconUrl: organizations.iconUrl,}).from(organizations).leftJoin(diff --git a/apps/web/app/dashboard/settings/organization/components/OrganizationIcon.tsx b/apps/web/app/dashboard/settings/organization/components/OrganizationIcon.tsxindex c4547bdf1..2e2ac3881 100644--- a/apps/web/app/dashboard/settings/organization/components/OrganizationIcon.tsx+++ b/apps/web/app/dashboard/settings/organization/components/OrganizationIcon.tsx@@ -1,11 +1,12 @@"use client";-import { Button, CardDescription, Input, Label } from "@cap/ui";-import { faCloudUpload } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import clsx from "clsx";-import Image from "next/image";-import { useEffect, useRef, useState } from "react";+import { removeOrganizationIcon } from "@/actions/organization/remove-icon";+import { uploadOrganizationIcon } from "@/actions/organization/upload-icon";+import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";+import { CardDescription, Label } from "@cap/ui";+import { useState } from "react";+import { toast } from "sonner";+import { FileInput } from "@/components/FileInput";interface OrganizationIconProps {isOwner: boolean;@@ -16,95 +17,55 @@ export const OrganizationIcon = ({isOwner,showOwnerToast,}: OrganizationIconProps) => {- const fileInputRef = useRef<HTMLInputElement>(null);- const [isDragging, setIsDragging] = useState(false);- const [selectedFile, setSelectedFile] = useState<File | null>(null);- const [previewUrl, setPreviewUrl] = useState<string | null>(null);+ const { activeOrganization } = useSharedContext();+ const organizationId = activeOrganization?.organization.id;+ const existingIconUrl = activeOrganization?.organization.iconUrl;- const handleDragEnter = (e: React.DragEvent<HTMLDivElement>) => {- e.preventDefault();- e.stopPropagation();- if (isOwner) {- setIsDragging(true);- }- };-- const handleDragLeave = (e: React.DragEvent<HTMLDivElement>) => {- e.preventDefault();- e.stopPropagation();- setIsDragging(false);- };-- const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {- e.preventDefault();- e.stopPropagation();- if (isOwner) {- e.dataTransfer.dropEffect = "copy";- setIsDragging(true);- }- };-- const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {- e.preventDefault();- e.stopPropagation();- setIsDragging(false);-+ const [isUploading, setIsUploading] = useState(false);++ const handleFileChange = async (file: File | null) => {if (!isOwner) {showOwnerToast();return;}- const files = e.dataTransfer.files;- if (files && files.length > 0) {- // Set the file to the input element- const file = files[0];+ // If file is null, it means the user removed the file+ if (!file || !organizationId) return;++ // Upload the file to the server immediately+ try {+ setIsUploading(true);+ const formData = new FormData();+ formData.append('file', file);++ const result = await uploadOrganizationIcon(formData, organizationId);- if (fileInputRef.current && file) {- try {- // Create a new DataTransfer instance- const dataTransfer = new DataTransfer();- dataTransfer.items.add(file);- fileInputRef.current.files = dataTransfer.files;-- // Trigger onChange event manually- const event = new Event('change', { bubbles: true });- fileInputRef.current.dispatchEvent(event);- } catch (error) {- console.error('Error handling file drop:', error);- }+ if (result.success) {+ toast.success("Organization icon updated successfully");}+ } catch (error) {+ console.error("Error uploading organization icon:", error);+ toast.error(error instanceof Error ? error.message : "Failed to upload icon");+ } finally {+ setIsUploading(false);}};-- // Clean up the preview URL when component unmounts- useEffect(() => {- return () => {- if (previewUrl) {- URL.revokeObjectURL(previewUrl);- }- };- }, [previewUrl]);- const handleFileChange = () => {- if (!isOwner) {- showOwnerToast();- return;- }+ const handleRemoveIcon = async () => {+ if (!isOwner || !organizationId) return;- const file = fileInputRef.current?.files?.[0];- if (file) {- // Clean up previous preview URL- if (previewUrl) {- URL.revokeObjectURL(previewUrl);- }-- // Create a new preview URL- const newPreviewUrl = URL.createObjectURL(file);- setPreviewUrl(newPreviewUrl);- setSelectedFile(file);+ try {+ setIsUploading(true);+ const result = await removeOrganizationIcon(organizationId);- // Here you would typically upload the file to your server- console.log("File selected:", file);+ if (result.success) {+ toast.success("Organization icon removed successfully");+ }+ } catch (error) {+ console.error("Error removing organization icon:", error);+ toast.error(error instanceof Error ? error.message : "Failed to remove icon");+ } finally {+ setIsUploading(false);}};@@ -118,76 +79,14 @@ export const OrganizationIcon = ({</CardDescription></div><div className="relative mt-4">- <div className="flex absolute top-0 left-0 justify-center items-center w-full h-full rounded-xl backdrop-blur-md bg-gray/50">- <p className="text-sm text-gray-11">Coming soon...</p>- </div>- {selectedFile ? (- <div className="flex gap-2 items-center p-1.5 rounded-xl border border-gray-4">- <div className="flex flex-1 gap-1.5 items-center">- <div className="overflow-hidden relative flex-shrink-0 rounded-md size-6">- {previewUrl && (- <Image- src={previewUrl}- alt="Selected file preview"- fill- className="object-contain"- />- )}- </div>- <div className="flex flex-1 gap-1 items-center">- <p className="text-xs font-medium w-fit max-w-[150px] truncate text-gray-12">{selectedFile.name}</p>- <p className="text-xs text-gray-10 min-w-fit">{(selectedFile.size / 1024).toFixed(1)} KB</p>- </div>- </div>- <Button- variant="destructive"- style={{- "--gradient-border-radius": "8px",- } as React.CSSProperties}- size="xs"- className="min-w-[80px]"- onClick={(e) => {- e.stopPropagation();- setSelectedFile(null);- setPreviewUrl(null);- if (fileInputRef.current) {- fileInputRef.current.value = '';- }- }}- >- Remove- </Button>- </div>- ) : (- <div- onClick={() => fileInputRef.current?.click()}- onDragEnter={handleDragEnter}- onDragOver={handleDragOver}- onDragLeave={handleDragLeave}- onDrop={handleDrop}- className={clsx(- "flex gap-3 justify-center items-center px-4 w-full rounded-xl border border-dashed transition-all duration-300 cursor-pointer py-[12px]",- isDragging ? "border-blue-500 bg-gray-5" : "hover:bg-gray-4 border-gray-8"- )}- >- <FontAwesomeIcon- className="text-gray-10 size-5"- icon={faCloudUpload}- />- <p className="text-sm truncate text-gray-11">- Choose a file or drag & drop it here- </p>- </div>- )}- <Input- className="hidden"- type="file"- ref={fileInputRef}+ <FileInputid="icon"- disabled={!isOwner}- accept="image/*"- onChange={handleFileChange}name="icon"+ onChange={handleFileChange}+ disabled={!isOwner}+ isLoading={isUploading}+ initialPreviewUrl={existingIconUrl || null}+ onRemove={handleRemoveIcon}/></div></div>diff --git a/apps/web/components/FileInput.tsx b/apps/web/components/FileInput.tsxnew file mode 100644index 000000000..133e385fd--- /dev/null+++ b/apps/web/components/FileInput.tsx@@ -0,0 +1,258 @@+"use client";++import { Button, Input } from "@cap/ui";+import { faCloudUpload, faSpinner } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import clsx from "clsx";+import Image from "next/image";+import { useEffect, useRef, useState } from "react";+import { toast } from "sonner";++export interface FileInputProps {+ onChange?: (file: File | null) => void;+ disabled?: boolean;+ id?: string;+ name?: string;+ className?: string;+ initialPreviewUrl?: string | null;+ onRemove?: () => void;+ isLoading?: boolean;+}++export const FileInput: React.FC<FileInputProps> = ({+ onChange,+ disabled = false,+ id = "file",+ name = "file",+ className = "",+ initialPreviewUrl = null,+ onRemove,+ isLoading = false,+}) => {+ const fileInputRef = useRef<HTMLInputElement>(null);+ const [isDragging, setIsDragging] = useState(false);+ const [selectedFile, setSelectedFile] = useState<File | null>(null);+ const [previewUrl, setPreviewUrl] = useState<string | null>(initialPreviewUrl);++ // Update preview URL when initialPreviewUrl changes+ useEffect(() => {+ setPreviewUrl(initialPreviewUrl);+ }, [initialPreviewUrl]);++ // Clean up the preview URL when component unmounts+ useEffect(() => {+ return () => {+ if (previewUrl && previewUrl !== initialPreviewUrl) {+ URL.revokeObjectURL(previewUrl);+ }+ };+ }, [previewUrl, initialPreviewUrl]);++ const handleDragEnter = (e: React.DragEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.stopPropagation();+ if (!disabled) {+ setIsDragging(true);+ }+ };++ const handleDragLeave = (e: React.DragEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(false);+ };++ const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.stopPropagation();+ if (!disabled) {+ e.dataTransfer.dropEffect = "copy";+ setIsDragging(true);+ }+ };++ const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(false);++ if (disabled) return;++ const files = e.dataTransfer.files;+ if (files && files.length > 0) {+ // Set the file to the input element+ const file = files[0];++ if (fileInputRef.current && file) {+ try {+ // Create a new DataTransfer instance+ const dataTransfer = new DataTransfer();+ dataTransfer.items.add(file);+ fileInputRef.current.files = dataTransfer.files;++ // Trigger onChange event manually+ const event = new Event('change', { bubbles: true });+ fileInputRef.current.dispatchEvent(event);+ } catch (error) {+ console.error('Error handling file drop:', error);+ }+ }+ }+ };++ const handleFileChange = () => {+ const file = fileInputRef.current?.files?.[0];+ if (file) {+ // Validate file type - only allow jpg, jpeg, svg, and png+ const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/svg+xml'];+ if (!allowedTypes.includes(file.type)) {+ toast.error("Please select a JPG, JPEG, PNG, or SVG file");+ if (fileInputRef.current) {+ fileInputRef.current.value = '';+ }+ return;+ }++ // Validate file size (limit to 2MB)+ if (file.size > 2 * 1024 * 1024) {+ toast.error("File size must be less than 2MB");+ if (fileInputRef.current) {+ fileInputRef.current.value = '';+ }+ return;+ }++ // Clean up previous preview URL if it's not the initial preview URL+ if (previewUrl && previewUrl !== initialPreviewUrl) {+ URL.revokeObjectURL(previewUrl);+ }++ // Create a new preview URL for immediate feedback+ const newPreviewUrl = URL.createObjectURL(file);+ setPreviewUrl(newPreviewUrl);+ setSelectedFile(file);++ // Call the onChange callback+ if (onChange) {+ onChange(file);+ }+ }+ };++ const handleRemove = (e: React.MouseEvent) => {+ e.stopPropagation();++ // Clean up preview URL if it's not the initial preview URL+ if (previewUrl && previewUrl !== initialPreviewUrl) {+ URL.revokeObjectURL(previewUrl);+ }++ setPreviewUrl(null);+ setSelectedFile(null);++ if (fileInputRef.current) {+ fileInputRef.current.value = '';+ }++ // Call the onRemove callback+ if (onRemove) {+ onRemove();+ }++ // Call the onChange callback with null+ if (onChange) {+ onChange(null);+ }+ };++ return (+ <div className={`relative ${className}`}>+ <div className="h-[46.5px]"> {/* Fixed height container to prevent resizing */}+ {(selectedFile || previewUrl) ? (+ <div className="flex gap-2 items-center p-1.5 rounded-xl border border-gray-4 h-full">+ <div className="flex flex-1 gap-1.5 items-center">+ <div className="overflow-hidden relative flex-shrink-0 rounded-md size-5">+ {previewUrl && (+ <Image+ src={previewUrl}+ alt="File preview"+ fill+ className="object-contain"+ />+ )}+ </div>+ <div className="flex flex-1 gap-1 items-center">+ {selectedFile ? (+ <>+ <p className="text-xs font-medium w-fit max-w-[150px] truncate text-gray-12">{selectedFile.name}</p>+ <p className="text-xs text-gray-10 min-w-fit">{(selectedFile.size / 1024).toFixed(1)} KB</p>+ </>+ ) : (+ <p className="text-xs font-medium text-gray-12">Current file</p>+ )}+ </div>+ </div>+ <Button+ variant="destructive"+ style={{+ "--gradient-border-radius": "8px",+ } as React.CSSProperties}+ size="xs"+ className="min-w-[80px]"+ disabled={isLoading || disabled}+ onClick={handleRemove}+ >+ {isLoading ? (+ <FontAwesomeIcon icon={faSpinner} className="animate-spin" />+ ) : (+ <>+ Remove+ </>+ )}+ </Button>+ </div>+ ) : (+ <div+ onClick={() => !disabled && fileInputRef.current?.click()}+ onDragEnter={handleDragEnter}+ onDragOver={handleDragOver}+ onDragLeave={handleDragLeave}+ onDrop={handleDrop}+ className={clsx(+ "flex gap-3 justify-center items-center px-4 w-full rounded-xl border border-dashed transition-all duration-300 cursor-pointer h-full",+ isDragging ? "border-blue-500 bg-gray-5" : "hover:bg-gray-4 border-gray-8",+ isLoading || disabled ? "opacity-50 pointer-events-none" : ""+ )}+ >+ {isLoading ? (+ <FontAwesomeIcon+ className="animate-spin text-gray-10 size-5"+ icon={faSpinner}+ />+ ) : (+ <FontAwesomeIcon+ className="text-gray-10 size-5"+ icon={faCloudUpload}+ />+ )}+ <p className="text-sm truncate text-gray-11">+ {isLoading+ ? "Uploading..."+ : "Choose a file or drag & drop it here"}+ </p>+ </div>+ )}+ </div>+ <Input+ className="hidden"+ type="file"+ ref={fileInputRef}+ id={id}+ disabled={disabled || isLoading}+ accept="image/jpeg, image/jpg, image/png, image/svg+xml"+ onChange={handleFileChange}+ name={name}+ />+ </div>+ );+};diff --git a/apps/web/components/forms/NewOrganization.tsx b/apps/web/components/forms/NewOrganization.tsxindex b235e73f3..c3e0e52e6 100644--- a/apps/web/components/forms/NewOrganization.tsx+++ b/apps/web/components/forms/NewOrganization.tsx@@ -7,9 +7,14 @@ import {FormControl,FormField,Input,+ CardDescription,+ Label,} from "@cap/ui";import { useForm } from "react-hook-form";import { createOrganization } from "./server";+import { useState } from "react";+import { toast } from "sonner";+import { FileInput } from "@/components/FileInput";export interface NewOrganizationProps {onOrganizationCreated: () => void;@@ -30,6 +35,9 @@ export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {},});+ const [selectedFile, setSelectedFile] = useState<File | null>(null);+ const [isUploading, setIsUploading] = useState(false);+return (<Form {...form}><form@@ -37,12 +45,25 @@ export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {ref={props.formRef}onSubmit={form.handleSubmit(async (values) => {try {+ setIsUploading(true);props.setCreateLoading?.(true);- await createOrganization(values);++ // Create FormData to send both the organization name and icon file+ const formData = new FormData();+ formData.append('name', values.name);++ // Add the icon file if one was selected+ if (selectedFile) {+ formData.append('icon', selectedFile);+ }++ await createOrganization(formData);props.onOrganizationCreated();} catch (error) {console.error("Error creating organization:", error);+ toast.error("Failed to create organization");} finally {+ setIsUploading(false);props.setCreateLoading?.(false);}})}@@ -64,6 +85,23 @@ export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {</FormControl>)}/>++ <div className="space-y-1">+ <Label htmlFor="icon">Organization Icon (Optional)</Label>+ <CardDescription className="w-full max-w-[400px]">+ Upload a custom logo or icon for your organization.+ </CardDescription>+ </div>++ <div className="relative mt-2">+ <FileInput+ id="icon"+ name="icon"+ onChange={setSelectedFile}+ disabled={isUploading}+ isLoading={isUploading}+ />+ </div></div></form></Form>diff --git a/apps/web/components/forms/server.ts b/apps/web/components/forms/server.tsindex d69a58b91..0592e5bc4 100644--- a/apps/web/components/forms/server.ts+++ b/apps/web/components/forms/server.ts@@ -7,17 +7,100 @@ import { organizationMembers, organizations, users } from "@cap/database/schema"import { eq } from "drizzle-orm";import { revalidatePath } from "next/cache";-export async function createOrganization(args: { name: string }) {+import { createS3Client, getS3Bucket } from "@/utils/s3";+import { createPresignedPost } from "@aws-sdk/s3-presigned-post";+import { serverEnv } from "@cap/env";++export async function createOrganization(formData: FormData) {const user = await getCurrentUser();if (!user) throw new Error("Unauthorized");+ // Extract the name from the FormData+ const name = formData.get('name') as string;+ if (!name) throw new Error("Organization name is required");+const organizationId = nanoId();- await db().insert(organizations).values({++ // Create the organization first+ const orgValues: { id: string; ownerId: string; name: string; iconUrl?: string } = {id: organizationId,ownerId: user.id,- name: args.name,- });+ name: name,+ };++ // Check if an icon file was uploaded+ const iconFile = formData.get('icon') as File;+ if (iconFile) {+ // Validate file type+ if (!iconFile.type.startsWith('image/')) {+ throw new Error("File must be an image");+ }++ // Validate file size (limit to 2MB)+ if (iconFile.size > 2 * 1024 * 1024) {+ throw new Error("File size must be less than 2MB");+ }++ // Create a unique file key+ const fileExtension = iconFile.name.split('.').pop();+ const fileKey = `organizations/${organizationId}/icon-${Date.now()}.${fileExtension}`;++ try {+ // Get S3 client+ const [s3Client] = await createS3Client();+ const bucketName = await getS3Bucket();++ // Create presigned post+ const presignedPostData = await createPresignedPost(s3Client, {+ Bucket: bucketName,+ Key: fileKey,+ Fields: {+ 'Content-Type': iconFile.type,+ },+ Expires: 600, // 10 minutes+ });++ // Upload file to S3+ const formDataForS3 = new FormData();+ Object.entries(presignedPostData.fields).forEach(([key, value]) => {+ formDataForS3.append(key, value as string);+ });+ formDataForS3.append('file', iconFile);++ const uploadResponse = await fetch(presignedPostData.url, {+ method: 'POST',+ body: formDataForS3,+ });++ if (!uploadResponse.ok) {+ throw new Error("Failed to upload file to S3");+ }++ // Construct the icon URL+ let iconUrl;+ if (serverEnv().CAP_AWS_BUCKET_URL) {+ // If a custom bucket URL is defined, use it+ iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;+ } else if (serverEnv().CAP_AWS_ENDPOINT) {+ // For custom endpoints like MinIO+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;+ } else {+ // Default AWS S3 URL format+ iconUrl = `https://${bucketName}.s3.${serverEnv().CAP_AWS_REGION || 'us-east-1'}.amazonaws.com/${fileKey}`;+ }++ // Add the icon URL to the organization values+ orgValues.iconUrl = iconUrl;+ } catch (error) {+ console.error("Error uploading organization icon:", error);+ throw new Error(error instanceof Error ? error.message : "Upload failed");+ }+ }++ // Insert the organization with or without the icon URL+ await db().insert(organizations).values(orgValues);+ // Add the user as an owner of the organizationawait db().insert(organizationMembers).values({id: nanoId(),userId: user.id,@@ -25,10 +108,12 @@ export async function createOrganization(args: { name: string }) {organizationId,});+ // Set this as the active organization for the userawait db().update(users).set({ activeOrganizationId: organizationId }).where(eq(users.id, user.id));revalidatePath("/dashboard");+ return { success: true, organizationId };}diff --git a/packages/database/migrations/meta/0002_snapshot.json b/packages/database/migrations/meta/0002_snapshot.jsonnew file mode 100644index 000000000..c276840df--- /dev/null+++ b/packages/database/migrations/meta/0002_snapshot.json@@ -0,0 +1,1286 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "c69214d1-02c2-4bee-9d62-199f92c6fe64",+ "prevId": "94acb4a1-1de9-4bcf-bb06-5aeae407cd92",+ "tables": {+ "accounts": {+ "name": "accounts",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_in": {+ "name": "expires_in",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token_expires_in": {+ "name": "refresh_token_expires_in",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "tempColumn": {+ "name": "tempColumn",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "provider_account_id_idx": {+ "name": "provider_account_id_idx",+ "columns": [+ "providerAccountId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "accounts_id": {+ "name": "accounts_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "accounts_id_unique": {+ "name": "accounts_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "comments": {+ "name": "comments",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(6)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "timestamp": {+ "name": "timestamp",+ "type": "float",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "authorId": {+ "name": "authorId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "parentCommentId": {+ "name": "parentCommentId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "video_id_idx": {+ "name": "video_id_idx",+ "columns": [+ "videoId"+ ],+ "isUnique": false+ },+ "author_id_idx": {+ "name": "author_id_idx",+ "columns": [+ "authorId"+ ],+ "isUnique": false+ },+ "parent_comment_id_idx": {+ "name": "parent_comment_id_idx",+ "columns": [+ "parentCommentId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "comments_id": {+ "name": "comments_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "comments_id_unique": {+ "name": "comments_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "organization_invites": {+ "name": "organization_invites",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "invitedEmail": {+ "name": "invitedEmail",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "invitedByUserId": {+ "name": "invitedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": [+ "organizationId"+ ],+ "isUnique": false+ },+ "invited_email_idx": {+ "name": "invited_email_idx",+ "columns": [+ "invitedEmail"+ ],+ "isUnique": false+ },+ "invited_by_user_id_idx": {+ "name": "invited_by_user_id_idx",+ "columns": [+ "invitedByUserId"+ ],+ "isUnique": false+ },+ "status_idx": {+ "name": "status_idx",+ "columns": [+ "status"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organization_invites_id": {+ "name": "organization_invites_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "organization_invites_id_unique": {+ "name": "organization_invites_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "organization_members": {+ "name": "organization_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": [+ "organizationId"+ ],+ "isUnique": false+ },+ "user_id_organization_id_idx": {+ "name": "user_id_organization_id_idx",+ "columns": [+ "userId",+ "organizationId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organization_members_id": {+ "name": "organization_members_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "organization_members_id_unique": {+ "name": "organization_members_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "organizations": {+ "name": "organizations",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "allowedEmailDomain": {+ "name": "allowedEmailDomain",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customDomain": {+ "name": "customDomain",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "domainVerified": {+ "name": "domainVerified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "iconUrl": {+ "name": "iconUrl",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "workosOrganizationId": {+ "name": "workosOrganizationId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "workosConnectionId": {+ "name": "workosConnectionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "owner_id_idx": {+ "name": "owner_id_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "custom_domain_idx": {+ "name": "custom_domain_idx",+ "columns": [+ "customDomain"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "organizations_id": {+ "name": "organizations_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "organizations_id_unique": {+ "name": "organizations_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "s3_buckets": {+ "name": "s3_buckets",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "region": {+ "name": "region",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "endpoint": {+ "name": "endpoint",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bucketName": {+ "name": "bucketName",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "accessKeyId": {+ "name": "accessKeyId",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "secretAccessKey": {+ "name": "secretAccessKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('aws')"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "s3_buckets_id": {+ "name": "s3_buckets_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "s3_buckets_id_unique": {+ "name": "s3_buckets_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "sessions": {+ "name": "sessions",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sessionToken": {+ "name": "sessionToken",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {+ "session_token_idx": {+ "name": "session_token_idx",+ "columns": [+ "sessionToken"+ ],+ "isUnique": true+ },+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "sessions_id": {+ "name": "sessions_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "sessions_id_unique": {+ "name": "sessions_id_unique",+ "columns": [+ "id"+ ]+ },+ "sessions_sessionToken_unique": {+ "name": "sessions_sessionToken_unique",+ "columns": [+ "sessionToken"+ ]+ }+ },+ "checkConstraint": {}+ },+ "shared_videos": {+ "name": "shared_videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "videoId": {+ "name": "videoId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizationId": {+ "name": "organizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sharedByUserId": {+ "name": "sharedByUserId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sharedAt": {+ "name": "sharedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ }+ },+ "indexes": {+ "video_id_idx": {+ "name": "video_id_idx",+ "columns": [+ "videoId"+ ],+ "isUnique": false+ },+ "organization_id_idx": {+ "name": "organization_id_idx",+ "columns": [+ "organizationId"+ ],+ "isUnique": false+ },+ "shared_by_user_id_idx": {+ "name": "shared_by_user_id_idx",+ "columns": [+ "sharedByUserId"+ ],+ "isUnique": false+ },+ "video_id_organization_id_idx": {+ "name": "video_id_organization_id_idx",+ "columns": [+ "videoId",+ "organizationId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "shared_videos_id": {+ "name": "shared_videos_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "shared_videos_id_unique": {+ "name": "shared_videos_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ },+ "users": {+ "name": "users",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastName": {+ "name": "lastName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "emailVerified": {+ "name": "emailVerified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeCustomerId": {+ "name": "stripeCustomerId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionId": {+ "name": "stripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "thirdPartyStripeSubscriptionId": {+ "name": "thirdPartyStripeSubscriptionId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionStatus": {+ "name": "stripeSubscriptionStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "stripeSubscriptionPriceId": {+ "name": "stripeSubscriptionPriceId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "activeOrganizationId": {+ "name": "activeOrganizationId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "onboarding_completed_at": {+ "name": "onboarding_completed_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customBucket": {+ "name": "customBucket",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "inviteQuota": {+ "name": "inviteQuota",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ }+ },+ "indexes": {+ "email_idx": {+ "name": "email_idx",+ "columns": [+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "users_id": {+ "name": "users_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "users_id_unique": {+ "name": "users_id_unique",+ "columns": [+ "id"+ ]+ },+ "users_email_unique": {+ "name": "users_email_unique",+ "columns": [+ "email"+ ]+ }+ },+ "checkConstraint": {}+ },+ "verification_tokens": {+ "name": "verification_tokens",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verification_tokens_identifier": {+ "name": "verification_tokens_identifier",+ "columns": [+ "identifier"+ ]+ }+ },+ "uniqueConstraints": {+ "verification_tokens_token_unique": {+ "name": "verification_tokens_token_unique",+ "columns": [+ "token"+ ]+ }+ },+ "checkConstraint": {}+ },+ "videos": {+ "name": "videos",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'My Video'"+ },+ "awsRegion": {+ "name": "awsRegion",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "awsBucket": {+ "name": "awsBucket",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bucket": {+ "name": "bucket",+ "type": "varchar(15)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "public": {+ "name": "public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "videoStartTime": {+ "name": "videoStartTime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "audioStartTime": {+ "name": "audioStartTime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "xStreamInfo": {+ "name": "xStreamInfo",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "jobId": {+ "name": "jobId",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "jobStatus": {+ "name": "jobStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "isScreenshot": {+ "name": "isScreenshot",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "skipProcessing": {+ "name": "skipProcessing",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "transcriptionStatus": {+ "name": "transcriptionStatus",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "updatedAt": {+ "name": "updatedAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "onUpdate": true,+ "default": "(now())"+ },+ "source": {+ "name": "source",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"type\":\"MediaConvert\"}')"+ }+ },+ "indexes": {+ "id_idx": {+ "name": "id_idx",+ "columns": [+ "id"+ ],+ "isUnique": false+ },+ "owner_id_idx": {+ "name": "owner_id_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "is_public_idx": {+ "name": "is_public_idx",+ "columns": [+ "public"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "videos_id": {+ "name": "videos_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "videos_id_unique": {+ "name": "videos_id_unique",+ "columns": [+ "id"+ ]+ }+ },+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of file