Skip to content

Commit

Permalink
채널톡 버튼 visibility path 설정 (#457)
Browse files Browse the repository at this point in the history
* chore: remove log

* feat: 채널톡 버튼 visibility 적용
  • Loading branch information
hyesungoh authored Nov 5, 2023
1 parent 403055c commit e35a81d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/review/steps/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Props extends StepProps {

const Intro = ({ nickname, next }: Props) => {
const { currentStep, paragraphStep: onSkip } = useParagraphStep();
console.log('currentStep: ', currentStep);

const { isCTAButtonVisible, skip: onCTAButtonVisibleSkip } = useCTAButtonVisible();

useDidMount(() => {
Expand Down
19 changes: 19 additions & 0 deletions src/hooks/channelTalk/useChannelTalkButtonVisibility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import * as ChannelTalk from '@channel.io/channel-web-sdk-loader';

const DIABLED_PATHS: RegExp[] = [/^\/review\/.*/];

const useChannelTalkButtonVisibility = () => {
const router = useRouter();

useEffect(() => {
if (DIABLED_PATHS.some((path) => path.test(router.asPath))) {
ChannelTalk.hideChannelButton();
} else {
ChannelTalk.showChannelButton();
}
}, [router.asPath]);
};

export default useChannelTalkButtonVisibility;
3 changes: 3 additions & 0 deletions src/pages/_app.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import NewFeedbackSnackBarListener from '~/components/snackBar/NewFeedbackSnackB
import SnackBarWrapper from '~/components/snackBar/SnackBarWrapper';
import ToastWrapper from '~/components/toast/ToastWrapper';
import { MAIN_LAYOUT_ID } from '~/constants/name';
import useChannelTalkButtonVisiblity from '~/hooks/channelTalk/useChannelTalkButtonVisibility';
import usePageTrack from '~/hooks/event/usePageTrack';
import GlobalStyles from '~/styles/GlobalStyle';
import defaultTheme from '~/styles/theme';
Expand Down Expand Up @@ -49,6 +50,8 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) {
const router = useRouter();
useOpenExternalBrowser({ where: 'all', onOpen: () => router.push('/') });

useChannelTalkButtonVisiblity();

return (
<SessionProvider session={pageProps.session}>
<MonitoringInitializer />
Expand Down

0 comments on commit e35a81d

Please sign in to comment.