Skip to content

Commit

Permalink
fix: MIME_TYPE when upload images
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 27, 2022
1 parent 65e73bd commit 13c92f6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion GZCTF/ClientApp/src/components/ChallengePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ChallengePanel: FC = () => {
const tags = Object.keys(challenges ?? {})
const [activeTab, setActiveTab] = useState<ChallengeTag | 'All'>('All')
const [hideSolved, setHideSolved] = useLocalStorage({
key: 'hideSolved',
key: 'hide-solved',
defaultValue: false,
})

Expand Down
3 changes: 2 additions & 1 deletion GZCTF/ClientApp/src/components/TeamEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { mdiCheck, mdiClose, mdiCloseCircle, mdiRefresh, mdiCrown } from '@mdi/j
import { Icon } from '@mdi/react'
import { showErrorNotification } from '@Utils/ApiErrorHandler'
import api, { TeamInfoModel, TeamUserInfoModel } from '@Api'
import { ACCEPT_IMAGE_MIME_TYPE } from '@Utils/ThemeOverride'

interface TeamEditModalProps extends ModalProps {
team: TeamInfoModel | null
Expand Down Expand Up @@ -334,7 +335,7 @@ const TeamEditModal: FC<TeamEditModalProps> = (props) => {
minHeight: '220px',
}}
maxSize={3 * 1024 * 1024}
accept={['image/png', 'image/gif', 'image/jpeg']}
accept={ACCEPT_IMAGE_MIME_TYPE}
>
<Group position="center" spacing="xl" style={{ minHeight: 240, pointerEvents: 'none' }}>
{avatarFile ? (
Expand Down
3 changes: 2 additions & 1 deletion GZCTF/ClientApp/src/pages/account/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import WithNavBar from '@Components/WithNavbar'
import { showErrorNotification } from '@Utils/ApiErrorHandler'
import { usePageTitle } from '@Utils/PageTitle'
import api, { ProfileUpdateModel } from '@Api'
import { ACCEPT_IMAGE_MIME_TYPE } from '@Utils/ThemeOverride'

const Profile: FC = () => {
const [dropzoneOpened, setDropzoneOpened] = useState(false)
Expand Down Expand Up @@ -306,7 +307,7 @@ const Profile: FC = () => {
minHeight: '220px',
}}
maxSize={3 * 1024 * 1024}
accept={['image/png', 'image/gif', 'image/jpeg']}
accept={ACCEPT_IMAGE_MIME_TYPE}
>
<Group
position="center"
Expand Down
3 changes: 2 additions & 1 deletion GZCTF/ClientApp/src/pages/admin/games/[id]/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Icon } from '@mdi/react'
import WithGameEditTab from '@Components/admin/WithGameEditTab'
import { showErrorNotification } from '@Utils/ApiErrorHandler'
import api, { GameInfoModel } from '@Api'
import { ACCEPT_IMAGE_MIME_TYPE } from '@Utils/ThemeOverride'

const GameInfoEdit: FC = () => {
const { id } = useParams()
Expand Down Expand Up @@ -246,7 +247,7 @@ const GameInfoEdit: FC = () => {
})
}}
maxSize={3 * 1024 * 1024}
accept={['image/png', 'image/gif', 'image/jpeg']}
accept={ACCEPT_IMAGE_MIME_TYPE}
disabled={disabled}
styles={{
root: {
Expand Down
2 changes: 2 additions & 0 deletions GZCTF/ClientApp/src/utils/ThemeOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@ export const useTooltipStyles = createStyles((theme) => ({
color: theme.colorScheme === 'dark' ? theme.colors.white[2] : theme.colors.gray[7],
},
}))

export declare const ACCEPT_IMAGE_MIME_TYPE: ("image/png" | "image/gif" | "image/jpeg" | "image/webp")[];

0 comments on commit 13c92f6

Please sign in to comment.