-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db222ba
commit 32e23a4
Showing
5 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { useCurrentOrganization, useOrganizationLogo, useSetOrganizationLogo } from '../../../hooks/organizations.hooks'; | ||
import LoadingIndicator from '../../../components/LoadingIndicator'; | ||
import EditLogoForm from './EditLogoForm'; | ||
|
||
const EditLogo = () => { | ||
const { data: organization, isLoading: organizationIsLoading } = useCurrentOrganization(); | ||
const { mutateAsync } = useSetOrganizationLogo(); | ||
const { data: imageUrl } = useOrganizationLogo(); | ||
|
||
if (organizationIsLoading || !organization) return <LoadingIndicator />; | ||
|
||
const onSubmitWrapper = async (logoImage: File) => { | ||
console.log('RECEIVED FILE'); | ||
await mutateAsync(logoImage); | ||
}; | ||
|
||
return <EditLogoForm logoImageUrl={imageUrl} onSubmit={onSubmitWrapper} />; | ||
}; | ||
|
||
export default EditLogo; |
66 changes: 66 additions & 0 deletions
66
src/frontend/src/pages/AdminToolsPage/EditGuestView/EditLogoForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import { Box, Button, Stack, useTheme } from '@mui/material'; | ||
import FileUploadIcon from '@mui/icons-material/FileUpload'; | ||
|
||
interface EditLogoFormProps { | ||
logoImageUrl?: string; | ||
onSubmit: (logoImage: File) => Promise<void>; | ||
} | ||
|
||
const EditLogoForm: React.FC<EditLogoFormProps> = ({ logoImageUrl, onSubmit }) => { | ||
const theme = useTheme(); | ||
return ( | ||
<Stack spacing={2}> | ||
{!logoImageUrl ? ( | ||
<Box | ||
sx={{ | ||
background: theme.palette.background.paper, | ||
width: 300, | ||
height: 300, | ||
borderRadius: 2, | ||
boxShadow: 3 | ||
}} | ||
/> | ||
) : ( | ||
<Box | ||
component="img" | ||
src={logoImageUrl} | ||
alt="Logo" | ||
sx={{ | ||
width: 300, | ||
height: 300, | ||
borderRadius: 2, | ||
boxShadow: 3 | ||
}} | ||
/> | ||
)} | ||
<Button | ||
variant="contained" | ||
color="error" | ||
component="label" | ||
startIcon={<FileUploadIcon />} | ||
sx={{ | ||
width: 'fit-content', | ||
textTransform: 'none', | ||
mt: '9.75px' | ||
}} | ||
> | ||
Upload | ||
<input | ||
onChange={(e) => { | ||
console.log('SUBMITTED'); | ||
!!e.target.files && onSubmit(e.target.files[0]); | ||
}} | ||
type="file" | ||
id="logo-image" | ||
accept="image/png, image/jpeg, application/pdf" | ||
name="logoImageFile" | ||
multiple | ||
hidden | ||
/> | ||
</Button> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default EditLogoForm; |