33import type { userSelectProps } from "@cap/database/auth/session" ;
44import type { videos } from "@cap/database/schema" ;
55import { buildEnv , NODE_ENV } from "@cap/env" ;
6- import { Button } from "@cap/ui" ;
6+ import { Avatar , Button } from "@cap/ui" ;
77import { userIsPro } from "@cap/utils" ;
88import { faChevronDown , faLock } from "@fortawesome/free-solid-svg-icons" ;
99import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
1010import clsx from "clsx" ;
1111import { Check , Copy , Globe2 } from "lucide-react" ;
1212import moment from "moment" ;
13+ import Image from "next/image" ;
1314import { useRouter } from "next/navigation" ;
1415import { useEffect , useState } from "react" ;
1516import { toast } from "sonner" ;
@@ -29,7 +30,10 @@ export const ShareHeader = ({
2930 sharedSpaces = [ ] ,
3031 spacesData = null ,
3132} : {
32- data : typeof videos . $inferSelect ;
33+ data : typeof videos . $inferSelect & {
34+ organizationIconUrl ?: string | null ;
35+ organizationName ?: string | null ;
36+ } ;
3337 user : typeof userSelectProps | null ;
3438 customDomain ?: string | null ;
3539 domainVerified ?: boolean ;
@@ -70,9 +74,11 @@ export const ShareHeader = ({
7074
7175 const handleBlur = async ( ) => {
7276 setIsEditing ( false ) ;
73-
77+ const next = title . trim ( ) ;
78+ if ( next === "" || next === data . name ) return ;
7479 try {
75- await editTitle ( data . id , title ) ;
80+ await editTitle ( data . id , next ) ;
81+ setTitle ( next ) ;
7682 toast . success ( "Video title updated" ) ;
7783 refresh ( ) ;
7884 } catch ( error ) {
@@ -81,6 +87,7 @@ export const ShareHeader = ({
8187 } else {
8288 toast . error ( "Failed to update title - please try again." ) ;
8389 }
90+ setTitle ( data . name ) ;
8491 }
8592 } ;
8693
@@ -136,7 +143,7 @@ export const ShareHeader = ({
136143
137144 const renderSharedStatus = ( ) => {
138145 const baseClassName =
139- "text-sm text-gray-10 transition-colors duration-200 flex items-center" ;
146+ "text-sm text-gray-10 justify-center lg:justify-start transition-colors duration-200 flex items-center" ;
140147
141148 if ( isOwner ) {
142149 const hasSpaceSharing =
@@ -198,17 +205,37 @@ export const ShareHeader = ({
198205 />
199206 < div className = "mt-8" >
200207 < div className = "flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between lg:gap-0" >
201- < div className = "items-center md:flex md:justify-between md:space-x-6" >
202- < div className = "mb-3 md:mb-0" >
203- < div className = "flex items-center space-x-3 lg:min-w-[400px]" >
208+ < div className = "justify-center items-center mb-3 w-full md:flex lg:justify-between md:space-x-6 md:mb-0" >
209+ < div className = "flex flex-col gap-5 md:gap-10 lg:flex-row" >
210+ < div className = "flex flex-col flex-1 justify-center items-center w-full lg:justify-evenly" >
211+ { data . organizationIconUrl ? (
212+ < Image
213+ className = "rounded-full size-9"
214+ src = { data . organizationIconUrl }
215+ alt = "Organization icon"
216+ width = { 36 }
217+ height = { 36 }
218+ />
219+ ) : (
220+ < Avatar
221+ className = "rounded-full size-9"
222+ name = { data . organizationName ?? "Organization" }
223+ letterClass = "text-sm"
224+ />
225+ ) }
226+ < p className = "text-sm font-medium text-gray-12" >
227+ { data . organizationName }
228+ </ p >
229+ </ div >
230+ < div className = "flex flex-col justify-center text-center lg:text-left lg:justify-start" >
204231 { isEditing ? (
205232 < input
206233 value = { title }
207234 onChange = { ( e ) => setTitle ( e . target . value ) }
208235 onBlur = { handleBlur }
209236 onKeyDown = { handleKeyDown }
210237 autoFocus
211- className = "w-full text-xl font-semibold sm:text-2xl"
238+ className = "w-full text-xl sm:text-2xl"
212239 />
213240 ) : (
214241 < h1
@@ -222,16 +249,16 @@ export const ShareHeader = ({
222249 { title }
223250 </ h1 >
224251 ) }
252+ { user && renderSharedStatus ( ) }
253+ < p className = "mt-1 text-sm text-gray-10" >
254+ { moment ( data . createdAt ) . fromNow ( ) }
255+ </ p >
225256 </ div >
226- { user && renderSharedStatus ( ) }
227- < p className = "mt-1 text-sm text-gray-10" >
228- { moment ( data . createdAt ) . fromNow ( ) }
229- </ p >
230257 </ div >
231258 </ div >
232259 { user !== null && (
233- < div className = "flex space-x-2" >
234- < div >
260+ < div className = "flex justify-center space-x-2 w-full lg:justify-end " >
261+ < div className = "w-fit" >
235262 < div className = "flex gap-2 items-center" >
236263 { data . password && (
237264 < FontAwesomeIcon
0 commit comments