Skip to content

Commit

Permalink
feat(admin): edit team division
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Nov 20, 2024
1 parent 9a5b437 commit 326d20f
Show file tree
Hide file tree
Showing 92 changed files with 341 additions and 166 deletions.
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"vite-plugin-pages": "^0.32.3",
"vite-plugin-prismjs": "^0.0.11",
"vite-plugin-webfont-dl": "^3.10.1",
"vite-tsconfig-paths": "^5.1.2"
"vite-tsconfig-paths": "^5.1.3"
},
"pnpm": {
"overrides": {
Expand Down
10 changes: 5 additions & 5 deletions src/GZCTF/ClientApp/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/GZCTF/ClientApp/prettier.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
'<THIRD_PARTY_MODULES>',
'^@Components/(.*)$',
'^@Utils/(.*)$',
'^@Hooks/(.*)$',
'^@Api$',
'^@Styles/(.*)$',
'^@(.*).css$',
Expand Down
16 changes: 13 additions & 3 deletions src/GZCTF/ClientApp/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,14 @@ export interface LogMessageModel {
status?: string | null;
}

/** Modify the participation information */
export interface ParticipationEditModel {
/** Participation Status */
status?: ParticipationStatus | null;
/** The division of the participated team */
division?: string | null;
}

export enum ParticipationStatus {
Pending = "Pending",
Accepted = "Accepted",
Expand Down Expand Up @@ -2528,12 +2536,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @tags Admin
* @name AdminParticipation
* @summary 更新参与状态
* @request PUT:/api/admin/participation/{id}/{status}
* @request PUT:/api/admin/participation/{id}
*/
adminParticipation: (id: number, status: ParticipationStatus, params: RequestParams = {}) =>
adminParticipation: (id: number, data: ParticipationEditModel, params: RequestParams = {}) =>
this.request<void, RequestResponse>({
path: `/api/admin/participation/${id}/${status}`,
path: `/api/admin/participation/${id}`,
method: "PUT",
body: data,
type: ContentType.Json,
...params,
}),

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import routes from '~react-pages'
import { ErrorFallback } from '@Components/ErrorFallback'
import { useLanguage } from '@Utils/I18n'
import { useCustomTheme } from '@Utils/ThemeOverride'
import { useBanner, localCacheProvider } from '@Utils/useConfig'
import { useBanner, localCacheProvider } from '@Hooks/useConfig'
import { fetcher } from '@Api'
import '@mantine/carousel/styles.css'
import '@mantine/core/styles.css'
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/AppFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC } from 'react'
import { FooterRender } from '@Components/FooterRender'
import { MainIcon } from '@Components/icon/MainIcon'
import { useIsMobile } from '@Utils/ThemeOverride'
import { useConfig } from '@Utils/useConfig'
import { useConfig } from '@Hooks/useConfig'
import classes from '@Styles/AppFooter.module.css'
import logoClasses from '@Styles/LogoHeader.module.css'

Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/ClientApp/src/components/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { LogoHeader } from '@Components/LogoHeader'
import { AppControlProps } from '@Components/WithNavbar'
import { LanguageMap, SupportedLanguages, useLanguage } from '@Utils/I18n'
import { useIsMobile } from '@Utils/ThemeOverride'
import { clearLocalCache } from '@Utils/useConfig'
import { useLogOut, useUser } from '@Utils/useUser'
import { clearLocalCache } from '@Hooks/useConfig'
import { useLogOut, useUser } from '@Hooks/useUser'
import classes from '@Styles/AppHeader.module.css'

export const AppHeader: FC<AppControlProps> = ({ openColorModal }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/ClientApp/src/components/AppNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { Link, useLocation } from 'react-router-dom'
import { LogoBox } from '@Components/LogoBox'
import { AppControlProps } from '@Components/WithNavbar'
import { LanguageMap, SupportedLanguages, useLanguage } from '@Utils/I18n'
import { clearLocalCache } from '@Utils/useConfig'
import { useLogOut, useUser } from '@Utils/useUser'
import { clearLocalCache } from '@Hooks/useConfig'
import { useLogOut, useUser } from '@Hooks/useUser'
import { Role } from '@Api'
import classes from '@Styles/AppNavBar.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/Captcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
import { forwardRef, useImperativeHandle, useRef } from 'react'
import { GoogleReCaptchaProvider, useGoogleReCaptcha } from 'react-google-recaptcha-v3'
import { HashPow } from '@Components/HashPow'
import { useCaptchaConfig } from '@Utils/useConfig'
import { useCaptchaConfig } from '@Hooks/useConfig'
import { CaptchaProvider } from '@Api'

interface CaptchaProps extends BoxProps {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/ChallengePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Empty } from '@Components/Empty'
import { GameChallengeModal } from '@Components/GameChallengeModal'
import { WriteupSubmitModal } from '@Components/WriteupSubmitModal'
import { useChallengeCategoryLabelMap, SubmissionTypeIconMap } from '@Utils/Shared'
import { useGame, useGameTeamInfo } from '@Utils/useGame'
import { useGame, useGameTeamInfo } from '@Hooks/useGame'
import { ChallengeInfo, ChallengeCategory, SubmissionType } from '@Api'
import classes from '@Styles/ChallengePanel.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/ErrorFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC } from 'react'
import { FallbackProps } from 'react-error-boundary'
import { useTranslation } from 'react-i18next'
import { useIsMobile } from '@Utils/ThemeOverride'
import { clearLocalCache } from '@Utils/useConfig'
import { clearLocalCache } from '@Hooks/useConfig'

export const ErrorFallback: FC<FallbackProps> = ({ error, resetErrorBoundary }: FallbackProps) => {
const theme = useMantineTheme()
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/GameCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { useLanguage } from '@Utils/I18n'
import { getGameStatus } from '@Utils/useGame'
import { getGameStatus } from '@Hooks/useGame'
import { BasicGameInfoModel } from '@Api'
import classes from '@Styles/HoverCard.module.css'

Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/ClientApp/src/components/GameJoinModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Icon } from '@mdi/react'
import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { useGame } from '@Utils/useGame'
import { useTeams } from '@Utils/useUser'
import { useGame } from '@Hooks/useGame'
import { useTeams } from '@Hooks/useUser'
import { GameJoinModel } from '@Api'

interface GameJoinModalProps extends ModalProps {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/IconHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, Group, Text, Title } from '@mantine/core'
import { FC } from 'react'
import { LogoHeader } from '@Components/LogoHeader'
import { useIsMobile } from '@Utils/ThemeOverride'
import { useConfig } from '@Utils/useConfig'
import { useConfig } from '@Hooks/useConfig'
import classes from '@Styles/IconHeader.module.css'

interface StickyHeaderProps {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/InstanceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import duration from 'dayjs/plugin/duration'
import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getProxyUrl } from '@Utils/Shared'
import { useConfig } from '@Utils/useConfig'
import { useConfig } from '@Hooks/useConfig'
import { ClientFlagContext } from '@Api'
import tooltipClasses from '@Styles/Tooltip.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/LogoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, BoxProps, createPolymorphicComponent, ElementProps, em, Image } from '@mantine/core'
import { forwardRef } from 'react'
import { MainIcon, MainIconProps } from '@Components/icon/MainIcon'
import { useConfig } from '@Utils/useConfig'
import { useConfig } from '@Hooks/useConfig'

type LogoProps = MainIconProps & BoxProps & ElementProps<'div'> & { url?: string }

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/LogoHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Group, GroupProps, Title } from '@mantine/core'
import { forwardRef } from 'react'
import { LogoBox } from '@Components/LogoBox'
import { useConfig } from '@Utils/useConfig'
import { useConfig } from '@Hooks/useConfig'
import classes from '@Styles/LogoHeader.module.css'

export const LogoHeader = forwardRef<HTMLDivElement, GroupProps>((props, ref) => {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/MobilePostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Link } from 'react-router-dom'
import { Markdown } from '@Components/MarkdownRenderer'
import { PostCardProps } from '@Components/PostCard'
import { RequireRole } from '@Components/WithRole'
import { useUserRole } from '@Utils/useUser'
import { useUserRole } from '@Hooks/useUser'
import { Role } from '@Api'

export const MobilePostCard: FC<PostCardProps> = ({ post, onTogglePinned }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useParams } from 'react-router-dom'
import { MobileScoreboardItemModal } from '@Components/MobileScoreboardItemModal'
import { ScoreboardProps } from '@Components/ScoreboardTable'
import { BloodBonus, useBonusLabels } from '@Utils/Shared'
import { useGameScoreboard } from '@Utils/useGame'
import { useGameScoreboard } from '@Hooks/useGame'
import { ScoreboardItem } from '@Api'
import classes from '@Styles/ScoreboardTable.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Link } from 'react-router-dom'
import { Markdown } from '@Components/MarkdownRenderer'
import { RequireRole } from '@Components/WithRole'
import { useLanguage } from '@Utils/I18n'
import { useUserRole } from '@Utils/useUser'
import { useUserRole } from '@Hooks/useUser'
import { PostInfoModel, Role } from '@Api'

export interface PostCardProps {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/RecentGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { GameColorMap, GameStatus } from '@Components/GameCard'
import { useLanguage } from '@Utils/I18n'
import { getGameStatus } from '@Utils/useGame'
import { getGameStatus } from '@Hooks/useGame'
import { BasicGameInfoModel } from '@Api'
import classes from '@Styles/HoverCard.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/RecentGameSlide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { GameColorMap, GameStatus } from '@Components/GameCard'
import { RecentGameProps } from '@Components/RecentGame'
import { getGameStatus } from '@Utils/useGame'
import { getGameStatus } from '@Hooks/useGame'
import classes from '@Styles/RecentGameSlide.module.css'

export const RecentGameSlide: FC<RecentGameProps> = ({ game, ...others }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/ScoreboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
useBonusLabels,
PartialIconProps,
} from '@Utils/Shared'
import { useGameScoreboard } from '@Utils/useGame'
import { useGameScoreboard } from '@Hooks/useGame'
import { ChallengeInfo, ChallengeCategory, ScoreboardItem, SubmissionType } from '@Api'
import classes from '@Styles/ScoreboardTable.module.css'
import tooltipClasses from '@Styles/Tooltip.module.css'
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/TeamRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useTranslation } from 'react-i18next'
import { useNavigate, useParams } from 'react-router-dom'
import { ErrorCodes } from '@Utils/Shared'
import { useIsMobile } from '@Utils/ThemeOverride'
import { useGameTeamInfo } from '@Utils/useGame'
import { useGameTeamInfo } from '@Hooks/useGame'

export const TeamRank: FC<CardProps> = (props) => {
const { id } = useParams()
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/TimeLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { normalizeLanguage, useLanguage } from '@Utils/I18n'
import { getGameStatus, useGame, useGameScoreboard } from '@Utils/useGame'
import { getGameStatus, useGame, useGameScoreboard } from '@Hooks/useGame'

interface TimeLineProps {
division: string | null
Expand Down
6 changes: 3 additions & 3 deletions src/GZCTF/ClientApp/src/components/WithGameTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { GameProgress } from '@Components/GameProgress'
import { IconTabs } from '@Components/IconTabs'
import { RequireRole } from '@Components/WithRole'
import { DEFAULT_LOADING_OVERLAY } from '@Utils/Shared'
import { getGameStatus, useGame } from '@Utils/useGame'
import { usePageTitle } from '@Utils/usePageTitle'
import { useUserRole } from '@Utils/useUser'
import { getGameStatus, useGame } from '@Hooks/useGame'
import { usePageTitle } from '@Hooks/usePageTitle'
import { useUserRole } from '@Hooks/useUser'
import { DetailedGameInfoModel, ParticipationStatus, Role } from '@Api'

dayjs.extend(duration)
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/WithNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Watermark } from '@Components/Watermark'
import { WithWiderScreen } from '@Components/WithWiderScreen'
import { DEFAULT_LOADING_OVERLAY } from '@Utils/Shared'
import { useIsMobile } from '@Utils/ThemeOverride'
import { useUser } from '@Utils/useUser'
import { useUser } from '@Hooks/useUser'

interface WithNavBarProps extends React.PropsWithChildren {
width?: string
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/WithRole.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Center, Loader } from '@mantine/core'
import React, { FC, useEffect } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { useUserRole } from '@Utils/useUser'
import { useUserRole } from '@Hooks/useUser'
import { Role } from '@Api'

interface WithRoleProps {
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/WriteupSubmitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Markdown } from '@Components/MarkdownRenderer'
import { showErrorNotification } from '@Utils/ApiHelper'
import { useLanguage } from '@Utils/I18n'
import { HunamizeSize } from '@Utils/Shared'
import { OnceSWRConfig } from '@Utils/useConfig'
import { OnceSWRConfig } from '@Hooks/useConfig'
import api from '@Api'
import uploadClasses from '@Styles/Upload.module.css'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { showErrorNotification } from '@Utils/ApiHelper'
import { useEditChallenge } from '@Utils/useEdit'
import { useEditChallenge } from '@Hooks/useEdit'
import api, { FileType, FlagCreateModel } from '@Api'

export const AttachmentRemoteEditModal: FC<ModalProps> = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FC, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { showErrorNotification } from '@Utils/ApiHelper'
import { useEditChallenge } from '@Utils/useEdit'
import { useEditChallenge } from '@Hooks/useEdit'
import api, { FileType } from '@Api'
import uploadClasses from '@Styles/Upload.module.css'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { BloodBonus } from '@Utils/Shared'
import { OnceSWRConfig } from '@Utils/useConfig'
import { OnceSWRConfig } from '@Hooks/useConfig'
import api, { SubmissionType } from '@Api'

const toNumber = (value: string | number) => {
Expand Down
46 changes: 46 additions & 0 deletions src/GZCTF/ClientApp/src/components/admin/DivisionEditModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ModalProps, Modal, Stack, Select, Button } from '@mantine/core'
import { FC, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ParticipationEditModel } from '@Api'

interface DivisionEditModalProps extends ModalProps {
participateId: number
divisions: string[]
currentDivision: string
setParticipation: (id: number, model: ParticipationEditModel) => Promise<void>
}

export const DivisionEditModal: FC<DivisionEditModalProps> = (props) => {
const { participateId, divisions, currentDivision, setParticipation, ...modalProps } = props
const [division, setDivision] = useState(currentDivision)
const [disabled, setDisabled] = useState(false)

const { t } = useTranslation()

const onConfirm = () => {
if (!division) return
setDisabled(true)
setParticipation(participateId, { division }).then(() => {
setDisabled(false)
modalProps.onClose()
})
}

return (
<Modal {...modalProps}>
<Stack>
<Select
required
label={t('game.content.join.division.label')}
data={divisions}
disabled={disabled}
value={division}
onChange={(e) => setDivision(e ?? '')}
/>
<Button fullWidth disabled={disabled} onClick={onConfirm}>
{t('common.modal.confirm_update')}
</Button>
</Stack>
</Modal>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FC, useState } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { showErrorNotification } from '@Utils/ApiHelper'
import { useEditChallenge } from '@Utils/useEdit'
import { useEditChallenge } from '@Hooks/useEdit'
import api from '@Api'

export const FlagCreateModal: FC<ModalProps> = (props) => {
Expand Down
Loading

0 comments on commit 326d20f

Please sign in to comment.