@@ -6,14 +6,20 @@ import { Loader2, Upload } from 'lucide-react';
66import { toast } from 'sonner' ;
77import useFileUpload from '@/lib/hooks/useFileUpload' ;
88import useFileClient from '@/lib/hooks/useFileClient' ;
9- import { authClient } from '@/lib/auth/auth-client' ;
109
1110type OrgLogoUploaderProps = {
1211 organization : { id : string ; name : string ; logo : string | null } ;
12+ updateLogo : ( logoUrl : string ) => Promise < boolean > ;
13+ disabled ?: boolean ;
1314 onUpdated : ( ) => void ;
1415} ;
1516
16- export default function OrgLogoUploader ( { organization, onUpdated } : OrgLogoUploaderProps ) {
17+ export default function OrgLogoUploader ( {
18+ organization,
19+ updateLogo,
20+ disabled = false ,
21+ onUpdated,
22+ } : OrgLogoUploaderProps ) {
1723 const {
1824 file,
1925 preview,
@@ -37,12 +43,8 @@ export default function OrgLogoUploader({ organization, onUpdated }: OrgLogoUplo
3743 toast . error ( 'Failed to upload logo' ) ;
3844 return ;
3945 }
40- await authClient . organization . update ( {
41- data : { logo : url } ,
42- organizationId : organization . id ,
43- } ) ;
44- toast . success ( 'Logo updated' ) ;
45- onUpdated ( ) ;
46+ const ok = await updateLogo ( url ) ;
47+ if ( ok ) onUpdated ( ) ;
4648 } catch ( err ) {
4749 toast . error (
4850 `Failed to update logo: ${ err instanceof Error ? err . message : 'Unknown error' } `
@@ -52,14 +54,14 @@ export default function OrgLogoUploader({ organization, onUpdated }: OrgLogoUplo
5254 }
5355 } ;
5456 upload ( ) ;
55- } , [ file , organization . id , uploadFile , onUpdated ] ) ;
57+ } , [ file , organization . id , uploadFile , updateLogo , onUpdated ] ) ;
5658
5759 return (
5860 < div >
5961 < button
6062 type = "button"
6163 onClick = { openFilePicker }
62- disabled = { isUploading }
64+ disabled = { isUploading || disabled }
6365 className = "group bg-sarge-gray-500 text-sarge-gray-0 relative flex size-18 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-lg disabled:cursor-not-allowed"
6466 >
6567 { logoSrc ? (
0 commit comments