Skip to content

Commit

Permalink
#3060-fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Dec 20, 2024
1 parent b9206bd commit 06df950
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 11 additions & 3 deletions src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@ import { useToast } from '../../../hooks/toasts.hooks';
import { Box, Card, Typography, useTheme } from '@mui/material';
import LogoDisplay from '../../HomePage/components/LogoDisplay';
import { NERButton } from '../../../components/NERButton';
import ErrorPage from '../../ErrorPage';

const EditLogo = () => {
const { data: organization, isLoading: organizationIsLoading } = useCurrentOrganization();
const { data: imageData, isLoading: imageDataIsLoading } = useOrganizationLogo();
const {
data: organization,
isLoading: organizationIsLoading,
isError: organizationIsError,
error: organizationError
} = useCurrentOrganization();
const { data: imageData, isLoading: imageDataIsLoading, isError: imageIsError, error: imageError } = useOrganizationLogo();
const { mutateAsync, isLoading } = useSetOrganizationLogo();
const toast = useToast();
const [isEditMode, setIsEditMode] = useState(false);
const theme = useTheme();

if (isLoading || !mutateAsync || organizationIsLoading || !organization || imageDataIsLoading) return <LoadingIndicator />;
if (organizationIsError) return <ErrorPage message={organizationError.message} />;
if (imageIsError) return <ErrorPage message={imageError.message} />;

const handleClose = () => {
setIsEditMode(false);
};

const onSubmit = async (logoInput: EditLogoInput) => {
try {
console.log(logoInput);
if (!logoInput.logoImage) {
toast.error('No logo image submitted.');
handleClose();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ const EditLogoForm: React.FC<EditLogoFormProps> = ({ onSubmit, orgLogo, onHide }
}
});

const onSubmitWrapper = async (data: EditLogoInput) => {
if (!!data.logoImage) {
await onSubmit(data);
}
reset();
};

const onHideWrapper = () => {
onHide();
reset();
Expand Down Expand Up @@ -106,12 +99,7 @@ const EditLogoForm: React.FC<EditLogoFormProps> = ({ onSubmit, orgLogo, onHide }
<NERFailButton sx={{ mx: 1 }} form={'edit-organization-logo'} onClick={onHideWrapper}>
Cancel
</NERFailButton>
<NERSuccessButton
sx={{ mx: 1 }}
type="submit"
form={'edit-organization-logo'}
onClick={handleSubmit(onSubmitWrapper)}
>
<NERSuccessButton sx={{ mx: 1 }} type="submit" form={'edit-organization-logo'}>
Save
</NERSuccessButton>
</Box>
Expand Down

0 comments on commit 06df950

Please sign in to comment.