Skip to content

Commit

Permalink
fix(teams): mutate teams
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 4, 2023
1 parent 3008571 commit f9283c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/GZCTF/ClientApp/src/components/TeamCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import api, { TeamUpdateModel } from '@Api'

interface TeamEditModalProps extends ModalProps {
isOwnTeam: boolean
mutate: () => void
}

const TeamCreateModal: FC<TeamEditModalProps> = (props) => {
const { isOwnTeam, ...modalProps } = props
const { isOwnTeam, mutate, ...modalProps } = props
const [createTeam, setCreateTeam] = useState<TeamUpdateModel>({ name: '', bio: '' })
const theme = useMantineTheme()

Expand All @@ -36,7 +37,7 @@ const TeamCreateModal: FC<TeamEditModalProps> = (props) => {
message: `${res.data.name} 创建成功,快去邀请队友吧!`,
icon: <Icon path={mdiCheck} size={1} />,
})
api.team.mutateTeamGetTeamsInfo()
mutate()
})
.catch(showErrorNotification)
.finally(() => {
Expand Down
5 changes: 3 additions & 2 deletions src/GZCTF/ClientApp/src/pages/Teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import api, { TeamInfoModel, Role } from '@Api'

const Teams: FC = () => {
const { user, error: userError } = useUser()
const { teams, error: teamsError } = useTeams()
const { teams, mutate: mutateTeams, error: teamsError } = useTeams()

const theme = useMantineTheme()

Expand Down Expand Up @@ -72,7 +72,7 @@ const Teams: FC = () => {
message: '队伍信息已更新',
icon: <Icon path={mdiCheck} size={1} />,
})
api.team.mutateTeamGetTeamsInfo()
mutateTeams()
})
.catch(showErrorNotification)
.finally(() => {
Expand Down Expand Up @@ -180,6 +180,7 @@ const Teams: FC = () => {
title="创建新队伍"
isOwnTeam={ownTeam ?? false}
onClose={() => setCreateOpened(false)}
mutate={mutateTeams}
/>

<TeamEditModal
Expand Down

0 comments on commit f9283c3

Please sign in to comment.