Skip to content

Commit

Permalink
[FE][Feat] #241 : API 완료 시 메인페이지로 이동 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
leedongyull committed Nov 26, 2024
1 parent 96e8080 commit a31703d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions frontend/src/pages/AddChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from 'react';
import { HiMiniInformationCircle } from 'react-icons/hi2';
import { FooterContext } from '@/component/layout/footer/LayoutFooterProvider';
import { RouteSettingButton } from '@/component/routebutton/RouteSettingButton';
import { Outlet } from 'react-router-dom';
import { Outlet, useNavigate } from 'react-router-dom';
import { RouteResultButton } from '@/component/routebutton/RouteResultButton';
import { IUser, UserContext } from '@/context/UserContext';
import { buttonActiveType } from '@/component/layout/enumTypes';
Expand Down Expand Up @@ -37,8 +37,15 @@ const Divider = () => <hr className="my-6 w-full border-gray-300" />;
export const AddChannel = () => {
const [channelName, setChannelName] = useState<string>('');
const { users, setUsers } = useContext(UserContext);
const { setFooterTitle, setFooterTransparency, setFooterActive, footerOption, setFooterOnClick } =
useContext(FooterContext);
const {
setFooterTitle,
setFooterTransparency,
setFooterActive,
footerOption,
setFooterOnClick,
resetFooterContext,
} = useContext(FooterContext);
const navigate = useNavigate();

/**
* 사용자 추가 함수
Expand Down Expand Up @@ -162,10 +169,14 @@ export const AddChannel = () => {
console.error('채널 생성 실패:', error);
}
};

const goToMainPage = () => {
navigate('/');
resetFooterContext();
};
useEffect(() => {
setFooterOnClick(() => {
createChannelAPI();
goToMainPage();
});
}, [footerOption.active, channelName]); // channelName이 변경될 때마다 실행

Expand Down

0 comments on commit a31703d

Please sign in to comment.