diff --git a/src/backend/src/services/organizations.services.ts b/src/backend/src/services/organizations.services.ts index c4ce91668b..ba785861cb 100644 --- a/src/backend/src/services/organizations.services.ts +++ b/src/backend/src/services/organizations.services.ts @@ -201,6 +201,10 @@ export default class OrganizationsService { const logoImageData = await uploadFile(logoImage); + if (!logoImageData?.name) { + throw new HttpException(500, 'Image Name not found'); + } + const updatedOrg = await prisma.organization.update({ where: { organizationId: organization.organizationId }, data: { diff --git a/src/frontend/src/pages/AdminToolsPage/AdminToolsPage.tsx b/src/frontend/src/pages/AdminToolsPage/AdminToolsPage.tsx index 059f2a2514..cc90246456 100644 --- a/src/frontend/src/pages/AdminToolsPage/AdminToolsPage.tsx +++ b/src/frontend/src/pages/AdminToolsPage/AdminToolsPage.tsx @@ -18,7 +18,6 @@ import NERTabs from '../../components/Tabs'; import { routes } from '../../utils/routes'; import { Box } from '@mui/system'; import AdminToolsRecruitmentConfig from './RecruitmentConfig/AdminToolsRecruitmentConfig'; -import EditDescription from './EditGuestView/EditDescription'; import EditLogo from './EditGuestView/EditLogo'; const AdminToolsPage: React.FC = () => { diff --git a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx index 311ec282f0..e545a78e86 100644 --- a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx +++ b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx @@ -1,21 +1,29 @@ import React from 'react'; -import { useCurrentOrganization, useOrganizationLogo, useSetOrganizationLogo } from '../../../hooks/organizations.hooks'; +import { useCurrentOrganization, useSetOrganizationLogo } from '../../../hooks/organizations.hooks'; import LoadingIndicator from '../../../components/LoadingIndicator'; import EditLogoForm from './EditLogoForm'; +import { useToast } from '../../../hooks/toasts.hooks'; const EditLogo = () => { const { data: organization, isLoading: organizationIsLoading } = useCurrentOrganization(); const { mutateAsync } = useSetOrganizationLogo(); - const { data: imageUrl } = useOrganizationLogo(); + const toast = useToast(); if (organizationIsLoading || !organization) return ; const onSubmitWrapper = async (logoImage: File) => { - console.log('RECEIVED FILE'); + try { + await mutateAsync(logoImage); + toast.success('Logo updated successfully!'); + } catch (e) { + if (e instanceof Error) { + toast.error(e.message); + } + } await mutateAsync(logoImage); }; - return ; + return ; }; export default EditLogo; diff --git a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogoForm.tsx b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogoForm.tsx index 56fb62c168..18c64eb2ac 100644 --- a/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogoForm.tsx +++ b/src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogoForm.tsx @@ -1,39 +1,31 @@ import React from 'react'; import { Box, Button, Stack, useTheme } from '@mui/material'; import FileUploadIcon from '@mui/icons-material/FileUpload'; +import LogoDisplay from '../../HomePage/components/LogoDisplay'; interface EditLogoFormProps { - logoImageUrl?: string; onSubmit: (logoImage: File) => Promise; } -const EditLogoForm: React.FC = ({ logoImageUrl, onSubmit }) => { +const EditLogoForm: React.FC = ({ onSubmit }) => { const theme = useTheme(); return ( - {!logoImageUrl ? ( - - ) : ( - - )} + + + +