diff --git a/src/backend/src/services/organizations.services.ts b/src/backend/src/services/organizations.services.ts index ba785861cb..5feed48fc4 100644 --- a/src/backend/src/services/organizations.services.ts +++ b/src/backend/src/services/organizations.services.ts @@ -220,7 +220,7 @@ export default class OrganizationsService { * @param organizationId the id of the organization * @returns the id of the image */ - static async getLogoImage(organizationId: string): Promise { + static async getLogoImage(organizationId: string): Promise { const organization = await prisma.organization.findUnique({ where: { organizationId } }); @@ -229,10 +229,6 @@ export default class OrganizationsService { throw new NotFoundException('Organization', organizationId); } - if (!organization.logoImageId) { - throw new HttpException(404, `Organization ${organizationId} does not have a logo image`); - } - return organization.logoImageId; } diff --git a/src/frontend/public/default-logo.png b/src/frontend/public/default-logo.png deleted file mode 100644 index a549f0ea69..0000000000 Binary files a/src/frontend/public/default-logo.png and /dev/null differ diff --git a/src/frontend/src/hooks/organizations.hooks.ts b/src/frontend/src/hooks/organizations.hooks.ts index 4c04bc0c60..bd2f3ac964 100644 --- a/src/frontend/src/hooks/organizations.hooks.ts +++ b/src/frontend/src/hooks/organizations.hooks.ts @@ -11,7 +11,6 @@ import { setOrganizationFeaturedProjects } from '../apis/organizations.api'; import { downloadGoogleImage } from '../apis/finance.api'; -import { getDefaultImageData } from '../utils/image.utils'; interface OrganizationProvider { organizationId: string; @@ -99,13 +98,11 @@ export const useSetOrganizationLogo = () => { }; export const useOrganizationLogo = () => { - return useQuery(['organizations', 'logo'], async () => { - try { - const { data: fileId } = await getOrganizationLogo(); - return await downloadGoogleImage(fileId); - } catch { - // return default logo if fileId was not found - return await getDefaultImageData(); + return useQuery(['organizations', 'logo'], async () => { + const { data: fileId } = await getOrganizationLogo(); + if (!fileId) { + return; } + return await downloadGoogleImage(fileId); }); }; diff --git a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx index 6fd56bbe66..9ba6a4643e 100644 --- a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx +++ b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx @@ -15,7 +15,7 @@ const EditLogo = () => { const [isEditMode, setIsEditMode] = useState(false); const theme = useTheme(); - if (isLoading || !mutateAsync || organizationIsLoading || !organization || !imageData || imageDataIsLoading) + if (isLoading || !mutateAsync || organizationIsLoading || !organization || imageDataIsLoading) return ; const handleClose = () => { @@ -60,12 +60,12 @@ const EditLogo = () => { ) : ( <> - + Promise; onHide: () => void; - orgLogo: File; + orgLogo?: File; } const EditLogoForm: React.FC = ({ onSubmit, orgLogo, onHide }) => { @@ -24,7 +24,9 @@ const EditLogoForm: React.FC = ({ onSubmit, orgLogo, onHide } }); const onSubmitWrapper = async (data: EditLogoInput) => { - await onSubmit(data); + if (!!data.logoImage) { + await onSubmit(data); + } reset(); }; @@ -85,7 +87,7 @@ const EditLogoForm: React.FC = ({ onSubmit, orgLogo, onHide } hidden /> - {value.name !== 'undefined' && ( + {value && value.name !== 'undefined' && ( {value.name} diff --git a/src/frontend/src/pages/HomePage/components/LogoDisplay.tsx b/src/frontend/src/pages/HomePage/components/LogoDisplay.tsx index a0699c9916..e56da136cf 100644 --- a/src/frontend/src/pages/HomePage/components/LogoDisplay.tsx +++ b/src/frontend/src/pages/HomePage/components/LogoDisplay.tsx @@ -2,7 +2,7 @@ import { Box, useTheme, Card } from '@mui/material'; import React from 'react'; interface LogoDisplayProps { - imageUrl: string; + imageUrl?: string; } const LogoDisplay: React.FC = ({ imageUrl }) => { @@ -17,7 +17,7 @@ const LogoDisplay: React.FC = ({ imageUrl }) => { borderRadius: 2 }} > - = ({ imageUrl }) => { width: '100%', borderRadius: 2 }} - /> + />} ); }; diff --git a/src/frontend/src/utils/image.utils.ts b/src/frontend/src/utils/image.utils.ts deleted file mode 100644 index 198e07ed88..0000000000 --- a/src/frontend/src/utils/image.utils.ts +++ /dev/null @@ -1,8 +0,0 @@ -import axios from 'axios'; - -export const getDefaultImageData = async () => { - const { data } = await axios.get('/default-logo.png', { - responseType: 'blob' - }); - return data; -};