Fixed team data not refreshing.

This commit is contained in:
Mike Cao 2024-06-22 16:23:06 -07:00
parent b0c9197f2d
commit 2109d3225e

View File

@ -11,7 +11,7 @@ import {
} from 'react-basics'; } from 'react-basics';
import { getRandomChars } from 'next-basics'; import { getRandomChars } from 'next-basics';
import { useContext, useRef, useState } from 'react'; import { useContext, useRef, useState } from 'react';
import { useApi, useMessages } from 'components/hooks'; import { useApi, useMessages, useModified } from 'components/hooks';
import { TeamContext } from 'app/(main)/teams/[teamId]/TeamProvider'; import { TeamContext } from 'app/(main)/teams/[teamId]/TeamProvider';
const generateId = () => getRandomChars(16); const generateId = () => getRandomChars(16);
@ -26,12 +26,14 @@ export function TeamEditForm({ teamId, allowEdit }: { teamId: string; allowEdit?
const ref = useRef(null); const ref = useRef(null);
const [accessCode, setAccessCode] = useState(team.accessCode); const [accessCode, setAccessCode] = useState(team.accessCode);
const { showToast } = useToasts(); const { showToast } = useToasts();
const { touch } = useModified();
const cloudMode = !!process.env.cloudMode; const cloudMode = !!process.env.cloudMode;
const handleSubmit = async (data: any) => { const handleSubmit = async (data: any) => {
mutate(data, { mutate(data, {
onSuccess: async () => { onSuccess: async () => {
ref.current.reset(data); ref.current.reset(data);
touch('teams');
showToast({ message: formatMessage(messages.saved), variant: 'success' }); showToast({ message: formatMessage(messages.saved), variant: 'success' });
}, },
}); });