@@ -2,10 +2,9 @@ import { useCallback, useEffect, useRef, useState } from 'react'
22import { createLogger } from '@sim/logger'
33import { getErrorMessage } from '@sim/utils/errors'
44import { uploadInternalFileSession } from '@/lib/uploads/client/session-upload'
5+ import { validateWorkspaceLogoFile } from '@/app/workspace/[workspaceId]/w/components/sidebar/hooks/workspace-logo-file'
56
67const logger = createLogger ( 'WorkspaceLogoUpload' )
7- const MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB
8- const ACCEPTED_IMAGE_TYPES = [ 'image/png' , 'image/jpeg' , 'image/jpg' , 'image/svg+xml' , 'image/webp' ]
98
109interface UseWorkspaceLogoUploadProps {
1110 workspaceId ?: string
@@ -51,16 +50,6 @@ export function useWorkspaceLogoUpload({
5150 setPreviewUrl ( currentLogoUrl || null )
5251 } , [ currentLogoUrl ] )
5352
54- const validateFile = useCallback ( ( file : File ) : string | null => {
55- if ( file . size > MAX_FILE_SIZE ) {
56- return `File "${ file . name } " is too large. Maximum size is 5MB.`
57- }
58- if ( ! ACCEPTED_IMAGE_TYPES . includes ( file . type ) ) {
59- return `File "${ file . name } " is not a supported image format. Please use PNG, JPEG, SVG, or WebP.`
60- }
61- return null
62- } , [ ] )
63-
6453 const uploadFileToServer = useCallback ( async ( file : File ) : Promise < string > => {
6554 const targetWorkspaceId = workspaceIdRef . current
6655 if ( ! targetWorkspaceId ) {
@@ -78,7 +67,7 @@ export function useWorkspaceLogoUpload({
7867
7968 const processFile = useCallback (
8069 async ( file : File ) => {
81- const validationError = validateFile ( file )
70+ const validationError = validateWorkspaceLogoFile ( file )
8271 if ( validationError ) {
8372 onErrorRef . current ?.( validationError )
8473 return
@@ -106,7 +95,7 @@ export function useWorkspaceLogoUpload({
10695 setIsUploading ( false )
10796 }
10897 } ,
109- [ uploadFileToServer , validateFile ]
98+ [ uploadFileToServer ]
11099 )
111100
112101 const handleFileChange = useCallback (
0 commit comments