fix: refresh memberlist when switching account (#3814)

This commit is contained in:
Finley Ge
2025-02-18 13:54:56 +08:00
committed by GitHub
parent b14674cc6f
commit 3e13397614
3 changed files with 10 additions and 4 deletions

View File

@@ -13,9 +13,11 @@ import { useRouter } from 'next/router';
const TeamSelector = ({
showManage,
afterSwitchTeam,
...props
}: ButtonProps & {
showManage?: boolean;
afterSwitchTeam?: () => void;
}) => {
const { t } = useTranslation();
const router = useRouter();
@@ -36,6 +38,7 @@ const TeamSelector = ({
{
onFinally: () => {
setLoading(false);
afterSwitchTeam?.();
},
errorToast: t('common:user.team.Switch Team Failed')
}

View File

@@ -110,7 +110,7 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => {
const theme = useTheme();
const { feConfigs } = useSystemStore();
const { t } = useTranslation();
const { userInfo, updateUserInfo, teamPlanStatus } = useUserStore();
const { userInfo, updateUserInfo, teamPlanStatus, initUserInfo } = useUserStore();
const { reset } = useForm<UserUpdateParams>({
defaultValues: userInfo as UserType
});
@@ -284,7 +284,7 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => {
<Flex mt={6} alignItems={'center'}>
<Box {...labelStyles}>{t('account_info:user_team_team_name')}:&nbsp;</Box>
<Flex flex={'1 0 0'} w={0} align={'center'}>
<TeamSelector height={'28px'} w={'100%'} showManage />
<TeamSelector height={'28px'} w={'100%'} showManage afterSwitchTeam={initUserInfo} />
</Flex>
</Flex>
)}

View File

@@ -35,7 +35,10 @@ const Team = () => {
const { t } = useTranslation();
const { userInfo } = useUserStore();
const { setEditTeamData, isLoading, teamSize } = useContextSelector(TeamContext, (v) => v);
const { setEditTeamData, isLoading, teamSize, refetchMembers } = useContextSelector(
TeamContext,
(v) => v
);
const Tabs = useMemo(
() => (
@@ -85,7 +88,7 @@ const Team = () => {
</Box>
</Flex>
<Flex align={'center'} ml={6}>
<TeamSelector height={'28px'} />
<TeamSelector height={'28px'} afterSwitchTeam={refetchMembers} />
</Flex>
{userInfo?.team?.role === TeamMemberRoleEnum.owner && (
<Flex align={'center'} justify={'center'} ml={2} p={'0.44rem'}>